%!PS % PS Bitmap Properties Reporter % ============================= % by Don Lancaster % Copyright c 2003 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.1 % PostScript-as-language utility reads a bitmap file header and reports properties % to the screen and log file. % ========= % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is required for this program. % After obvious location mods, uncomment ONE of the following two lines: (C:\\windows\\desktop\\gonzo\\gonzo.ps) run % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % GONZO20A Guru Gonzo PostScript power tools (Interim release) % Includes gonzo justification and layout utilities. % Copyright c 1990, 1996, 2001 by Don Lancaster and Synergetics, Box 809, % Thatcher Arizona, 5552 (928) 428-4073 don@tinaja.com support % via http://www.tinaja.com All commercial rights and all electronic % media rights **FULLY** reserved. Reposting is expressly forbidden. % ======== /guru { gonzo begin ps.util.1 begin printerror nuisance begin} def guru % activate gonzo utilities % ========= % input name of bmp file to be evaluated here... /diskfileheader (C:\\WINDOWS\\Desktop\\aaraw_pix\\) store /diskfilesourcename (cdskiv01.bmp) store /sourcefilename diskfileheader diskfilesourcename mergestr store /readfile sourcefilename (r) file store % establish input read file /workstring 600 string store % length of workstring (\n\nProperties of ) sourcefilename mergestr (:\n\n) mergestr print readfile (XX) readstring pop % error message if file not two chars long % BM check: (BM) eq {(File has correct "BM" as first two bytes.\n) print } { sourcefilename ( is not in .BMP format; further eval terminated.\n\n\n) mergestr print quit } ifelse % Filesize: 4 {readfile read pop} repeat % get filesize error if not present 3 {256 mul add} repeat % calculate filesize 10 string cvs % make string (Total BMP filelength is ) exch mergestr ( bytes.\n) mergestr print flush % Reserved: 4 {readfile read pop} repeat % get reserved bytes error if not present 3 {256 mul add} repeat % calculate filesize 10 string cvs % make string false { (First reserved character group is ) exch mergestr ( bytes.\n) mergestr print flush } {pop} ifelse % Data Start: 4 {readfile read pop} repeat % get data start bytes error if not present 3 {256 mul add} repeat % calculate data start 10 string cvs % make string (Actual image data start is ) exch mergestr ( bytes.\n) mergestr print flush % Header Size: 4 {readfile read pop} repeat % get header size bytes error if not present 3 {256 mul add} repeat % calculate header size 10 string cvs % make string (Header size is ) exch mergestr ( bytes.\n) mergestr print flush % Bitmap Width: 4 {readfile read pop} repeat % get bitmap width bytes error if not present 3 {256 mul add} repeat % calculate data start 10 string cvs % make string (Bitmap width is ) exch mergestr ( pixels.\n) mergestr print flush % Bitmap Height: 4 {readfile read pop} repeat % get bitmap height error if not present 3 {256 mul add} repeat % calculate height 10 string cvs % make string (Bitmap height is ) exch mergestr ( pixels.\n) mergestr print flush % Color Planes: 2 {readfile read pop} repeat % get color planes error if not present 1 {256 mul add} repeat % calculate color planes 10 string cvs % make string (Total Color Planes are ) exch mergestr (.\n) mergestr print flush % Bits per pixel: 2 {readfile read pop} repeat % get color planes error if not present 1 {256 mul add} repeat % calculate bits per pixel dup /bpp exch store % save for expanded analysis 10 string cvs % make string (Bits per pixel are ) exch mergestr (.\n) mergestr print flush bpp 1 eq {( This is a monochrome B/W pallette.\n) print flush} if bpp 4 eq {( This is a 4 bit palletized RGB file with 16 possible colors.n) print flush} if bpp 8 eq {( This is an 8 bit palletized RGB file with 256 possible colors.n) print flush} if bpp 8 eq {( This is a 16 bit palletized RGB file with up to 65,536 possible colors.n) print flush} if bpp 24 eq {( This is a 24 bit RGB file with 16,777,216 possible colors.\n) print flush} if % Compression mode: 4 {readfile read pop} repeat % get color planes error if not present 3 {256 mul add} repeat % calculate compression mode dup /cmm exch store % save for expanded analysis 10 string cvs % make string 10 string cvs % make string (Compression mode is ) exch mergestr (.\n) mergestr print flush cmm 0 eq {( This is the BI_RGB uncompressed file mode.\n) print flush} if cmm 1 eq {( This is the BI_RLE8 8-bit run length encoded mode.\n) print flush} if cmm 2 eq {( This is the BI_RLE4 4-bit run length encoded mode.\n) print flush} if % Image size: 4 {readfile read pop} repeat % get image size error if not present 3 {256 mul add} repeat % calculate imagesize 10 string cvs % make string (Image size is ) exch mergestr ( .\n) mergestr print flush % Horizontal Resolution: 4 {readfile read pop} repeat % get h resolution error if not present 3 {256 mul add} repeat % calculate h resolution 10 string cvs % make string (Horizontal resolution is ) exch mergestr ( pixels per meter.\n) mergestr print flush % Vertical Resolution: 4 {readfile read pop} repeat % get v resolution error if not present 3 {256 mul add} repeat % calculate v resolution 10 string cvs % make string (Vertical resolution is ) exch mergestr ( pixels per meter.\n) mergestr print flush bpp 9 lt { % Colors used: 4 {readfile read pop} repeat % get v resolution error if not present 3 {256 mul add} repeat % calculate colors used 10 string cvs % make string (Colors used are ) exch mergestr ( .\n) mergestr print flush % Important colors: 4 {readfile read pop} repeat % get important colors error if not present 3 {256 mul add} repeat % calculate important colors 10 string cvs % make string (Important colors are ) exch mergestr ( .\n) mergestr print flush } if (\n\n\n) print flush % EOF