Why RID?

One of the disadvantages of windows bitmap is that the file is too large for high resolution images (up to 30,000 DPI), while other raster image file formats such as TIFF (Tagged Image File Format) are too complex for most people to write their own readers. RID is a very simple two color (black & white) raster image file format with high compression ratio. You need only half an hour to master it completely. It's quite easy to write your own RID reader. RID is designed in the hope that GerbMagic can interface as many kinds of plotters as possible. GerbMagic supports TIFF (Packbits), BMP (windows bitmap) as output formats, but RID is our recommended format for those who can not handle TIFF. More formats may be supported in future releases of GerbMagic.

RID Specification

RID (Raster Image Data) is a black-and-white graphical file format used by GerbMagic to store rasterized images. It is simpler and more compact than BMP. The advantage of RID over BMP is file size and speed. A bitmap of over 100M bytes, when converted to RID, may be reduced to less than 20M bytes. Smaller files also cost less time to be stored on the disk. Since disk I/O is the most significant bottleneck, using RID gains a lot. The disadvantage of RID is that it is monochrome. But this is not a problem in rasterizing Gerber or PCB files, we don't need colors at all.

  A RID file contains a 48-byte file header followed by raster data , as follows.

0 8 16 24 31

RID signature (0x02040B12)

Reserved (0)

File Type (1) Version (0x0201)

Image left-top X coordinate in pixels (0)

Image left-top Y coordinate in pixels (0)

Image right-bottom X coordinate in pixels

Image right-bottom Y coordinate in pixels

Image X resolution (DPI)

Image Y resolution (DPI)

Offset of raster data (0x30)

left margin in pixels

Top margin in pixels

Right margin in pixels

Bottom margin in pixels

Reserved (0)

Reserved (0)

Raster data begins here...

Consider the following exemplar RID file header for a 1016 DPI, 3552 x 3665  image:

0000: 12 0B 04 02 00 01 01 02 00 00 00 00 00 00 00 00

0010: E0 0D 00 00 51 0E 00 00 F8 03 F8 03 30 00 00 00

0020: 51 00 30 01 51 00 30 01 00 00 00 00 00 00 00 00

File header info:

0000: 0x02040B12 RID signature, MUST be 0x02040B12 ( 4 bytes)

0004: 0x00 Reserved, must be zero ( 1 bytes) 

0005: 0x01 File type identifier, must be 0x01 (1 byte)

0006: 0x0201 Version number. must be 0x0201 ( 2 bytes)

0008: 0x00000000 Image left-top x coordinates, always zero (4 bytes)

000C: 0x00000000 Image left-top y coordinates, always zero ( 4 bytes)

0010: 0x00000DE0 Image right-bottom x coordinates in pixels (4 bytes)

0014: 0x00000DE0 Image right-bottom y coordinates in pixels (4 bytes)

0018: 0x03f8 Image x resolution (1016 DPI) (2 bytes)

001A: 0x03f8 Image y resolution (1016 DPI) (2 bytes)

001C: 0x00000030  Offset of raster data, always 0x30. ( 4 bytes)

0020: 0x0051 Left border width in pixels ( 2 bytes)

0022: 0x0130 Top border width in pixels (2 bytes)

0024: 0x0051 Right border width in pixels (2 bytes)

0026: 0x0130 Bottom border width in pixels (2 bytes)

0028: 0x00000000 Reserved (4 bytes)

002C: 0x00000000 Reserved (4 bytes)

Raster data of each scan line begins at RID file offset 0x30.


line0: i0, i1, i2, ...ik, ...  in

line1: in+1, in+2, in+3, ... in+m


where i0,i1,... are 2-byte integers.

if(ik>0) there are ik 0's.

if(ik<0) there are (-ik) 1's.

0 represents white and 1 represents black.

A scan line is extracted by adding the absolute value of ik accumulatively until image-width pixels. There are no End-Of-Line marks in RID files.

Copyright (c) 2002, Bronzware Inc.  All trademarks are the property of their respective owners.