Draw Image
Purpose
The Draw Image function draws a one- or two-dimensional array of pixels.
Syntax
Opcode format | Opcode | Operand Format | Comments |
Extended ASCII | (Image | <ws><ICol>,<IRow><ws><IX1>,<IY1><ws><IX2>,<IY2><ws><IId><ws><TFormat>[<ws>[,]<IData>]+) | Draws an image |
Extended Binary | 0x0002 | <USCol><USRow><LX1><LY1><LX2><LY2><LId><Bcount>[<BRi><BGi><BBi><BAi>]+<LDSize>[<BData>]+} | A bitonal colormapped image. |
0x0003 | <USCol><USRow><LX1><LY1><LX2><LY2><LId><Bcount>[<BRi><BGi><BBi><BAi>]+<LDSize>[<BData>]+} | A Group3X compressed bitonal colormapped image | |
0x0004 | <USCol><USRow><LX1><LY1><LX2><LY2><LId><LDSize>[<BGIndex>]+} | A color-indexed image. | |
0x0005 | <USCol><USRow><LX1><LY1><LX2><LY2><LId><Bcount>[<BRi><BGi><BBi><BAi>]+<LDSize>[<BLIndex>]+} | A colormapped image. | |
0x0006 | <USCol><USRow><LX1><LY1><LX2><LY2><LId><LDSize>[<BRn><BGn><BBn>]+} | An RGB image. | |
0x0007 | <USCol><USRow><LX1><LY1><LX2><LY2><LId><LDSize>[<BRn><BGn><BBn><BAn>]+} | An RGBA image | |
0x0008 | <USCol><USRow><LX1><LY1><LX2><LY2><LId><LDSize>[<BData>]+} | A JPEG compressed RGB image. |
Col The number of columns in the pixel array
Row The number of rows in the pixel array
X1,Y1 A logical coordinate indicating the lower-left corner of the image to be drawn
X2,Y2 A logical coordinate indicating the upper-right corner of the image to be drawn
Id An identifier that may be used by other opcodes to refer to this image (as with texture mapping).
Count The number of colors to be defined in this Color Map. Legal values range from 1 to 256, when using the ASCII version, or 0 to 255 when using the binary form, with zero indicating a colormap of size 256.
Ri, Gi, Bi, Ai The definition of the ith color (the red, green, blue, and alpha components) in the Color Map.
Format A description of how data in the Data array is to be interpreted
DSize The length (in bytes) of the Data sequence that follows
Data A sequence of encoded data that represents the colors of the image pixels, see below for encoding details.
GIndex An index into the global colormap (as defined by Set Color Map) that defines the color of the nth pixel.
LIndex An index into the local colormap (as defined by the Ri, Gi, Bi, Ai parameters) that defines the color of the nth pixel.
Rn, Gn, Bn, An The color definition of the nth pixel (the red, green, blue, and alpha components).
Details
Regardless of the format used, the data that defines the pixel colors within the image is ordered so that the top-left most pixel comes first, followed by the remaining pixels on the top-most row (in left to right order), followed by the subsequent rows (in top-to-bottom order).
The color of pixels in the Bitonal, the Group3X, and the JPEG formats are encoded as follows:
Bitonal
Each pixel of the image is represented by a single bit of data that is used as an index into the supplied colormap. The index bits from 8 sequential pixels are packed into bytes and stored in the DWF file. If image width is not an even multiple of 8 pixels, then each scanline is padded so that they end on a byte boundary.
Group3X
Each raster of the image is compressed individually (using a modified version of CCITT Group 3 compression) and stored in the the DWF file as a series of bits. If the last bit of the last raster does not fill a byte, then the last raster is padded to a byte boundary. The application generating the DWF file may try compressing each raster with all three available methods and then storing the most efficient result. The first two bits of each compressed raster indicate the compression method that was selected by the DWF generating application as follows:
00 (CCITT Group 3 compression of the raster)
In this case the original raster was scanned for run-lengths (the number of consecutive pixels of a certain color), and these run lengths were converted to variable bit length codes using the CCITT Group 3 Huffman table.
01 (CCITT Group 3 compression of the raster XOR'ed with the previous raster)
In this case the original raster was first XOR'ed with its previous raster, and then the resulting raster was compressed using the Group 3 method described above.
10 (Uncompressed Bitonal format)
In this case the original raster is not compressed, and is stored as a normal bitonal raster as described above. This case is used when compression formats "00" and "01" would have caused the raster to grow in size, as happens for noisy or random source data.
11 (Reserved for future use)
JPEG
The pixels of the image are encoded as a JFIF (a JPEG format) data file and stored in the DWF. The Independent JPEG Group's JPEG Toolkit version 6 is used as the reference implementation .
Notes
The array of pixels that define an image (Col x Row) need not have a one-to-one mapping to the logical coordinates that are specified (X1,Y1 to X2,Y2) to position and size the image, as the image is scaled accordingly when displayed.
Implementation in WHIP! Versions
Toolkit Function |
TBD |
Partial |
Full |
Revised in |
Draw Image | - |
- |
2.0 |
- |
See Also