RasterMaster® SDK Image Data Format
This section describes the formats for decompressed and compressed images. All high-level and low-level methods which decompress or import images convert the data and store it in memory as the MS Windows DIB format (Device Independent Bitmap), which consists of the following:
- Header(DIB_Head)
- Palette
- Imagedata
All formats are converted to either 1, 4, 8, or 24-bits.
MS_Windows DIB Header Format
All images stored in memory start with the following header.
public class_Dib_Head public int
public int biWidth;
int biHeight;
public short biPlanes;
short
public in biCompression;
biSizeImage;
public in biXPelsPerMeter;
biClrUsed;
MS_Windows DIB Palette Format
All images stored in memory except for 24-bit images have a series of the following RGBQUAD
structures. An RGBQUAD
structure exists for each possible color.
Table 6.1: MS_Windows DIB Palette Format
Image Size | RGBQUAD Entries |
---|---|
1-bit | 2 |
4-bit | 16 |
8-bit | 256 |
24-bit | No Entries |
All images stored in memory have the following palette format:
public class RGBQUAD
{
public byte rgbBlue;
public byte rgbGreen;
public byte rgbRed;
public byte rgbReserved;
{
MS_Windows DIB Image Data Format
1, 4, 8, and 24-bit images are stored as packed uncompressed raster data. All rasters must end on a long or a multiple of 4 bytes. Extra bytes are added to rasters not meeting this criterion. They are stored with upside down or the last raster first up to the first or line 0. The raw image data may be much larger than the input document because the image data is not compressed. The size of the image data will depend on the resolution (DPI) and bits per pixel of the input document.
- Please see Determining Memory Requirements for more information on how to calculate the expected size of the raw image data.
- Please see
IMGLOW_set_document_input
in the RasterMaster Java API for information on how to adjust the resolution and bits per pixel of the input document. - Please see Converting File Formats for how to adjust from one resolution (dpi) to another.
The image data is a series of rasters, parallel lines that make up the rectangular image. Each raster is stored as a series of pixels or runs. A run is a series of pixels that are all the same color. All rasters must end on a long or a multiple of 4 bytes. Extra bytes are added to rasters not meeting this criterion. They are stored with upside down or the last raster first up to the first or line 0.
Table 6.2: MS_Windows DIB Image Data Format
Image Size | Byte Size |
---|---|
1-bit | 8 pixels |
4-bit | 2 pixels |
8- bit | 1 pixel |
24-bit | 3 bytes equals 1 pixel, starting with the blue, green, then red values |
For black and white images, each run is stored as a 32-bit integer. The first wordint
is a byte count of the entire raster including the byte count wordint
. This is followed by a white then a black column. The line alternates from white to black until the end of the raster.
A line always starts with a white column. If the first pixel is black, the first white entry is then zero. The line must end with at least three entries for the horizontal width.
Example 6.3: WORDINT
For a raster or width of 100.
DWORDINT 0 - 12 Total byte count.
DWORDINT 1 - 5 White until pixel 5.
WORDINT 2 - 10 Black from pixel 5 to pixel 10.
WORDINT 3 - 100 White to end of raster.
DWORDINT 4 - 100
DWORDINT 5 - 100
Changing the DPI in the RasterMaster® SDK Library
When the library decompresses an image, it is converted into an MS-Windows device independent bitmap (DIB), which contains a header for the width, height, and also the dots per inch.
To change or look at the DPI information from an image use the following code:
Example 6.4: Changing the DPI in the RasterMaster® SDK Library
int xDPI, yDPI
xDPI = Simage.getXdpi() yDPI = Simage.getYpdi()
if (xDPI < 300 || yDPI < 300) {
Simage.setXdpi(300);
Simage.setYdpi(300);
}
Have questions, corrections, or concerns about this topic? Please let us know!