Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
87 lines (72 sloc) 2.528 kB
Here's the header data blob:
554e 4952 4153 5400-0000 0001 1801 0004
0000 0001 0000 0000-0000 13ec 0000 19c8
0000 0258 0000 0000-0000 0000 ff80 c780
01
// raster data starts here -- BYTE ALIGNED
7f ffff ff7f ffff-ff7f ffff ff7f ffff
// file header (12 bytes)
554e 4952 4153 5400 = "UNIRAST\0"
0000 0001 = 1 page
// page header (32 bytes)
18 = 24bpp
01 = color space 1 (values 1-6 mean different things)
00 = duplex mode (no)
04 = quality 4
0000 0001 = unknown
0000 0000 = unknown
0000 13ec = 5100 = page width
0000 19c8 = 6600 = page height
0000 0258 = 600 = dots per inch
0000 0000 = unknown
0000 0000 = unknown
Another one, for a 17-page file (which reported 0 pages up front, supposedly)
554e 4952 4153 5400-0000 0011 1801 0004
0000 0001 0000 0000-0000 13ec 0000 19c8
0000 0258 0000 0000-0000 0000 ff80 9b80
017f ffff ff7f ffff-ff7f ffff ff7f ffff
554e 4952 4153 5400 = "UNIRAST\0"
0000 0011 = 17 pages
// page header (32 bytes)
0: 18 = bits per pixel
1: 01 = color space
2: 00 = duplex mode
3: 04 = print quality
4: 0000 0001
8: 0000 0000
C: 0000 13ec = 5100 = page width
10: 0000 19c8 = 6600 = page height
14: 0000 0258 = 600 = resolution
18: 0000 0000
1C: 0000 0000
// raster data
20: ff = line repeat code -- how many times this line repeats. Unsigned byte.
21: 80 = PackBits code (see below)
22: 9b = line repeat code
23: 80 = PackBits code
24: 01 = line repeat code
etc...
UNIRAST PackBits Algorithm:
===========================
This is sort of an inverted version of the TIFF PackBits algorithm.
Code is a signed byte, with three interpretations:
switch ( code )
{
case -128: // 0x80
FillRestOfLineWithFillByte();
break;
case 0..127: // copy single pixel and repeat it n+1 times
int n = ((int)code)+1;
uint8_t pixel[pixel_size];
ReadData(&pixel, pixel_size);
while ( n-- > 0 )
{
AddPixelToLine( pixel );
}
break;
case -128..-1: // copy the following (-n)+1 pixels verbatim
int n = (-(int)code)+1;
ReadData(linePtr, n * pixel_size);
break;
}
In TIFF, the 0x80 byte is a NOP used for padding, and the -128..-1 and 0..127 cases are the other way around. I saw some weird results when I tried that...
Jump to Line
Something went wrong with that request. Please try again.