[comp.graphics] What format used in this file?

guansy@cs.tamu.edu (Sheng-Yih Guan) (10/05/90)

I used GBA-Scanin software to scan in a color picture and store it in
Sun output format.  Then I shifted it to our Sun workstation.  Using
ALV package, I found that the configuration of the file is:
	xsize = 300
	ysize = 230
	depth = 8
But, the size of the file is 207800.  If we multiply 300 by 230, we
get 69,000.  So, I thought it must be stored as 3 bytes per pixel.
After I ran the r24r8 (developed by ncsa), I found the following
error: more bytes in file ../images/rat1.sun than dimensions indicate.
Note that r24r8 is a program quantizes a raw RGB 24 bit "pixel" image 
into a 8 bit image with RGB palette.  I can use "dsp" to display the
file.  But, what I got is only 1/3 of the picture.  Can anyone help
me figure out in what format this file is?  

Thanks in advance!

0000000  59a6 6a95 0000 012c 0000 00e6 0000 0008
0000020  0001 0d88 0000 0001 0000 0001 0000 0300
0000040  0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
0000060  1011 1213 1415 1617 1819 1a1b 1c1d 1e1f
0000100  2021 2223 2425 2627 2829 2a2b 2c2d 2e2f
0000120  3031 3233 3435 3637 3839 3a3b 3c3d 3e3f
0000140  4041 4243 4445 4647 4849 4a4b 4c4d 4e4f
0000160  5051 5253 5455 5657 5859 5a5b 5c5d 5e5f
0000200  6061 6263 6465 6667 6869 6a6b 6c6d 6e6f
0000220  7071 7273 7475 7677 7879 7a7b 7c7d 7e7f
0000240  8081 8283 8485 8687 8889 8a8b 8c8d 8e8f
0000260  9091 9293 9495 9697 9899 9a9b 9c9d 9e9f
0000300  a0a1 a2a3 a4a5 a6a7 a8a9 aaab acad aeaf
0000320  b0b1 b2b3 b4b5 b6b7 b8b9 babb bcbd bebf
0000340  c0c1 c2c3 c4c5 c6c7 c8c9 cacb cccd cecf
0000360  d0d1 d2d3 d4d5 d6d7 d8d9 dadb dcdd dedf
0000400  e0e1 e2e3 e4e5 e6e7 e8e9 eaeb eced eeef
0000420  f0f1 f2f3 f4f5 f6f7 f8f9 fafb fcfd feff
0000440  0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
0000460  1011 1213 1415 1617 1819 1a1b 1c1d 1e1f
0000500  2021 2223 2425 2627 2829 2a2b 2c2d 2e2f
0000520  3031 3233 3435 3637 3839 3a3b 3c3d 3e3f
0000540  4041 4243 4445 4647 4849 4a4b 4c4d 4e4f
0000560  5051 5253 5455 5657 5859 5a5b 5c5d 5e5f
0000600  6061 6263 6465 6667 6869 6a6b 6c6d 6e6f
0000620  7071 7273 7475 7677 7879 7a7b 7c7d 7e7f
0000640  8081 8283 8485 8687 8889 8a8b 8c8d 8e8f
0000660  9091 9293 9495 9697 9899 9a9b 9c9d 9e9f
0000700  a0a1 a2a3 a4a5 a6a7 a8a9 aaab acad aeaf
0000720  b0b1 b2b3 b4b5 b6b7 b8b9 babb bcbd bebf
0000740  c0c1 c2c3 c4c5 c6c7 c8c9 cacb cccd cecf
0000760  d0d1 d2d3 d4d5 d6d7 d8d9 dadb dcdd dedf
0001000  e0e1 e2e3 e4e5 e6e7 e8e9 eaeb eced eeef
0001020  f0f1 f2f3 f4f5 f6f7 f8f9 fafb fcfd feff
0001040  0001 0203 0405 0607 0809 0a0b 0c0d 0e0f
0001060  1011 1213 1415 1617 1819 1a1b 1c1d 1e1f
0001100  2021 2223 2425 2627 2829 2a2b 2c2d 2e2f
0001120  3031 3233 3435 3637 3839 3a3b 3c3d 3e3f
0001140  4041 4243 4445 4647 4849 4a4b 4c4d 4e4f
0001160  5051 5253 5455 5657 5859 5a5b 5c5d 5e5f
0001200  6061 6263 6465 6667 6869 6a6b 6c6d 6e6f
0001220  7071 7273 7475 7677 7879 7a7b 7c7d 7e7f
0001240  8081 8283 8485 8687 8889 8a8b 8c8d 8e8f
0001260  9091 9293 9495 9697 9899 9a9b 9c9d 9e9f
0001300  a0a1 a2a3 a4a5 a6a7 a8a9 aaab acad aeaf
0001320  b0b1 b2b3 b4b5 b6b7 b8b9 babb bcbd bebf
0001340  c0c1 c2c3 c4c5 c6c7 c8c9 cacb cccd cecf
0001360  d0d1 d2d3 d4d5 d6d7 d8d9 dadb dcdd dedf
0001400  e0e1 e2e3 e4e5 e6e7 e8e9 eaeb eced eeef
0001420  f0f1 f2f3 f4f5 f6f7 f8f9 fafb fcfd feff
0001440  ffff ffff ffff ffff ffff ffff ffff ffff
0001460  ffff ffff ffff fcff fffc ffff fcff ffff
0001500  ffff fffc ffff fffc ffff ffff fcfc ffff
0001520  ffff ffff ffff ffff ffff ffff ffff ffff

