Generalised Bitmap Module ========================= Supported File Formats ---------------------- Short name : Long name : File extensions Comments Bitmap : OS/2 1.1, 1.2, 2.0 / Windows 3.0 bitmap : .BMP .VGA .BGA .RLE .DIB .RL4 .RL8 Reads any of the above if uncompressed or run-length compressed. Will not read CCITT G3 MH Fax compressed files. Will not read 24 bit RLE files. If input is an OS/2 bitmaparray file then which bitmap can be specified. Input options: index=# (default: 0) Can be made to write OS/2 1.1 or Windows 3.0 / OS/2 2.0 bitmaps Output options: 1.1,win,2.0 (default: 1.1, note win=2.0) Note when OS/2 2.0 becomes more prevalent that OS/2 1.x, the default output option will become 2.0 bitmaps. There is confusion as to which way round 1bpp palette entrys go. Foreground and background colours in palette can be inverted on input. Input options: inv Foreground and background colours in palette can be inverted on output. Output options: inv Foreground and background colours in bits can be inverted on input. Input options: invb Foreground and background colours in bits can be inverted on output. Output options: invb GIF : CompuServe Graphics Interchange Format : .GIF Reads 1, bit data files. Reads 2, 3 and 4 bit data files and presents them as 4 bit. Reads 5, 6, 7 and 8 bit data files and presents them as 8 bit. Writes 1, 4 and 8 bit data files. Reads "GIF87a" and "GIF89a" style files. Writes "GIF87a" style files. Should correctly handle deferred clear-code in LZW data stream. Will not generate output with deferred clear-code. ie: should not break older GIF readers. Can specify index of image within file on read. Input option: index=# (default 0) Can specify to return decoded data so far rather than error if corrupt. Input option: errok Can specify screen size to write in output screen descriptor. Output options: xscreen=#,yscreen=# (defaults: image size). Can specify background colour index to write in file BMHD header. Output option: background=# (default: 0) Can specify position information in output image descriptor. Output options: xpos=#,ypos=# (defaults: 0,0). Tested on selection of .GIF files from starbase1.austin.ibm.com. Also tested with output of public domain PPMTOGIF.EXE. Compatibility tested with xloadimage and xv. PCX : ZSoft PC Paintbrush Image format : .PCX Reads and writes 1,4,8 and 24 bit colour files. Subset of plane/bits-per-plane combinations supported. Files are read and written using a run-length coding scheme. Tested using Zsoft originated .PCX files. Compressed runs of pixels are not supposed to straddle scan lines. GBM never does this, but some other applications violate this rule. By default, if GBM finds that a run of pixels is longer than the scan line, it will use the leftover pixels on the next scan line. Some images will not load properly, as they require the loading program to discard those pixels in the run that extend beyond the end of the scan line. This behaviour can be enabled in GBM. Input option: trunc TIFF : Microsoft/Aldus Tagged Image File Format support : .TIF Reads and writes 1,4,8 and 24 bit colour files. Reads uncompressed and Packbits compressed files only. DANGER Currently has untested/unknown-sanity attempt at LZW decode. Write uncompressed files only. Can specify informational tags to append on output. Output options: artist=,software=,make=,model=,host=,documentname=,pagename=,imagedescription= Data is written out as a single large strip. Does not understand tags added after TIFF 5.0 level. Targa : Truevision Targa/Vista bitmap : .TGA .VST .AFI Reads any uncompressed type as 8 bit or 24 bit. Reads both yup and ydown files. Writes out as 8 bit or 16,24,32 bit. Output options: 16,24,32 (default 24) Can be made to write yup and ydown files. Output options: ydown,yup (default: yup) ILBM : Amiga IFF / ILBM Interleaved bitmap format : .IFF .LBM Reads 1 bit palettised files. Reads 2,3 and 4 bit palettised files, returning them as 4 bit. Reads 5,6,7 and 8 bit palettised files, returning them as 8 bit. Writes 1,4 and 8 bit palettised colour files. Understands the RLE compression scheme used. Uses BMHD, CMAP and BODY sections of file only. Only writes BMHD, CMAP and BODY sections in output files. Can specify position information in file BHMD header. Output options: xpos=#,ypos=# (defaults: 0,0). Can specify transparent colour to write in file BMHD header. Output option: transcol=# (default: 0) Can specify aspect ratio to write in file BMHD header. Output options: xaspect=#,yaspect=# (defaults: 1,1). Can specify screen size to write in output BMHD header. Output options: xscreen=#,yscreen=# (defaults: image size). Note that when DeluxePaint etc. try to load an 8 bit IFF file, they switch to a 32 colour (5 bit mode) and only read the 5 least significant planes of the file - this generally looks yukky! Tested using DeluxePaint sample bitmaps. YUV12C : YUV12C M-Motion Frame Buffer : .VID Reads files and presents data as 24 bit data. Writes 24 bit data files by converting them into 12 bit YUV. VID files MUST be a multiple of 4 pixels wide. When writing a non-multiple of 4, the last 1, 2 or 3 pixels are lost. Can specify image origin information in YUV12C header. Output options: xpos=#,ypos=# (defaults: 0,0). Tested using M-Control Program 2.0, Browser sample application. Greymap : Portable Greyscale-map (binary P5 type) : .PGM Credit for file format to Poskancer. No palette present in file format. Reads 8 bit grey scale files. Writes red, green, blue plane or greyscale equivelent of 8 bit image. Output options: r,g,b,k (default: k) Pixmap : Portable Pixel-map (binary P6 type) : .PPM Credit for file format to Poskancer. Reads and writes 24 bit unpalettised RGB data files. KIPS : IBM KIPS : .KPS Reads 8 bit palettised files. Will look for palette in .PAL file unless .KPL file specified. Input options: pal,kpl (default: pal) Writes 8 bit palettised files. Will write palette in .PAL file unless .KPL file specified. Output options: pal,kpl (default: pal) IAX : IBM Image Access eXecutive : .IAX Reads array as 8 bit greyscale. File format does not hold image dimensions. Hence code assumes width is 512 pixels unless overridden. Input options: width=# (default: 512) File format does not include palette. Writes red, green, blue plane or greyscale equivelent of 8 bit image. Output options: r,g,b,k (default: k) XBitmap : X Windows bitmap : .XBM Reads 1bpp X bitmaps, presenting 1's as black, 0's as white. Writes 1bpp X bitmaps, darkest colours as 1's, brightest colour as 0's. Tested upon some .XBM files obtained from spock.hursley.ibm.com Sample Applications ------------------- GBMHDR - Display header information from bitmap files usage: gbmhdr {filename.ext{,opt}} flags: filename.ext input filename (ext used to guess bitmap file format) Bitmap when ext in [BMP VGA BGA RLE DIB RL4 RL8] GIF when ext in [GIF] PCX when ext in [PCX] TIFF when ext in [TIF] Targa when ext in [TGA VST AFI] ILBM when ext in [IFF LBM] YUV12C when ext in [VID] Greymap when ext in [PGM] Pixmap when ext in [PPM] KIPS when ext in [KPS] IAX when ext in [IAX] Xbitmap when ext in [XBM] opt bitmap format specific option to pass to bitmap reader Note that the GBM module only ever surfaces the size and bits per pixel of images (regardless of the other information present in the header). All GBM programs have access to the bitmap file formats documented above, although this list is omitted in subsequent documentation. GBMREF - Reflect in horizontal and/or vertical directions usage: gbmref [-h] [-v] [-t] fn1.ext{,opt} [fn2.ext{,opt}] flags: -h reflect horizontally -v reflect vertically -t transpose x for y fn1.ext{,opt} input filename (with any format specific options) fn2.ext{,opt} optional output filename (or will use fn1 if not present) bitmap formats and options as before Certain non-obvious combinations of -h, -v and -t can be very usefull. None of them can be used for just file format translation. -h -v reflect both, equivelent to 180 degree turn -h -t equivelent to 90 degree turn clockwise -v -t equivelent to 90 degree turn anti-clockwise. GBMSUB - Extract a subrectangle of a bitmap usage: gbmsub [-x x] [-y y] [-w w] [-h h] fn1.ext{,opt} [fn2.ext{,opt}] flags: -x x left edge of rectangle (default 0) -y y bottom edge of rectangle (default 0) -w w width of rectangle (default width of image - x) -h h height of rectangle (default height of image - y) fn1.ext{,opt} input filename (with any format specific options) fn2.ext{,opt} optional output filename (or will use fn1 if not present) bitmap formats and options as before If none of the -x,-y,-w and -h options are supplied the defaults cover the whole of the input file. Hence this program will just read one file and write the data as another. Great for format conversion. GBMBPP - Do various bits per pixel conversions usage: gbmbpp [-m map] [-e] [-h] fn1.ext{,opt} [fn2.ext{,opt}] flags: -m map mapping to perform (default 7x8x4) bw black and white vga 16 colour VGA 8 8 colour (in 4 bit file) 4g 4 bit greyscale 7x8x4 7 levels red, 8 green, 4 blue 8514/A 6x6x6 6 levels red, 6 green, 6 blue 8g 8 bit greyscale tripel 64 reds, 64 greens, 64 blues tripel freqR:G:B:N keep R red, G green, b blue bits, and map to N most used colours in 8 bit palette R:G:B keep R red, G green, B blue bits (eg: 8:8:8) -e enable error-diffusion (default is to truncate) -e not with -m 8g or tripel or freq or -h -h enable halftoning (default is to truncate) -h only with -m 7x8x4, 6x6x6, 8, vga or R:G:B, with no -e fn1.ext{,opt} input filename (with any format specific options) fn2.ext{,opt} optional output filename (or will use fn1 if not present) bitmap formats and options as before This program reads the input bitmap. If it is not 24 bit, then it is expanded to 24 bit per pixel. The data is then processed using the supplied mapping giving a 24,8,4 or 1 bit per pixel image, which is then written to the output bitmap file. The bw mapping produces a 1 bpp output file, vga and 4g gives 4 bit output files, 7x8x4, 6x6x6, 8g, freq and tripel give 8 bit output files. R:G:B (where R,G and B are numbers in the range 0 to 8), gives a 24 bit output file wh1