You subclass this to be served an image. The only methods you certainly should handle are dimensions and row; dimensions is called with the image data (be sure to call the superclass), and row is called for each row in the image. To get row data in a format more to your liking, use the convert method.
Public Member Functions | |
| this (char[] filename) | |
| Load image from the file. | |
| this (char[] filename, Stream stream) | |
| Load image from the stream. | |
| void | dimensions (int width, int height, int depth, char[] type, bit alpha) |
| The dimensions and color format of the subsequent image. | |
| void | topdown () |
| Indicate that this image will be read in top-down row order. | |
| void | bottomup () |
| Indicate that this image will be read in bottom-up row order. | |
| void | paletteColors (Color[] colors) |
| Indicate a palette. | |
| void | row (int y, ubyte[] data) |
| Read in a single row. | |
| bit | prefer8to16 () |
| Return whether 16-bit images are okay. | |
| bit | prefer8to124 () |
| Return whether 1, 2, and 4-bit images are okay. | |
| bit | preferAlpha () |
| Return whether an alpha channel is preferred. | |
| int | readIndex (ubyte[] data, int depth, int index) |
| Read an indexed value. | |
| int | readScale (ubyte[] data, int depth, int index, int maximum) |
| Read a value rescaled into another range. | |
| void | writeIndex (ubyte[] data, int depth, int index, uint value) |
| Write an indexed value. | |
| void | writeScale (ubyte[] data, int depth, int index, uint value, int maximum) |
| Write a value rescaled from another range. | |
| ubyte[] | convert (ubyte[] data, int ddepth, char[] dtype, bit dalpha) |
| Convert a row of data from the input to what you want. | |
| int | channelCount (char[] type, bit alpha) |
| Get the number of channels in a pixel specification. | |
| int | channelCount () |
| Get the number of channels. | |
| int | bitsPerPixel (int depth, char[] type, bit alpha) |
| Get the number of bits in a pixel. | |
| int | bitsPerPixel () |
| Get the number of bits in a pixel. | |
| int | bytesPerRow (int width, int depth, char[] type, bit alpha) |
| Get the number of bytes in a row. | |
| int | bytesPerRow () |
| Get the number of bytes in a row. | |
Public Attributes | |
| int | width |
| Width of the image, passed to dimensions. | |
| int | height |
| Height of the image, passed to dimensions. | |
| int | depth |
| Bit depth of each channel in the image, passed to dimensions. | |
| char[] | type |
| Color type of the image; "luminance", "index", or "rgb". | |
| bit | alpha |
| Whether this image has a dedicated alpha channel. | |
| Color[] | palette |
| A previously given palette. | |
| ubyte[] | digCommonResult |
| Used by convert. | |
|
||||||||||||||||||||||||
|
The dimensions and color format of the subsequent image. depth is the bit depth of each channel and can be 1, 2, 4, 8, or 16. type can be "luminance", "index", or "rgb". alpha indicates whether an alpha channel is also given. |
|
|
Return whether 1, 2, and 4-bit images are okay. You may still be served them, in which case you should convert them to a higher depth, but some packages can do this automatically. |
|
|
Return whether 16-bit images are okay. You may still be served them, in which case you should convert them to a lower depth, but some packages can do this automatically. |
|
||||||||||||
|
Read in a single row. y is the row index, and data is the content. For 1, 2, and 4-bit depth, the bits are in decreasing order (the first channel of the first pixel of a bit image is & 128 of the first byte, & 64 for the second channel, etcetera). A type of luminance has a single channel, as does index, and rgb has three in red, green, and blue order. If there is an alpha channel, this comes next. For example, take an rgb image with an alpha channel in 2-bit depth. The first byte can be taken apart as so:
ubyte v = first byte;
ubyte r = (v & 0b11000000) >> 6; // 0 to 3.
ubyte g = (v & 0b00110000) >> 4;
ubyte b = (v & 0b00001100) >> 2;
ubyte a = (v & 0b00000011);
There is no padding between pixels. |
|
|
Indicate that this image will be read in top-down row order. The opposite of this is bottomup, although neither of these will be called if it is unknowable. |
|
|
Bit depth of each channel in the image, passed to dimensions. This can be 1, 2, 4, 8, or 16. |
1.3.2