-Stanley

 _       _   _                            ___________          
|  \    /_| / /    Visualization Lab     /____  ____/         
 \  \  //  / /   Computer Science Dept       / /  _   _    _   _   
  | | //  / /     Texas A&M University      / /  / | | \  / | | | ||
  | |//  / / College Station, TX 77843-3112/ /  / /| |  \//|| | | ||
  /  /  / /____    Tel: (409)845-0531     / /  / -|| | |\/ || | !_!| 
 !__/  /______/ stanley@visual1.tamu.edu /_/  /_/ || !_!   || !____!

marks@galadriel.bt.co.uk (Mark Shackleton) (10/05/90)

From article <8812@helios.TAMU.EDU>, by guansy@cs.tamu.edu (Sheng-Yih Guan):
> I used GBA-Scanin software to scan in a color picture and store it in
> Sun output format.  Then I shifted it to our Sun workstation.  Using
> ALV package, I found that the configuration of the file is:
> 	xsize = 300
> 	ysize = 230
> 	depth = 8
> But, the size of the file is 207800.  If we multiply 300 by 230, we
> get 69,000.  So, I thought it must be stored as 3 bytes per pixel.

- The header says the image array SHOULD BE 69000 bytes, one byte per pel,
colour lookup tables supplied before the image data.

> 0000000  59a6 6a95 0000 012c 0000 00e6 0000 0008
> 0000020  0001 0d88 0000 0001 0000 0001 0000 0300
> ...

If you look up the Sun manual page RASTERFILE(5) it gives you the header
format for sun rasterfiles. Also the include file 'rasterfile.h' gives
meanings to some of the types used (it is found in /usr/include).

According to the header data above most of the details you give are
confirmed:

Xres=300, Yres=230, Bits per pel = 8, bytes of image data = 69000,
raster type = 1 (standard, see rasterfile.h), map type = 1 (3x256 colourmap
lookup entries, first red, then green, then blue).

> After I ran the r24r8 (developed by ncsa), I found the following
> error: more bytes in file ../images/rat1.sun than dimensions indicate.
> 

I think the error you get is probably accurate: the file is larger than the
header says it should be. Note however that the image pel values are lookup
entries and the RGB data is not stored explicitly. The colour lookup tables
contained at the start of the file are used to produce the true RGB values.
You could try using the sun SCREENLOAD(1) command to display the file to see
if the file simply has garbage tacked on the end or gets corrupted sooner.

Hope this is helpful,

Mark.

jef@well.sf.ca.us (Jef Poskanzer) (10/05/90)

In the referenced message, guansy@cs.tamu.edu (Sheng-Yih Guan) wrote:
}I used GBA-Scanin software to scan in a color picture and store it in
}Sun output format.  Then I shifted it to our Sun workstation.  Using
}ALV package, I found that the configuration of the file is:
}	xsize = 300
}	ysize = 230
}	depth = 8
}But, the size of the file is 207800.

}0000000  59a6 6a95 0000 012c 0000 00e6 0000 0008
          |_______| |_______| |_______| |_______|
	  Sun       width     height    depth
	  raster    300       230       8
	  magic     decimal   decimal
	  number

}0000020  0001 0d88 0000 0001 0000 0001 0000 0300
	  |_______| |_______| |_______| |_______|
	  length    type      maptype   maplength
	  69000     standard  equalrgb  768
	  decimal                       decimal

The rest is part of the colormap, and it looks like a ramp.

So, if the file's length is really ~207000 instead of ~69000, then I'd
say that whatever wrote the file is broken.
---
Jef

  Jef Poskanzer  jef@well.sf.ca.us  {ucbvax, apple, hplabs}!well!jef
       My .forward contains "| sed '1,/^$/d | /bin/sh ; exit 0".