Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
images [2016/02/22 10:41] christian [Implementation] |
images [2016/09/24 08:15] dokuadmin ↷ Links adapted because of a move operation |
||
---|---|---|---|
Line 2: | Line 2: | ||
Bitmapped images are described in chapter 8.9 //Images// on page 203 of the {{pdf32000_2008.pdf# | Bitmapped images are described in chapter 8.9 //Images// on page 203 of the {{pdf32000_2008.pdf# | ||
+ | |||
+ | The implementation is in package '' | ||
===== Usage ===== | ===== Usage ===== | ||
Line 23: | Line 25: | ||
renderer paintXObject: | renderer paintXObject: | ||
</ | </ | ||
+ | |||
+ | {{demo20_ImagesUsage.pdf}} shows the result with an example image. | ||
+ | |||
+ | {{demo21_Images.pdf}} shows some PDF features of images (masking, rotation, interpolation, | ||
===== Object Models ===== | ===== Object Models ===== | ||
Line 73: | Line 79: | ||
</ | </ | ||
- | In PDF images are defined by the number of bits per color component (1, 2, 4, 8 or 16 bit). The colorspace defines the number of components and their layout for a pixel. Any colorspace permitted in PDF can be used (see [[Colors]]). For images converted from Smalltalk, only ''/ | + | In PDF images are defined by the number of bits per color component (1, 2, 4, 8 or 16 bit). The colorspace defines the number of components and their layout for a pixel. Any colorspace permitted in PDF can be used (see [[:colors]]). For images converted from Smalltalk, only ''/ |
A '' | A '' | ||
Line 95: | Line 101: | ||
The conversion methods are implemented in the '' | The conversion methods are implemented in the '' | ||
+ | |||
+ | {{ : | ||
The default behavior is to transfer the pixels one by one. For each pixel, the bits are read from the specified location in the source image bytes and interpreted as color ('' | The default behavior is to transfer the pixels one by one. For each pixel, the bits are read from the specified location in the source image bytes and interpreted as color ('' | ||
Line 100: | Line 108: | ||
This default implementation ('' | This default implementation ('' | ||
- | Some conversions can be greatly sped up by exploiting the internal byte organization of the image bits and transfering them directly. While this is possible for many useful forms, it is not possible in general (a Smalltalk image with a palette of more than 255 colors, for example). | + | Some conversions can be greatly sped up (one or two orders of magnitude) |
The following conversions are currently optimized: | The following conversions are currently optimized: | ||
Line 109: | Line 117: | ||
* Depth{2 4 8)Image with a MappedPalette. | * Depth{2 4 8)Image with a MappedPalette. | ||
- | The direct conversion of an image with a mapped palette is special. Since RGB color components are represented with 13 bits in Smalltalk, but only 8 bits are used in PDF, a Smalltalk palette may have more than one entry for one 8 bit RGB color. This is correctly handled when converting the image pixel by pixel, because each color is stored as 8 bit color in the PDF /Indexed colorspace, thereby aligning different 3x13 bit colors to the same 3x8 bit color. | + | The direct conversion of an image with a mapped palette is special. Since RGB color components are represented with 13 bits in Smalltalk, but using 8 bits in PDF, a Smalltalk palette may have more than one entry for one 8 bit RGB color. This is correctly handled when converting the image pixel by pixel, because each color is stored as 8 bit color in the PDF /Indexed colorspace, thereby aligning different 3x13 bit colors to the same 3x8 bit color. |
- | When converting such image optimized by converting the palette and using the same indexes for the pixels, the /Indexed colorspace may contain several entries for the same color. | + | When converting such image optimized by converting the palette and using the same indexes for the pixels |
- | ===== Disclaimer | + | ===== To be done ===== |
- | Not covered are the special | + | ==== Filter ==== |
+ | |||
+ | Although all Smalltalk images can be used for PDF, not all PDF images can be transformed to Smalltalk images. For one, several | ||
* **RunLengthDecode** 8 bit monochrome images | * **RunLengthDecode** 8 bit monochrome images | ||
* **CCITTFaxDecode** CCITT encoded 1 bit monochrome images | * **CCITTFaxDecode** CCITT encoded 1 bit monochrome images | ||
* **JBIG2Decode** JBIG2 encoded 1 bit monochrome images | * **JBIG2Decode** JBIG2 encoded 1 bit monochrome images | ||
* **DCTDecode** JPEG encoded 8 bit grayscale or color images | * **DCTDecode** JPEG encoded 8 bit grayscale or color images | ||
- | * **JPXDecode** JPEG2000 encoded grayscale or color images | + | * **JPXDecode** JPEG2000 encoded grayscale or color images. |
+ | |||
+ | This means that it is not possible to extract such images from PDF. Nor is it possible to store images in the most efficient way in a PDF. This feature is valuable and I hope to implement some of the filters in the not too distant future. | ||
- | These are not implemented (yet), so that it is not possible to extract | + | Secondly, PDF can have images in other colorspaces than RGB or Grayscale; most notable |
+ | ==== Inlined Images ==== | ||
+ | Images in PDF can be inlined in the /Contents stream instead of storing them in the /Resources as /XObject. Only a subset of legal PDF images can be inlined and it is discouraged for large images. Even though, I have not seen such image in a real-world PDF, this feature should be implemented for completeness. |