| 1 | <HTML>
|
|---|
| 2 | <HEAD>
|
|---|
| 3 | <TITLE>Generalised Bitmap Module</TITLE>
|
|---|
| 4 | </HEAD>
|
|---|
| 5 | <BODY>
|
|---|
| 6 |
|
|---|
| 7 | <H1>Generalised Bitmap Module</H1>
|
|---|
| 8 |
|
|---|
| 9 | <!--...sIntroduction:0:-->
|
|---|
| 10 | <H2>Introduction</H2>
|
|---|
| 11 |
|
|---|
| 12 | <P>The GBM package consists of a number of components :-
|
|---|
| 13 |
|
|---|
| 14 | <P>
|
|---|
| 15 | <UL>
|
|---|
| 16 | <LI>A peice of code capable of loading and saving bitmap files
|
|---|
| 17 | in a variety of popular
|
|---|
| 18 | <A HREF="#formats">file formats</A>.
|
|---|
| 19 | Programs may be written to use this code, and thus be able to
|
|---|
| 20 | access a variety of file formats without actually knowing
|
|---|
| 21 | what format the pictures are in, or any details about file format itself.
|
|---|
| 22 | <LI>Some peices of code that perform common operations on bitmap data.
|
|---|
| 23 | Such as reflection, X-Y transposition, rotation, cropping, scaling,
|
|---|
| 24 | halftoning, error-diffusing, palette mapping, and colour space mapping.
|
|---|
| 25 | <LI>Some sample
|
|---|
| 26 | <A HREF="#cmdline">command line programs</A>
|
|---|
| 27 | which use the above code.
|
|---|
| 28 | </UL>
|
|---|
| 29 | <!--...e-->
|
|---|
| 30 | <!--...sDistributed packages:0:-->
|
|---|
| 31 | <H2>Distributed packages</H2>
|
|---|
| 32 |
|
|---|
| 33 | <P>The GBM packages are best obtained via the links on my home page :-
|
|---|
| 34 |
|
|---|
| 35 | <P>
|
|---|
| 36 | <UL>
|
|---|
| 37 | <LI><A HREF="http://www.interalpha.net/customer/nyangau/">
|
|---|
| 38 | <CODE>http://www.interalpha.net/customer/nyangau/</CODE></A>
|
|---|
| 39 | </UL>
|
|---|
| 40 |
|
|---|
| 41 | <P>The basic GBMOS2 package contains all the OS/2 executables.
|
|---|
| 42 | Often GBMDOS32, GBMWIN, GBMAIX, GBMLINUX and other packages are available too.
|
|---|
| 43 |
|
|---|
| 44 | <P>The GBMSRC source package contains all the source code,
|
|---|
| 45 | which is 32 bit portable C.
|
|---|
| 46 | Makefiles for OS/2 (VisualAge C++),
|
|---|
| 47 | Win32 (Visual C++ 4.2, 5.0, 6.0),
|
|---|
| 48 | and UNIX (using xlc under AIX, and gcc under Linux) are included.
|
|---|
| 49 | See the <A HREF="gbmsrc.htm">source documentation</A>
|
|---|
| 50 |
|
|---|
| 51 | <P>All the GBM source code is written using Andys Source Code Folding Editor,
|
|---|
| 52 | and this is also accessible via my home page.
|
|---|
| 53 | The source will look funny (have strange comments in it, etc.) when veiwed
|
|---|
| 54 | using a regular 'flat' editor.
|
|---|
| 55 |
|
|---|
| 56 | <P>There is a GBMOS2PM package, which contains programs specific to OS/2
|
|---|
| 57 | and to OS/2 with Presentation Manager.
|
|---|
| 58 | These include GBMV, GBMV2, GBMVFSA and GBMLOGO.
|
|---|
| 59 | These used to be a part of the standard packages, but I have recently
|
|---|
| 60 | split them out as most people don't have or use OS/2.
|
|---|
| 61 | See the <A HREF="gbmos2pm.htm">OS/2 extras documentation</A>.
|
|---|
| 62 | <!--...e-->
|
|---|
| 63 | <!--...sJPEG support:0:-->
|
|---|
| 64 | <A NAME="jpeg">
|
|---|
| 65 | <H2>JPEG support</H2></A>
|
|---|
| 66 |
|
|---|
| 67 | <P>The Independant JPEG Group have generously allowed others to
|
|---|
| 68 | use their source code to their JPEG handling library.
|
|---|
| 69 | The only condition of use is that the IJG must be credited for their work.
|
|---|
| 70 | Try looking for this library at :-
|
|---|
| 71 |
|
|---|
| 72 | <P>
|
|---|
| 73 | <UL>
|
|---|
| 74 | <LI><A HREF="ftp://sun2.urz.uni-heidelberg.de/pub/simtel/graphics/jpegsr6a.zip">
|
|---|
| 75 | <CODE>ftp://sun2.urz.uni-heidelberg.de/pub/simtel/graphics/jpegsr6a.zip</CODE></A>.
|
|---|
| 76 | <LI><A HREF="ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/jpegsr6a.zip">
|
|---|
| 77 | <CODE>ftp://ftp.simtel.net/pub/simtelnet/msdos/graphics/jpegsr6a.zip</CODE></A>.
|
|---|
| 78 | <LI><A HREF="http://sunsite.doc.ic.ac.uk/computing/systems/ibmpc/simtel/msdos/graphics/jpegsr6a.zip">
|
|---|
| 79 | <CODE>http://sunsite.doc.ic.ac.uk/computing/systems/ibmpc/simtel/msdos/graphics/jpegsr6a.zip</CODE></A>.
|
|---|
| 80 | </UL>
|
|---|
| 81 |
|
|---|
| 82 | <P>Martin Lisowski <CODE><mlisowsk@aixterm1.urz.uni-heidelberg.de></CODE>
|
|---|
| 83 | has generously donated his <CODE>gbmjpg.c</CODE> to GBM.
|
|---|
| 84 | This file allows GBM to use the IJG 6a library.
|
|---|
| 85 |
|
|---|
| 86 | <P>GBM may be compiled up either with or without JPEG support.
|
|---|
| 87 | If you use the JPEG enabled variety of GBM in your project,
|
|---|
| 88 | you must credit the IJG.
|
|---|
| 89 |
|
|---|
| 90 | <P>This code has been tested on OS/2, AIX, Linux and NT.
|
|---|
| 91 | <!--...e-->
|
|---|
| 92 | <!--...sFormats supported:0:-->
|
|---|
| 93 | <A NAME="formats">
|
|---|
| 94 | <H2>Formats supported</H2></A>
|
|---|
| 95 |
|
|---|
| 96 | <P>GBM supports a variety of file formats, such as GIF, TIFF, PCX etc..
|
|---|
| 97 |
|
|---|
| 98 | <P>Normally, applications using GBM deduce the file format from the file
|
|---|
| 99 | extension.
|
|---|
| 100 | eg: <CODE>filename.gif</CODE> is a Compu$erve GIF file.
|
|---|
| 101 |
|
|---|
| 102 | <P>When specifying file names to programs written using GBM, it is usually
|
|---|
| 103 | possible to append a comma seperated list of format specific options.
|
|---|
| 104 | eg: you can say <CODE>webpiccy.gif,ilace</CODE>.
|
|---|
| 105 | In this case, the <CODE>ilace</CODE> is a cue to the code in GBM which writes
|
|---|
| 106 | GIF files, to tell it to write an interlaced GIF.
|
|---|
| 107 |
|
|---|
| 108 | <P>
|
|---|
| 109 | <PRE>
|
|---|
| 110 | Short name : Long name : File extensions
|
|---|
| 111 | Comments
|
|---|
| 112 | </PRE>
|
|---|
| 113 | <PRE>
|
|---|
| 114 | Bitmap : OS/2 1.1, 1.2, 2.0 / Windows 3.0 bitmap : .BMP .VGA .BGA .RLE .DIB .RL4 .RL8
|
|---|
| 115 | Reads any of the above if uncompressed or run-length compressed.
|
|---|
| 116 | Will not read CCITT G3 MH Fax compressed files.
|
|---|
| 117 | Will not read 24 bit RLE files.
|
|---|
| 118 | If input is an OS/2 bitmaparray file then which bitmap can be specified.
|
|---|
| 119 | Input options: index=# (default: 0)
|
|---|
| 120 | Can be made to write OS/2 1.1 or Windows 3.0 / OS/2 2.0 bitmaps
|
|---|
| 121 | Output options: 1.1,win,2.0 (default: 2.0, note win=2.0)
|
|---|
| 122 | The handling of 1bpp bitmaps is a little complicated.
|
|---|
| 123 | When reading 1bpp bitmaps, the palette is ignored.
|
|---|
| 124 | 1's are considered foreground, and they are considered black.
|
|---|
| 125 | 0's are considered background, and they are considered white.
|
|---|
| 126 | This agrees with WorkPlace Shell WPFolder background mode, and most PM
|
|---|
| 127 | programs, but notably disagrees with Windows PBrush.
|
|---|
| 128 | When writing 1bpp bitmaps, the actual 2 colours in the palette are
|
|---|
| 129 | ignored, and a fixed palette is written. This is so that the resulting
|
|---|
| 130 | bitmap will display 1's in black on 0's in white when displayed by
|
|---|
| 131 | WPFolder etc..
|
|---|
| 132 | Foreground and background colours in palette can be inverted on input.
|
|---|
| 133 | Input options: inv
|
|---|
| 134 | Foreground and background colours in palette can be inverted on output.
|
|---|
| 135 | Output options: inv
|
|---|
| 136 | Foreground and background colours in bits can be inverted on input.
|
|---|
| 137 | Input options: invb
|
|---|
| 138 | Foreground and background colours in bits can be inverted on output.
|
|---|
| 139 | Output options: invb
|
|---|
| 140 | The best option for writing 1bpp bitmaps is to write the darkest
|
|---|
| 141 | colour as the foreground. The resulting bitmap will have darkest
|
|---|
| 142 | colour as 1 bits, and lightest colour as 0 bits. When reloaded
|
|---|
| 143 | WPFolders and GBM will give a black 1's on white 0's picture.
|
|---|
| 144 | Output option: darkfg
|
|---|
| 145 | Also, there is an option for writing 1bpp bitmaps with the lightest
|
|---|
| 146 | colour as foreground. As WPFolder and GBM assume the foreground is
|
|---|
| 147 | black and the background is white on reloading, this will typically
|
|---|
| 148 | cause the image to be inverted.
|
|---|
| 149 | Output option: lightfg
|
|---|
| 150 | </PRE>
|
|---|
| 151 | <PRE>
|
|---|
| 152 | GIF : CompuServe Graphics Interchange Format : .GIF
|
|---|
| 153 | Reads 1, bit data files.
|
|---|
| 154 | Reads 2, 3 and 4 bit data files and presents them as 4 bit.
|
|---|
| 155 | Reads 5, 6, 7 and 8 bit data files and presents them as 8 bit.
|
|---|
| 156 | Writes 1, 4 and 8 bit data files.
|
|---|
| 157 | Reads "GIF87a" and "GIF89a" style files.
|
|---|
| 158 | Writes "GIF87a" style files.
|
|---|
| 159 | Will write "GIF89a" file, if the transcol= option is used.
|
|---|
| 160 | Should correctly handle deferred clear-code in LZW data stream.
|
|---|
| 161 | Will not generate output with deferred clear-code.
|
|---|
| 162 | ie: should not break older GIF readers.
|
|---|
| 163 | Can specify index of image within file on read.
|
|---|
| 164 | Input option: index=# (default 0)
|
|---|
| 165 | Can specify to return decoded data so far rather than error if corrupt.
|
|---|
| 166 | Input option: errok
|
|---|
| 167 | Can specify screen size to write in output screen descriptor.
|
|---|
| 168 | Output options: xscreen=#,yscreen=# (defaults: image size).
|
|---|
| 169 | Can specify background colour index to write in file BMHD header.
|
|---|
| 170 | Output option: background=# (default: 0)
|
|---|
| 171 | Can specify position information in output image descriptor.
|
|---|
| 172 | Output options: xpos=#,ypos=# (defaults: 0,0).
|
|---|
| 173 | Can specify transparent colour index (useful for HTML embedding).
|
|---|
| 174 | Output option: transcol=# (default is none).
|
|---|
| 175 | Can specify transparent colour index same as first pixel.
|
|---|
| 176 | Output option: transcol=edge
|
|---|
| 177 | Can write interlaced GIFs (good for HTML <IMG=SRC="x.gif">)
|
|---|
| 178 | Output option: ilace
|
|---|
| 179 | Extensively test on GIF files from a wide variety of sources.
|
|---|
| 180 | Compatibility tested with xloadimage and xv.
|
|---|
| 181 | </PRE>
|
|---|
| 182 | <PRE>
|
|---|
| 183 | PCX : ZSoft PC Paintbrush Image format : .PCX .PCC
|
|---|
| 184 | Reads and writes 1,4,8 and 24 bit colour files.
|
|---|
| 185 | Subset of plane/bits-per-plane combinations supported.
|
|---|
| 186 | Files are read and written using a run-length coding scheme.
|
|---|
| 187 | Tested using Zsoft originated .PCX files.
|
|---|
| 188 | Compressed runs of pixels are not supposed to straddle scan lines.
|
|---|
| 189 | GBM never does this, but some other applications violate this rule.
|
|---|
| 190 | By default, if GBM finds that a run of pixels is longer than the scan
|
|---|
| 191 | line, it will use the leftover pixels on the next scan line.
|
|---|
| 192 | Some images will not load properly, as they require the loading
|
|---|
| 193 | program to discard those pixels in the run that extend beyond the end
|
|---|
| 194 | of the scan line. This behaviour can be enabled in GBM.
|
|---|
| 195 | Input option: trunc
|
|---|
| 196 | </PRE>
|
|---|
| 197 | <PRE>
|
|---|
| 198 | TIFF : Microsoft/Aldus Tagged Image File Format support : .TIF .TIFF
|
|---|
| 199 | Reads and writes 1,4,8 and 24 bit colour files.
|
|---|
| 200 | Can almost read all TIFF 6.0 Baseline compliant files.
|
|---|
| 201 | Can read uncompressed and Packbits images.
|
|---|
| 202 | CCITT Modified huffman compression is the missing peice.
|
|---|
| 203 | Can read some files with extensions to Baseline.
|
|---|
| 204 | Can read 1bpp greyscale and palettised files.
|
|---|
| 205 | Can read Orientation==4 files.
|
|---|
| 206 | Can read PlanarConfiguration==2 files for RGB image data.
|
|---|
| 207 | Can read LZW compressed files too.
|
|---|
| 208 | Can also read CMYK 4 colour seperation files.
|
|---|
| 209 | No JPEG or Y-Cb-Cr support.
|
|---|
| 210 | Writes files that comply with TIFF 6.0 Baseline.
|
|---|
| 211 | Usually writes uncompressed files only.
|
|---|
| 212 | Data is written out as a single large strip.
|
|---|
| 213 | Can specify image within TIFF file with many images
|
|---|
| 214 | Input option: index=# (default: 0)
|
|---|
| 215 | Can write 1bpp as non-Baseline file preserving fg/bg cols
|
|---|
| 216 | Output option: pal1bpp
|
|---|
| 217 | Can ask for LZW compression.
|
|---|
| 218 | Output option: lzw
|
|---|
| 219 | Can specify informational tags to append on output.
|
|---|
| 220 | Output options: artist=,software=,make=,model=,host=,documentname=,pagename=,imagedescription=
|
|---|
| 221 | </PRE>
|
|---|
| 222 | <PRE>
|
|---|
| 223 | Targa : Truevision Targa/Vista bitmap : .TGA .VST .AFI
|
|---|
| 224 | Reads any uncompressed/run-length-compressed files.
|
|---|
| 225 | Reads 8 bit and 24 bit files.
|
|---|
| 226 | Can read 8 bit greyscale and 8 bit colour mapped files.
|
|---|
| 227 | Reads both yup and ydown files.
|
|---|
| 228 | Writes out as uncompressed 8 bit or 16,24,32 bit.
|
|---|
| 229 | Output options: 16,24,32 (default 24)
|
|---|
| 230 | 8 bit data is always written out as a colour mapped file.
|
|---|
| 231 | Can be made to write yup and ydown files.
|
|---|
| 232 | Output options: ydown,yup (default: yup)
|
|---|
| 233 | </PRE>
|
|---|
| 234 | <PRE>
|
|---|
| 235 | ILBM : Amiga IFF / ILBM Interleaved bitmap format : .IFF .LBM
|
|---|
| 236 | Reads 1 bit palettised files.
|
|---|
| 237 | Reads 2,3 and 4 bit palettised files, returning them as 4 bit.
|
|---|
| 238 | Reads 5,6,7 and 8 bit palettised files, returning them as 8 bit.
|
|---|
| 239 | Reads 24 bit images and returns them as 24 bit.
|
|---|
| 240 | Reads HAM6, HAM8, SHAM and Extra-Halfbrite images.
|
|---|
| 241 | HAM6, HAM8 and SHAM returned as 24 bit data.
|
|---|
| 242 | Writes 1,4 and 8 bit palettised colour files.
|
|---|
| 243 | Writes 24 bit files normally, or by converting to HAM6 first.
|
|---|
| 244 | This loses quality but results are still better than 8 bit.
|
|---|
| 245 | Understands the RLE compression scheme used.
|
|---|
| 246 | Uses BMHD, CMAP, CAMG and BODY sections of file only.
|
|---|
| 247 | Only writes BMHD, CMAP, CAMG and BODY sections in output files.
|
|---|
| 248 | Can specify position information in file BHMD header.
|
|---|
| 249 | Output options: xpos=#,ypos=# (defaults: 0,0).
|
|---|
| 250 | Can specify transparent colour to write in file BMHD header.
|
|---|
| 251 | Output option: transcol=# (default: 0)
|
|---|
| 252 | Can specify aspect ratio to write in file BMHD header.
|
|---|
| 253 | Output options: xaspect=#,yaspect=# (defaults: 1,1).
|
|---|
| 254 | Can specify screen size to write in output BMHD header.
|
|---|
| 255 | Output options: xscreen=#,yscreen=# (defaults: image size).
|
|---|
| 256 | Can specify to write 24 bpp data in HAM6 format.
|
|---|
| 257 | Output option: ham6
|
|---|
| 258 | Note that when DeluxePaint etc. try to load an 8 bit IFF file, they
|
|---|
| 259 | switch to a 32 colour (5 bit mode) and only read the 5 least
|
|---|
| 260 | significant planes of the file - this generally looks yukky!
|
|---|
| 261 | Tested using DeluxePaint sample bitmaps.
|
|---|
| 262 | </PRE>
|
|---|
| 263 | <PRE>
|
|---|
| 264 | YUV12C : YUV12C M-Motion Frame Buffer : .VID
|
|---|
| 265 | Reads files and presents data as 24 bit data.
|
|---|
| 266 | Writes 24 bit data files by converting them into 12 bit YUV.
|
|---|
| 267 | VID files MUST be a multiple of 4 pixels wide.
|
|---|
| 268 | When writing a non-multiple of 4, the last 1, 2 or 3 pixels are lost.
|
|---|
| 269 | Can specify image origin information in YUV12C header.
|
|---|
| 270 | Output options: xpos=#,ypos=# (defaults: 0,0).
|
|---|
| 271 | Tested using M-Control Program 2.0, Browser sample application.
|
|---|
| 272 | </PRE>
|
|---|
| 273 | <PRE>
|
|---|
| 274 | Greymap : Portable Greyscale-map (binary P5 type) : .PGM
|
|---|
| 275 | Credit for file format to Jef Poskancer.
|
|---|
| 276 | No palette present in file format.
|
|---|
| 277 | Reads 8 bit grey scale files.
|
|---|
| 278 | Writes red, green, blue plane or greyscale equivelent of 8 bit image.
|
|---|
| 279 | Output options: r,g,b,k (default: k)
|
|---|
| 280 | </PRE>
|
|---|
| 281 | <PRE>
|
|---|
| 282 | Pixmap : Portable Pixel-map (binary P6 type) : .PPM
|
|---|
| 283 | Credit for file format to Jef Poskancer.
|
|---|
| 284 | Reads and writes 24 bit unpalettised RGB data files.
|
|---|
| 285 | </PRE>
|
|---|
| 286 | <PRE>
|
|---|
| 287 | KIPS : IBM KIPS : .KPS
|
|---|
| 288 | Reads 8 bit palettised files.
|
|---|
| 289 | Will look for palette in .PAL file unless .KPL file specified.
|
|---|
| 290 | Input options: pal,kpl (default: pal)
|
|---|
| 291 | Writes 8 bit palettised files.
|
|---|
| 292 | Will write palette in .PAL file unless .KPL file specified.
|
|---|
| 293 | Output options: pal,kpl (default: pal)
|
|---|
| 294 | </PRE>
|
|---|
| 295 | <PRE>
|
|---|
| 296 | IAX : IBM Image Access eXecutive : .IAX
|
|---|
| 297 | Reads array as 8 bit greyscale.
|
|---|
| 298 | File format does not hold image dimensions.
|
|---|
| 299 | Hence code assumes width is 512 pixels unless overridden.
|
|---|
| 300 | Input options: width=# (default: 512)
|
|---|
| 301 | File format does not include palette.
|
|---|
| 302 | Writes red, green, blue plane or greyscale equivelent of 8 bit image.
|
|---|
| 303 | Output options: r,g,b,k (default: k)
|
|---|
| 304 | </PRE>
|
|---|
| 305 | <PRE>
|
|---|
| 306 | XBitmap : X Windows bitmap : .XBM
|
|---|
| 307 | Reads 1bpp X bitmaps, presenting 1's as black, 0's as white.
|
|---|
| 308 | Writes 1bpp X bitmaps, darkest colours as 1's, brightest colour as 0's.
|
|---|
| 309 | Tested upon some sample .XBM files.
|
|---|
| 310 | </PRE>
|
|---|
| 311 | <PRE>
|
|---|
| 312 | Sprite : Archimedes Sprite format from RiscOS : .SPR .SPRITE
|
|---|
| 313 | Technically sprite files have no extension.
|
|---|
| 314 | But GBM recognises .SPR and .SPRITE for convenience.
|
|---|
| 315 | Reads 1,4 and 8 bit sprites.
|
|---|
| 316 | 'First bit' value in header must be a multiple of 8 (v.likely).
|
|---|
| 317 | Will only read image plane, will ignore any mask plane.
|
|---|
| 318 | Will handle case when no palette present in file.
|
|---|
| 319 | Will default to the default Wimp palette in this case.
|
|---|
| 320 | If input contains more than one sprite then which can be specified.
|
|---|
| 321 | Input options: index=# (default: 0)
|
|---|
| 322 | Will output 1,4 and 8 bit files.
|
|---|
| 323 | Will write a palette in the file.
|
|---|
| 324 | Will only write an image plane, ie: no mask plane.
|
|---|
| 325 | Will write a 16 entry palette for 8 bit data (not 64 entry).
|
|---|
| 326 | Will map to wierd archmedes palette when writing 8 bit data.
|
|---|
| 327 | Tested reading 4bpp sprites with no palette.
|
|---|
| 328 | Tested reading 8bpp sprites with no palette and with 64 entry palette.
|
|---|
| 329 | Sprites generated by GBM have been loaded on RiscOS.
|
|---|
| 330 | Remember: Use SetType to change type of file from PC-file to Sprite,
|
|---|
| 331 | by SetType option of filer menu or "*SetType <filename> Sprite".
|
|---|
| 332 | </PRE>
|
|---|
| 333 | <PRE>
|
|---|
| 334 | PSEG : IBM Printer Page Segment : .PSE .PSEG .PSEG38PP .PSEG3820
|
|---|
| 335 | This is a file format used by IBM document/printing systems.
|
|---|
| 336 | It is used to represent a bi-level image to be used in a document.
|
|---|
| 337 | Reads data and presents a 1bpp bitmap.
|
|---|
| 338 | Image is presented 1's as black on 0's as white background.
|
|---|
| 339 | PSEG files should be downloaded from a VM host in binary mode.
|
|---|
| 340 | Some PSEG files have a corrupt record structure.
|
|---|
| 341 | This doesn't cause a problem on VM but can confuse a non-VM reader.
|
|---|
| 342 | GBM can be made to attempt to handle these files.
|
|---|
| 343 | Input option: fixrec
|
|---|
| 344 | Will output 1bpp file.
|
|---|
| 345 | Will output file with scale factor of 1000
|
|---|
| 346 | Can specify new scale for both x and y
|
|---|
| 347 | Output options: scalex=#, scaley=#
|
|---|
| 348 | Can double the scale factors (option exists for backwards compatibility).
|
|---|
| 349 | Output option: double
|
|---|
| 350 | WIll output file with pel values of 2400 (dots per 10 inches, ie: 240 dpi).
|
|---|
| 351 | Can specify new pel values for both x and y
|
|---|
| 352 | Output options: pelx=#, pely=#
|
|---|
| 353 | Palette in 1bpp data is lost when written to file.
|
|---|
| 354 | The resulting non-VM file has no record structure.
|
|---|
| 355 | So when it is uploaded it must be fixed using FIXL3820 EXEC or similar.
|
|---|
| 356 | Image width is rounded up to next multiple of 8 when written.
|
|---|
| 357 | </PRE>
|
|---|
| 358 | <PRE>
|
|---|
| 359 | GemRas : GEM Raster : .IMG
|
|---|
| 360 | There is a basic level of support, and assorted XIMG extensions.
|
|---|
| 361 | One extension is the inclusion of palette info.
|
|---|
| 362 | Another allows 24 bpp data to be placed into an .IMG file.
|
|---|
| 363 | Reads 1 bpp files (which are B/W) and returns 1 bpp data.
|
|---|
| 364 | Reads 2,3 and 4 bpp files (col, grey, XIMG with pal) and returns 4 bpp.
|
|---|
| 365 | Reads 5,6,7 and 8 bpp files (grey, XIMG with pal) and returns 8 bpp.
|
|---|
| 366 | Reads 24 bpp (which are by definition XIMG) files and returns 24 bpp.
|
|---|
| 367 | Writes 1 bpp data as B/W 1 bpp file.
|
|---|
| 368 | Writes 4 bpp data mapped to 'standard' 16 colour palette.
|
|---|
| 369 | Or writes 4 bpp data greyscale 4 bpp file.
|
|---|
| 370 | Output option: grey
|
|---|
| 371 | Or writes 4 bpp data to XIMG file with palette.
|
|---|
| 372 | Output option: pal
|
|---|
| 373 | There is no 'standard' palette for 256 colour files.
|
|---|
| 374 | Writes 8 bpp data as greyscale 8 bpp file.
|
|---|
| 375 | Or writes 8 bpp to XIMG file with palette.
|
|---|
| 376 | Output option: pal
|
|---|
| 377 | Writes 24 bpp data as an XIMG file (normal file can't do 24 bpp).
|
|---|
| 378 | The pixel dimensions in microns can be specified.
|
|---|
| 379 | Output options: pixw=#,pixh=# (defaults: 85,85)
|
|---|
| 380 | </PRE>
|
|---|
| 381 | <PRE>
|
|---|
| 382 | Portrait : Portrait : .CVP
|
|---|
| 383 | In Germany, photographers sometimes supply a floppy with a .CVP on it.
|
|---|
| 384 | File holds a single 512x512 24bpp RGB image.
|
|---|
| 385 | File is uncompressed, and will therefore always be 3/4Mb.
|
|---|
| 386 | You can only write 512x512 images using this format.
|
|---|
| 387 | Pixels in the file are not square, the width is approx. 3/4 the height.
|
|---|
| 388 | This aspect ratio problem is not adjusted for when reading or writing.
|
|---|
| 389 | </PRE>
|
|---|
| 390 | <PRE>
|
|---|
| 391 | JPEG : JPEG File Interchange Format : .JPG .JPEG .JPE
|
|---|
| 392 | Can read 8 bpp (greyscale) and 24 bpp files.
|
|---|
| 393 | Can write 24 bpp data to a file.
|
|---|
| 394 | Can write with varying degrees of quality.
|
|---|
| 395 | Output option: quality=# (range 0 to 100, default 75)
|
|---|
| 396 | Can write progressive JPEGs.
|
|---|
| 397 | Output option: prog
|
|---|
| 398 | </PRE>
|
|---|
| 399 | <!--...e-->
|
|---|
| 400 | <!--...sCommand line programs:0:-->
|
|---|
| 401 | <A NAME="cmdline">
|
|---|
| 402 | <H2>Command line programs</H2></A>
|
|---|
| 403 |
|
|---|
| 404 | <P>All the command line programs are written in portable C, and therefore
|
|---|
| 405 | can be compiled up on a wide variety of platforms.
|
|---|
| 406 |
|
|---|
| 407 | <!--...sGBMHDR \45\ Display header information from bitmap files:0:-->
|
|---|
| 408 | <A NAME="gbmhdr">
|
|---|
| 409 | <H3>GBMHDR - Display header information from bitmap files</H3></A>
|
|---|
| 410 |
|
|---|
| 411 | <P>
|
|---|
| 412 | <PRE>
|
|---|
| 413 | usage: gbmhdr [-g] [-s] [--] {fn.ext{,opt}}
|
|---|
| 414 | flags: -g don't guess bitmap format, try each type
|
|---|
| 415 | -s be silent about errors
|
|---|
| 416 | fn.ext{,opt} input filenames (with any format specific options)
|
|---|
| 417 | Bitmap when ext in [BMP VGA BGA RLE DIB RL4 RL8]
|
|---|
| 418 | GIF when ext in [GIF]
|
|---|
| 419 | PCX when ext in [PCX]
|
|---|
| 420 | TIFF when ext in [TIF]
|
|---|
| 421 | Targa when ext in [TGA VST AFI]
|
|---|
| 422 | ILBM when ext in [IFF LBM]
|
|---|
| 423 | YUV12C when ext in [VID]
|
|---|
| 424 | Greymap when ext in [PGM]
|
|---|
| 425 | Pixmap when ext in [PPM]
|
|---|
| 426 | KIPS when ext in [KPS]
|
|---|
| 427 | IAX when ext in [IAX]
|
|---|
| 428 | XBitmap when ext in [XBM]
|
|---|
| 429 | Sprite when ext in [SPR]
|
|---|
| 430 | GemRas when ext in [IMG]
|
|---|
| 431 | Portrait when ext in [CVP]
|
|---|
| 432 | JPEG when ext in [JPG JPEG JPE]
|
|---|
| 433 | opt bitmap format specific option to pass to bitmap reader
|
|---|
| 434 | </PRE>
|
|---|
| 435 |
|
|---|
| 436 | <P>Note that the GBM module only ever surfaces the size and bits per pixel
|
|---|
| 437 | of images (regardless of the other information present in the header).
|
|---|
| 438 | All GBM programs have access to the bitmap file formats documented
|
|---|
| 439 | above, although this list is omitted in subsequent documentation.
|
|---|
| 440 |
|
|---|
| 441 | <P>GBMHDR displays output in the following style :-
|
|---|
| 442 |
|
|---|
| 443 | <P>
|
|---|
| 444 | <PRE>
|
|---|
| 445 | 384x768 8bpp 51Kb 17% GIF aab.gif
|
|---|
| 446 | 227x254 8bpp 58Kb 102% Bitmap andy.bmp
|
|---|
| 447 | 256x256 24bpp 84Kb 43% TIFF bardot.tif
|
|---|
| 448 | </PRE>
|
|---|
| 449 |
|
|---|
| 450 | <P>Listed is the size, bits per pixel, Kb size of the file, a percentage
|
|---|
| 451 | value, the file format, and the file name.
|
|---|
| 452 | The percentage is calculated as (filesize*100/datasize) and effectively gives
|
|---|
| 453 | the compression ratio.
|
|---|
| 454 | For example <CODE>aab.gif</CODE> is well compressed (to 17% of the theoretical
|
|---|
| 455 | size).
|
|---|
| 456 | <CODE>andy.bmp</CODE> gives a >100% value because of the file header.
|
|---|
| 457 | <!--...e-->
|
|---|
| 458 | <!--...sGBMREF \45\ Reflect in horizontal and\47\or vertical directions:0:-->
|
|---|
| 459 | <A NAME="gbmref">
|
|---|
| 460 | <H3>GBMREF - Reflect in horizontal and/or vertical directions</H3></A>
|
|---|
| 461 |
|
|---|
| 462 | <P>
|
|---|
| 463 | <PRE>
|
|---|
| 464 | usage: gbmref [-h] [-v] [-t] [--] fn1.ext{,opt} [fn2.ext{,opt}]
|
|---|
| 465 | flags: -h reflect horizontally
|
|---|
| 466 | -v reflect vertically
|
|---|
| 467 | -t transpose x for y
|
|---|
| 468 | fn1.ext{,opt} input filename (with any format specific options)
|
|---|
| 469 | fn2.ext{,opt} optional output filename (or will use fn1 if not present)
|
|---|
| 470 | bitmap formats and options as before
|
|---|
| 471 | </PRE>
|
|---|
| 472 |
|
|---|
| 473 | <P>Certain non-obvious combinations of <CODE>-h</CODE>, <CODE>-v</CODE>
|
|---|
| 474 | and <CODE>-t</CODE> can be very handy :-
|
|---|
| 475 |
|
|---|
| 476 | <DL>
|
|---|
| 477 | <DT>None of them
|
|---|
| 478 | <DD>can be used for just file format translation.
|
|---|
| 479 | <DT><CODE>-h -v</CODE>
|
|---|
| 480 | <DD>reflect both, equivelent to 180 degree turn.
|
|---|
| 481 | <DT><CODE>-h -t</CODE>
|
|---|
| 482 | <DD>equivelent to 90 degree turn clockwise.
|
|---|
| 483 | <DT><CODE>-v -t</CODE>
|
|---|
| 484 | <DD>equivelent to 90 degree turn anti-clockwise.
|
|---|
| 485 | </DL>
|
|---|
| 486 | <!--...e-->
|
|---|
| 487 | <!--...sGBMSUB \45\ Extract a subrectangle of a bitmap:0:-->
|
|---|
| 488 | <A NAME="gbmsub">
|
|---|
| 489 | <H3>GBMSUB - Extract a subrectangle of a bitmap</H3></A>
|
|---|
| 490 |
|
|---|
| 491 | <P>
|
|---|
| 492 | <PRE>
|
|---|
| 493 | usage: gbmsub [-x x] [-y y] [-w w] [-h h] [--] fn1.ext{,opt} [fn2.ext{,opt}]
|
|---|
| 494 | flags: -x x left edge of rectangle (default 0)
|
|---|
| 495 | -y y bottom edge of rectangle (default 0)
|
|---|
| 496 | -w w width of rectangle (default width of image - x)
|
|---|
| 497 | -h h height of rectangle (default height of image - y)
|
|---|
| 498 | fn1.ext{,opt} input filename (with any format specific options)
|
|---|
| 499 | fn2.ext{,opt} optional output filename (or will use fn1 if not present)
|
|---|
| 500 | bitmap formats and options as before
|
|---|
| 501 | </PRE>
|
|---|
| 502 |
|
|---|
| 503 | <P>If none of the <CODE>-x</CODE>, <CODE>-y</CODE>, <CODE>-w</CODE> and
|
|---|
| 504 | <CODE>-h</CODE> options are supplied the defaults cover the whole of the
|
|---|
| 505 | input file.
|
|---|
| 506 | Hence this program will just read one file and write the data as another.
|
|---|
| 507 | Great for format conversion.
|
|---|
| 508 | <!--...e-->
|
|---|
| 509 | <!--...sGBMSIZE \45\ Change the size of a bitmap:0:-->
|
|---|
| 510 | <A NAME="gbmsize">
|
|---|
| 511 | <H3>GBMSIZE - Change the size of a bitmap</H3></A>
|
|---|
| 512 |
|
|---|
| 513 | <P>
|
|---|
| 514 | <PRE>
|
|---|
| 515 | usage: gbmsize [-w w] [-h h] [-a] [--] fn1.ext{,opt} [fn2.ext{,opt}]
|
|---|
| 516 | flags: -w w new width of bitmap (default width of bitmap)
|
|---|
| 517 | -h h new height of bitmap (default height of bitmap)
|
|---|
| 518 | -a preserve aspect ratio when only one of -w or -h given
|
|---|
| 519 | fn1.ext{,opt} input filename (with any format specific options)
|
|---|
| 520 | fn2.ext{,opt} optional output filename (or will use fn1 if not present)
|
|---|
| 521 | bitmap formats and options as before
|
|---|
| 522 | </PRE>
|
|---|
| 523 |
|
|---|
| 524 | <P>If none of the <CODE>-w</CODE> or <CODE>-h</CODE> options are supplied,
|
|---|
| 525 | the defaults will be the input image size.
|
|---|
| 526 | Hence this program will just read one file and write the data as another.
|
|---|
| 527 | Great for format conversion.
|
|---|
| 528 |
|
|---|
| 529 | <P>The scaling algorithm simply uses pixel skipping and/or replication.
|
|---|
| 530 | <!--...e-->
|
|---|
| 531 | <!--...sGBMBPP \45\ Do various bits per pixel conversions:0:-->
|
|---|
| 532 | <A NAME="gbmbpp">
|
|---|
| 533 | <H3>GBMBPP - Do various bits per pixel conversions</H3></A>
|
|---|
| 534 |
|
|---|
| 535 | <P>
|
|---|
| 536 | <PRE>
|
|---|
| 537 | usage: gbmbpp [-m map] [-e] [-hN] [-p fnp.ext{,opt}]
|
|---|
| 538 | [--] fn1.ext{,opt} [fn2.ext{,opt}]
|
|---|
| 539 | flags: -m map mapping to perform (default 7x8x4)
|
|---|
| 540 | bw black and white
|
|---|
| 541 | vga 16 colour VGA
|
|---|
| 542 | 8 8 colour (in 4 bit file)
|
|---|
| 543 | 4g 4 bit greyscale
|
|---|
| 544 | 7x8x4 7 levels red, 8 green, 4 blue 8514/A
|
|---|
| 545 | 6x6x6 6 levels red, 6 green, 6 blue
|
|---|
| 546 | 8g 8 bit greyscale
|
|---|
| 547 | tripel 64 reds, 64 greens, 64 blues tripel
|
|---|
| 548 | pal1bpp map to 1bpp, palette specified via -p
|
|---|
| 549 | pal4bpp map to 4bpp, palette specified via -p
|
|---|
| 550 | pal8bpp map to 8bpp, palette specified via -p
|
|---|
| 551 | freqR:G:B:N keep R red, G green, b blue bits, and map
|
|---|
| 552 | to N most used colours in 8 bit palette
|
|---|
| 553 | mcutN median cut to N colours
|
|---|
| 554 | R:G:B keep R red, G green, B blue bits
|
|---|
| 555 | -e enable error-diffusion (default is to truncate)
|
|---|
| 556 | -e only with -m bw, vga, 4g, 7x8x4, 6x6x6, no -h
|
|---|
| 557 | -h enable halftoning (default is to truncate)
|
|---|
| 558 | -h only with -m 7x8x4, 6x6x6, 8, vga or R:G:B, no -e
|
|---|
| 559 | N is a halftoning algorithm number (default 0)
|
|---|
| 560 | -p fnp.ext{,opt} palette is taken from this bitmap
|
|---|
| 561 | fn1.ext{,opt} input filename (with any format specific options)
|
|---|
| 562 | fn2.ext{,opt} optional output filename (or use fn1 if not present)
|
|---|
| 563 | bitmap formats and options as before
|
|---|
| 564 | </PRE>
|
|---|
| 565 |
|
|---|
| 566 | <P>This program reads the input bitmap.
|
|---|
| 567 | If it is not 24 bit, then it is expanded to 24 bit per pixel.
|
|---|
| 568 | The data is then processed using the supplied mapping giving a 24,8,4 or 1 bit
|
|---|
| 569 | per pixel image, which is then written to the output bitmap file.
|
|---|
| 570 |
|
|---|
| 571 | <P>The <CODE>bw</CODE> mapping produces a 1 bpp output file,
|
|---|
| 572 | <CODE>vga</CODE> and <CODE>4g</CODE> gives 4 bit output files,
|
|---|
| 573 | <CODE>7x8x4</CODE>, <CODE>6x6x6</CODE>, <CODE>8g</CODE>, <CODE>freq</CODE>
|
|---|
| 574 | and <CODE>tripel</CODE> give 8 bit output files.
|
|---|
| 575 | <CODE>R:G:B</CODE> (where R,G and B are numbers in the range 0 to 8),
|
|---|
| 576 | gives a 24 bit output file where only the top R bits of red are non-zero,
|
|---|
| 577 | the top G of green and B of blue.
|
|---|
| 578 |
|
|---|
| 579 | <P>The normal way to map is simply to map each colour in the source
|
|---|
| 580 | bitmap to the closest one in the destination bitmap.
|
|---|
| 581 | However if <CODE>-e</CODE> is supplied, error diffusion is used to get a
|
|---|
| 582 | smoother result.
|
|---|
| 583 | Also, if <CODE>-h</CODE> is supplied halftoning may be used instead.
|
|---|
| 584 | <CODE>-e</CODE> and <CODE>-h</CODE> are not valid together, and are only
|
|---|
| 585 | valid with certain mappings.
|
|---|
| 586 | <!--...e-->
|
|---|
| 587 | <!--...sGBMGAMMA \45\ Convert between various colour spaces:0:-->
|
|---|
| 588 | <A NAME="gbmgamma">
|
|---|
| 589 | <H3>GBMGAMMA - Convert between various colour spaces</H3></A>
|
|---|
| 590 |
|
|---|
| 591 | <P>
|
|---|
| 592 | <PRE>
|
|---|
| 593 | usage: gbmgamma [-m map] [-g gamma] [-s shelf] [--] fn1.ext{,opt} [fn2.ext{,opt}]
|
|---|
| 594 | flags: -m map mapping in the form ?_to_? (default: i_to_l), where ? is
|
|---|
| 595 | i physical intensitys (eg: raytracer output)
|
|---|
| 596 | p gamma corrected for a specific monitor
|
|---|
| 597 | l L* cyclometric linear perceived intensitys (as in PM)
|
|---|
| 598 | -g gamma set monitor gamma (default 2.1)
|
|---|
| 599 | -s shelf set monitor shelf (default 0.0)
|
|---|
| 600 | gamma and shelf only used for mapping to or from p
|
|---|
| 601 | for 8514 monitor gamma=2.3,shelf=0.136
|
|---|
| 602 | for 8515 monitor gamma=2.1,shelf=0.0
|
|---|
| 603 | fn1.ext{,opt} input filename (with any format specific options)
|
|---|
| 604 | fn2.ext{,opt} optional output filename (or will use fn1 if not present)
|
|---|
| 605 | bitmap formats and options as before
|
|---|
| 606 | </PRE>
|
|---|
| 607 |
|
|---|
| 608 | <P>This program reads a bitmap and assumes the pixel values in it are
|
|---|
| 609 | in the input colour space.
|
|---|
| 610 |
|
|---|
| 611 | <P>If the bitmap has a palette it maps each palette entry according to the
|
|---|
| 612 | supplied mapping, otherwise it maps each individual 24 bit pixel.
|
|---|
| 613 |
|
|---|
| 614 | <P>For example, if you get a 24 bit per pixel image from a Windows video
|
|---|
| 615 | capture program, the odds are in may be in a gamma corrected colour space
|
|---|
| 616 | with a gamma of 2.2.
|
|---|
| 617 | You can convert this to the L* cyclometric colour space used by PM by typing :-
|
|---|
| 618 |
|
|---|
| 619 | <P>
|
|---|
| 620 | <PRE>
|
|---|
| 621 | gbmgamma -m p_to_l -g 2.2 captured.bmp nicepm.bmp
|
|---|
| 622 | </PRE>
|
|---|
| 623 |
|
|---|
| 624 | <P>The shelf option is primarily for when converting to a gamma corrected
|
|---|
| 625 | colour space for a specific monitor (when you aren't going to use PM to
|
|---|
| 626 | display the bitmap, and the display program doesn't do any correction).
|
|---|
| 627 | Some monitors don't actually start to light up pixels until the pixel
|
|---|
| 628 | values are a certain value.
|
|---|
| 629 | Normally <CODE>-s shelf</CODE> will not be used.
|
|---|
| 630 | <!--...e-->
|
|---|
| 631 | <!--...sGBMCPAL \45\ Map to Common Palette:0:-->
|
|---|
| 632 | <A NAME="gbmcpal">
|
|---|
| 633 | <H3>GBMCPAL - Map to Common Palette</H3></A>
|
|---|
| 634 |
|
|---|
| 635 | <P>
|
|---|
| 636 | <PRE>
|
|---|
| 637 | usage: gbmcpal [-m map] [-v] n1 n2 n3 ifspec{,opt} ofspec{,opt}
|
|---|
| 638 | flags: -m map mapping to perform (default freq6:6:6:256)
|
|---|
| 639 | freqR:G:B:N map all bitmaps to same palette, worked
|
|---|
| 640 | out using frequency of use histogram
|
|---|
| 641 | mcutN map all bitmaps to same palette, worked
|
|---|
| 642 | out using median cut algorithm
|
|---|
| 643 | rofreqR:G:B:N:N2 map each bitmap to frequency palette,
|
|---|
| 644 | reordered to minimise differences
|
|---|
| 645 | between successive bitmaps
|
|---|
| 646 | romcutN:N2 map each bitmap to median cut palette,
|
|---|
| 647 | reordered to minimise differences
|
|---|
| 648 | between successive bitmaps
|
|---|
| 649 | R,G,B are bits of red, green and blue
|
|---|
| 650 | to keep, N is number of unique colours,
|
|---|
| 651 | N2 is extra palette entries
|
|---|
| 652 | -v verbose mode
|
|---|
| 653 | n1 n2 n3 for ( f=n1; f<n2; f+=n3 )
|
|---|
| 654 | ifspec printf(ifspec, f);
|
|---|
| 655 | ofspec printf(ofspec, f);
|
|---|
| 656 | filespecs are of the form fn.ext
|
|---|
| 657 | ext's are used to deduce desired bitmap file formats
|
|---|
| 658 | bitmap formats and options as before
|
|---|
| 659 | </PRE>
|
|---|
| 660 |
|
|---|
| 661 | <P>Given a set of bitmaps, it is possible to examine them all and compute
|
|---|
| 662 | a common palette for holding them, and then generate new bitmaps
|
|---|
| 663 | mapped to that palette.
|
|---|
| 664 |
|
|---|
| 665 | <P>The mappings available are frequency based and median-cut based.
|
|---|
| 666 |
|
|---|
| 667 | <P>Alternatively, it is possible to generate the most suitable palette
|
|---|
| 668 | for each frame, and then reorder the palettes of each bitmap so as to
|
|---|
| 669 | be as close as possible to its predecessor.
|
|---|
| 670 |
|
|---|
| 671 | <P>By reordering palettes (using <CODE>rofreq</CODE>/<CODE>romcut</CODE>)
|
|---|
| 672 | it is possible to remove almost all flicker on playback.
|
|---|
| 673 | From frame to frame, almost all palette entries in a given frame, have
|
|---|
| 674 | close entries in the previous frame.
|
|---|
| 675 |
|
|---|
| 676 | <P>However for a few, this is not true, and flicker may be seen.
|
|---|
| 677 | The <CODE>N2</CODE> parameter is designed to alleviate this.
|
|---|
| 678 | The process will handle the <CODE>N2</CODE> worst palette changes using
|
|---|
| 679 | <CODE>N2</CODE> extra palette entries.
|
|---|
| 680 | Thus the <CODE>N2</CODE> worst causes of flicker can be eliminated.
|
|---|
| 681 | A typical use might be :-
|
|---|
| 682 |
|
|---|
| 683 | <P>
|
|---|
| 684 | <PRE>
|
|---|
| 685 | gbmcpal -m romcut240:16 0 100 1 in%02d.bmp out%02d.bmp
|
|---|
| 686 | </PRE>
|
|---|
| 687 |
|
|---|
| 688 | <P>This means map each frame to a palette with 240 unique colours in.
|
|---|
| 689 | Any given frame only uses 240 colours at most.
|
|---|
| 690 | But the palette is actually 240+16 colours in length, and the additional
|
|---|
| 691 | 16 are used to eliminate flicker caused by the 16 worst matches.
|
|---|
| 692 | <!--...e-->
|
|---|
| 693 | <!--...e-->
|
|---|
| 694 | <!--...sColour spaces:0:-->
|
|---|
| 695 | <A NAME="colspace">
|
|---|
| 696 | <H2>Colour spaces</H2></A>
|
|---|
| 697 |
|
|---|
| 698 | <P>If a light is physically twice as bright, the eye does not necessarily see
|
|---|
| 699 | it as twice as bright.
|
|---|
| 700 | Also, if a pixel is written onto a monitor screen with twice the value,
|
|---|
| 701 | the physical intensity of the pixel is not necessarily double.
|
|---|
| 702 |
|
|---|
| 703 | <P>How exactly should numbers inside a bitmap file relate to physical or
|
|---|
| 704 | perceived intensitys when displayed on the screen?
|
|---|
| 705 |
|
|---|
| 706 | <P>In OS/2 PM perceived intensitys are proportional to the values in the bitmap
|
|---|
| 707 | file.
|
|---|
| 708 | Pixels in such a bitmap are in the 'L* cyclometric' colour space.
|
|---|
| 709 |
|
|---|
| 710 | <P>Ray Tracers often write pixel values in the bitmap proportional to the
|
|---|
| 711 | physical intensity computed for that ray.
|
|---|
| 712 | Such data is in the 'intensity' colour space.
|
|---|
| 713 |
|
|---|
| 714 | <P>Finally, if a bitmap holds values computed in such a way as to
|
|---|
| 715 | compensate for the gamma of the monitor (ie: intensitys transformed to
|
|---|
| 716 | cancel out the gamma of the monitor), then the data is in
|
|---|
| 717 | a 'gamma corrected' colour space.
|
|---|
| 718 |
|
|---|
| 719 | <P>So, if you have some Ray Tracer output, and you wish to display on an 8514
|
|---|
| 720 | monitor WITHOUT using OS/2 PM, then to get a decent colour rendition, you must
|
|---|
| 721 | map the bitmap from the 'intensity' to a 'gamma corrected' colour space.
|
|---|
| 722 | To do this you must know the gamma of the 8514 monitor (which is about 2.1).
|
|---|
| 723 |
|
|---|
| 724 | <P>Also, if you have some Ray Tracer output, and you wish to display on
|
|---|
| 725 | OS/2 PM, then to get a decent rendition you must map the bitmap from
|
|---|
| 726 | the 'intensity' to the 'L* cyclometric' colour space.
|
|---|
| 727 |
|
|---|
| 728 | <P><A HREF="#gbmgamma">GBMGAMMA</A> is a colour mapping program capable
|
|---|
| 729 | of performing mappings between any 2 of the 3 colour spaces above.
|
|---|
| 730 |
|
|---|
| 731 | <P>Mapping of this sort should really be done on 24 bit data, before
|
|---|
| 732 | error-diffusion or halftoning takes place.
|
|---|
| 733 | <!--...e-->
|
|---|
| 734 | <!--...sMaking bitmap animations:0:-->
|
|---|
| 735 | <A NAME="anim">
|
|---|
| 736 | <H2>Making bitmap animations</H2>
|
|---|
| 737 |
|
|---|
| 738 | <P>GBM was originally written as the bitmap handling portion of my homebrew
|
|---|
| 739 | Ray Tracer, RT.
|
|---|
| 740 | RT was originally written to allow me to trace snazzy animations.
|
|---|
| 741 | For example, here is what I did to make a spinning globe animation.
|
|---|
| 742 |
|
|---|
| 743 | <P>First I traced a largish number of individual bitmap frames using RT.
|
|---|
| 744 | I wrote these out under the names <CODE>globeNNN.tif</CODE> where
|
|---|
| 745 | <CODE>NNN</CODE> is <CODE>000</CODE>, <CODE>010</CODE>, <CODE>020</CODE>,
|
|---|
| 746 | ... <CODE>350</CODE> (ie: the angle of rotation in degrees).
|
|---|
| 747 | I used the <CODE>,lzw</CODE> option to get the files
|
|---|
| 748 | written LZW encoded to reduce the disk space requirements.
|
|---|
| 749 |
|
|---|
| 750 | <P>Then to map the data to a common palette, I used
|
|---|
| 751 | <A HREF="#gbmcpal">GBMCPAL</A> :-
|
|---|
| 752 |
|
|---|
| 753 | <P>
|
|---|
| 754 | <PRE>
|
|---|
| 755 | gbmcpal -m freq6:6:6:256 0 360 10 globe%03d.tif globe%03d.bmp
|
|---|
| 756 | </PRE>
|
|---|
| 757 |
|
|---|
| 758 | <P>Obviously there are file formats specifically for holding animations, and
|
|---|
| 759 | algorithms for having animations where palette entries vary from frame to
|
|---|
| 760 | frame, but the simple example above is ok for many purposes.
|
|---|
| 761 | <!--...e-->
|
|---|
| 762 | <!--...sExamples of use:0:-->
|
|---|
| 763 | <A NAME="examples">
|
|---|
| 764 | <H2>Examples of use</H2></A>
|
|---|
| 765 |
|
|---|
| 766 | <P>
|
|---|
| 767 | <PRE>
|
|---|
| 768 | gbmhdr *.bmp *.tif
|
|---|
| 769 | Displays the headers of all the bitmaps and TIFF files
|
|---|
| 770 | </PRE>
|
|---|
| 771 | <PRE>
|
|---|
| 772 | gbmref file.bmp file.tga
|
|---|
| 773 | Perform no reflection (no -h, -v or -t).
|
|---|
| 774 | Hence simply converts file from Bitmap to Targa format!
|
|---|
| 775 | </PRE>
|
|---|
| 776 | <PRE>
|
|---|
| 777 | gbmref -h larrow.tga rarrow.tga
|
|---|
| 778 | Reflects larrow.tga to make rarrow.tga
|
|---|
| 779 | </PRE>
|
|---|
| 780 | <PRE>
|
|---|
| 781 | gbmref -h -t profit.gif loss.gif
|
|---|
| 782 | The combination of a horizontal flip with a transpose gives a 90
|
|---|
| 783 | degree rotation clockwise. Thus a graph going up from bottom left
|
|---|
| 784 | to top right, ends up going from top left to bottom right!
|
|---|
| 785 | </PRE>
|
|---|
| 786 | <PRE>
|
|---|
| 787 | gbmref -v uarrow.pcx "darrow.lbm,xaspect=5,yaspect=6,xscreen=320,yscreen=200"
|
|---|
| 788 | Reflects uarrow.pcx to make darrow.lbm
|
|---|
| 789 | Output options defined for ILBM files used to write to aspect ratio
|
|---|
| 790 | and screen size fields in output .lbm file.
|
|---|
| 791 | Note: some command processors (such as OS/2 CMD.EXE) will split command
|
|---|
| 792 | line arguments at spaces and commas, so we quote second argument.
|
|---|
| 793 | </PRE>
|
|---|
| 794 | <PRE>
|
|---|
| 795 | gbmsub -x 100 -y 50 page.bmp
|
|---|
| 796 | Trims 100 pixels off the left, and 50 off of the bottom
|
|---|
| 797 | Note: no second filename given, so output overwrites page.bmp
|
|---|
| 798 | </PRE>
|
|---|
| 799 | <PRE>
|
|---|
| 800 | gbmsize -w 1024 -h 768 strangesize.bmp screensized.bmp
|
|---|
| 801 | Takes any bitmap and scales it to a typical SVGA screen size.
|
|---|
| 802 | </PRE>
|
|---|
| 803 | <PRE>
|
|---|
| 804 | gbmbpp -m 7x8x4 24bit.tga 8bit.bpp
|
|---|
| 805 | Maps a 24 RGB image to the 8514/A PM palette
|
|---|
| 806 | Note: Source image format (Targa) not same as output format (Bitmap)
|
|---|
| 807 | </PRE>
|
|---|
| 808 | <PRE>
|
|---|
| 809 | gbmbpp -m 7x8x4 -h 24bit.bmp nice8bit.bmp
|
|---|
| 810 | As above but with halftoning
|
|---|
| 811 | </PRE>
|
|---|
| 812 | <PRE>
|
|---|
| 813 | gbmbpp -m 7x8x4 -e 24bit.bmp nice8bit.bmp
|
|---|
| 814 | As above, but with error diffusion
|
|---|
| 815 | </PRE>
|
|---|
| 816 | <PRE>
|
|---|
| 817 | gbmbpp -m vga -e 24bit.bmp nice4bit.bmp
|
|---|
| 818 | As above, but suitable for VGA display
|
|---|
| 819 | </PRE>
|
|---|
| 820 | <PRE>
|
|---|
| 821 | gbmbpp -m 5:5:5 -e 8r8g8b.tga "5r5g5b.tga,16"
|
|---|
| 822 | Error diffuse from 24 bit RGB to 15 bit RGB
|
|---|
| 823 | (bottom 3 bits of each of R,G and B become zero)
|
|---|
| 824 | Output option ",16" ensures data written in Targa-16 form
|
|---|
| 825 | This reduces wasted disk space.
|
|---|
| 826 | </PRE>
|
|---|
| 827 | <PRE>
|
|---|
| 828 | gbmbpp -m freq8:8:8:240 24bit.bmp 8bit.bmp
|
|---|
| 829 | Finds 240 most frequently used colours.
|
|---|
| 830 | For other colours finds closest match in most common 240 colours.
|
|---|
| 831 | Maps colours in 24bit.bmp to give 8 bit output file.
|
|---|
| 832 | If excessively large number of colours in original, may truncate bits.
|
|---|
| 833 | </PRE>
|
|---|
| 834 | <PRE>
|
|---|
| 835 | gbmgamma -m i_to_l raytrace.bmp pmsuited.bmp
|
|---|
| 836 | raytrace.bmp has pixels values proportional to physical intensity.
|
|---|
| 837 | pmsuited.bmp is made with pixels proportional to perceived intensity.
|
|---|
| 838 | </PRE>
|
|---|
| 839 | <PRE>
|
|---|
| 840 | gbmcpal -m freq6:6:6:256 0 360 10 globe%03d.bmp cpal%03d.bmp
|
|---|
| 841 | Read globe000.bmp, globe010.bmp, ... globe350.bmp.
|
|---|
| 842 | Compute a common shared palette.
|
|---|
| 843 | Map each globeXXX.bmp file to a cpalXXX.bmp file.
|
|---|
| 844 | </PRE>
|
|---|
| 845 | <!--...e-->
|
|---|
| 846 | <!--...sRelated code:0:-->
|
|---|
| 847 | <A NAME="related">
|
|---|
| 848 | <H2>Related code</H2></A>
|
|---|
| 849 |
|
|---|
| 850 | <P>GBM was originally written as the file handling part of my homebrew
|
|---|
| 851 | ray tracer, RT.
|
|---|
| 852 | This may be found via my home page too.
|
|---|
| 853 |
|
|---|
| 854 | <P>My follow-on Modular Renderer package, currently in development, uses GBM.
|
|---|
| 855 | It does wire-frame, polygon rendering and raytracing.
|
|---|
| 856 | Not currently publically available.
|
|---|
| 857 |
|
|---|
| 858 | <P>Martin Lisowski informs me he is working on something he calls GBMV3,
|
|---|
| 859 | which is like the OS/2 PM GBMV2 viewer, only with extra features.
|
|---|
| 860 | It is currently "far from being ready, and still has bugs".
|
|---|
| 861 |
|
|---|
| 862 | <P>From time to time I notice people (other than myself) using GBM either
|
|---|
| 863 | in its precompiled DLL form, or by recompiling bits of the source.
|
|---|
| 864 | Sometimes people email me to let me know.
|
|---|
| 865 |
|
|---|
| 866 | <P>Of course, simply using the code unmodified makes it easier for you
|
|---|
| 867 | to pick up improvements in the code, as and when they happen.
|
|---|
| 868 |
|
|---|
| 869 | <P>IBM WebExplorer uses the Bitmap, GIF and XBM handling parts of GBM to
|
|---|
| 870 | some degree - in <CODE>webexwin.dll</CODE>, around byte offset 86924 (in my
|
|---|
| 871 | copy) are a whole load of GBM error strings.
|
|---|
| 872 |
|
|---|
| 873 | <P>IBM VisualAge C++ 3.0 for OS/2 uses large wedges of GBM source code.
|
|---|
| 874 | I think they're using it in their supplied <CODE>class IGBitmap</CODE>.
|
|---|
| 875 | This is apparent from the object filenames listed in
|
|---|
| 876 | <CODE>\ibmcpp\iocdll\cppoou3.rsp</CODE>
|
|---|
| 877 | and the exported function names in
|
|---|
| 878 | <CODE>\ibmcpp\iocdll\cppoou3.def</CODE>.
|
|---|
| 879 |
|
|---|
| 880 | <P>The IBM Person to Person personal conferencing system for OS/2 used
|
|---|
| 881 | the PCX and TIFF parts of GBM, and I think the AIX variant used whole loads
|
|---|
| 882 | more.
|
|---|
| 883 |
|
|---|
| 884 | <P>BITMAP32, a bitmap viewer for OS/2 PM, uses GBM.DLL unmodified.
|
|---|
| 885 | Because the IBM Developer Connection shipped BITMAP32, they ship GBM too.
|
|---|
| 886 |
|
|---|
| 887 | <P>BluePaint, an OS/2 PM painting program, being developed for
|
|---|
| 888 | Shareware (I think) uses GBM.DLL unmodified.
|
|---|
| 889 | <!--...e-->
|
|---|
| 890 | <!--...sLegal stuff:0:-->
|
|---|
| 891 | <A NAME="legal">
|
|---|
| 892 | <H2>Legal stuff</H2></A>
|
|---|
| 893 |
|
|---|
| 894 | <!--...sPublic domain declaration:0:-->
|
|---|
| 895 | <H3>Public domain declaration</H3>
|
|---|
| 896 |
|
|---|
| 897 | <P>I wrote all this code in my own time on my own equiptment.
|
|---|
| 898 |
|
|---|
| 899 | <P>I used public non-confidential information to do so.
|
|---|
| 900 |
|
|---|
| 901 | <P>I hereby place all this code into the public domain.
|
|---|
| 902 |
|
|---|
| 903 | <P>Feel free to do whatever you like with it.
|
|---|
| 904 |
|
|---|
| 905 | <P>No copyright / no royalties / no guarantees / no problem.
|
|---|
| 906 |
|
|---|
| 907 | <P>Caveat Emptor!
|
|---|
| 908 |
|
|---|
| 909 | <P>Anyone offering ideas/code must be happy with the above.
|
|---|
| 910 |
|
|---|
| 911 | <P>The above does not apply to the JPEG support.
|
|---|
| 912 | <!--...e-->
|
|---|
| 913 | <!--...sJPEG support:0:-->
|
|---|
| 914 | <H3>JPEG support</H3>
|
|---|
| 915 |
|
|---|
| 916 | <P>This section is applicable if you are using GBM with JPEG support.
|
|---|
| 917 |
|
|---|
| 918 | <P>The Independent JPEG Group JPEGLIB version 6a may be used provided
|
|---|
| 919 | they are credited, (which I do so here).
|
|---|
| 920 |
|
|---|
| 921 | <P>This software is based in part on the work of the Independent JPEG Group.
|
|---|
| 922 |
|
|---|
| 923 | <P>Martin Lisowski has donated <CODE>gbmjpg.c</CODE> to GBM and it is just as
|
|---|
| 924 | public domain as the rest of GBM.
|
|---|
| 925 | <!--...e-->
|
|---|
| 926 | <!--...sCompu\36\erve GIF Tax:0:-->
|
|---|
| 927 | <H3>Compu$erve GIF Tax</H3>
|
|---|
| 928 |
|
|---|
| 929 | <P>Both Unisys and IBM (and others) have various patents pertaining to the LZW
|
|---|
| 930 | algorithm used in GIF and LZW compressed TIFF files.
|
|---|
| 931 |
|
|---|
| 932 | <P>For many years Unisys have only licensed their LZW technology in hardware
|
|---|
| 933 | implementations (typically Modems).
|
|---|
| 934 | Now Unisys (through Compu$erve) are looking to license the use of LZW
|
|---|
| 935 | in software applications, such as GIF and TIFF.
|
|---|
| 936 | This is the infamous 'Compu$erve GIF Tax'.
|
|---|
| 937 |
|
|---|
| 938 | <P>Unisys have stated (in news postings) that non-commercial
|
|---|
| 939 | software need not be licensed.
|
|---|
| 940 |
|
|---|
| 941 | <P>Assuming this to be true, GBM will continue to
|
|---|
| 942 | support GIF and LZW compressed TIFF.
|
|---|
| 943 |
|
|---|
| 944 | <P>It is anticipated that this move will mean
|
|---|
| 945 | the death of LZW in image files, and that the Net will develop a replacement
|
|---|
| 946 | based on LZSS, LZ77, LZHUF, Yabba or other (hopefully) non-patented technology.
|
|---|
| 947 | The emerging PNG format could be exactly that.
|
|---|
| 948 |
|
|---|
| 949 | <P>If and when this occurs, there is a good chance GBM will support it.
|
|---|
| 950 | <!--...e-->
|
|---|
| 951 | <!--...e-->
|
|---|
| 952 | <!--...sChange Log:0:-->
|
|---|
| 953 | <A NAME="change">
|
|---|
| 954 | <H2>Change Log</H2></A>
|
|---|
| 955 |
|
|---|
| 956 | <P>
|
|---|
| 957 | <PRE>
|
|---|
| 958 | 11/5/92 Initial general release.
|
|---|
| 959 |
|
|---|
| 960 | 29/11/93 Supplied to IBM OS/2 Developer Connection.
|
|---|
| 961 |
|
|---|
| 962 | 1/8/94 Submitted to Internet hobbes.nmsu.edu.
|
|---|
| 963 |
|
|---|
| 964 | 10/1/95 Added gbm_version(), better error checking, const's.
|
|---|
| 965 | Added clarification on LZW 'software patent'.
|
|---|
| 966 | Submitted to hobbes.nmsu.edu.
|
|---|
| 967 |
|
|---|
| 968 | 16/1/95 Added support for Portrait files (.CVP files).
|
|---|
| 969 |
|
|---|
| 970 | 21/3/95 Fixed palettes in XIMG GemRas files (thanks Eero).
|
|---|
| 971 | Fixed GIF writing transcol=edge, & reading local colour tables.
|
|---|
| 972 | Added GBMLOGO.EXE to ease use of MAKELOGO.EXE on DevCon CD 6.
|
|---|
| 973 |
|
|---|
| 974 | 16/5/95 Distribution now uses InfoZIP ZIP.EXE, not PKZIP.EXE 2.04g.
|
|---|
| 975 | Added Product Information dialog box to GBMV2.EXE.
|
|---|
| 976 | Fixed GBMLOGO.EXE error message trap for non 640x400 bitmaps.
|
|---|
| 977 |
|
|---|
| 978 | 25/3/96 Improved Bitmap reader to tolerate bad #colours in header.
|
|---|
| 979 | Fixed reading XBitmaps with digits in their identifiers.
|
|---|
| 980 | Added support for ilace flag on GIF output.
|
|---|
| 981 |
|
|---|
| 982 | 1/4/96 Fixed reading XBitmaps with other chars in their identifiers.
|
|---|
| 983 | Fixed interlaced GIF support.
|
|---|
| 984 | Added Win32 makefile and compilability.
|
|---|
| 985 | Added ability to cause GBM.DLL to use user defined I/O funcs.
|
|---|
| 986 | Added accessibility of I/O funcs used by GBM.
|
|---|
| 987 |
|
|---|
| 988 | 16/4/96 Applied fixes found by Wonkoo in 1/4/96 release.
|
|---|
| 989 | Increase warning levels for OS/2 compile and cleaned up source.
|
|---|
| 990 | Added /Os- to work around C-Set++ bug.
|
|---|
| 991 |
|
|---|
| 992 | 29/4/96 Applied fix to GIF/TIFF readers found by David Wendt.
|
|---|
| 993 |
|
|---|
| 994 | 19/6/96 Applied fixes found by Ralf and Andreas.
|
|---|
| 995 | Fixed RLE4 Bitmap decoder (thanks for Marc for bug report).
|
|---|
| 996 |
|
|---|
| 997 | 28/10/96 Changed over from IBM C-Set++ to IBM VisualAge C++ with CTC305.
|
|---|
| 998 | Fixed 16bpp display bug in GBMV2.EXE.
|
|---|
| 999 |
|
|---|
| 1000 | 18/11/96 Added darkfg option on 1bpp BMP writing.
|
|---|
| 1001 | Fixed printout of 1bpp bitmaps problem.
|
|---|
| 1002 |
|
|---|
| 1003 | 1/2/97 Changed colour->greyscale coefficients, as Wonkoo suggested.
|
|---|
| 1004 | Added JPEG support.
|
|---|
| 1005 | Changed documentation to HTML.
|
|---|
| 1006 | Submitted to Internet hobbes.nmsu.edu.
|
|---|
| 1007 |
|
|---|
| 1008 | 1/5/98 Added initial Linux port.
|
|---|
| 1009 | Support GIF files without EOI code in compressed data.
|
|---|
| 1010 | Included source for OS/2 PM Scroller control.
|
|---|
| 1011 |
|
|---|
| 1012 | 12/7/98 Fixed writing 1bpp PCXs with reverse palettes (ta Wonkoo).
|
|---|
| 1013 | Fixed OS/2 c0000005 Trap by increasing stack size (ta Gunter).
|
|---|
| 1014 |
|
|---|
| 1015 | 1/1/99 Added OS/2 _System Gbm_ entrypoints.
|
|---|
| 1016 | Added support for filenames starting with -, via -- convention.
|
|---|
| 1017 | Initial port to 32 bit DOS, via Watcom C/C++ and CauseWay.
|
|---|
| 1018 |
|
|---|
| 1019 | 20/1/99 Fixed reading of .pgm palettes (ta Wonkoo Kim).
|
|---|
| 1020 | Fixed 2 low probability bugs in LZW encoders in GIF and TIFF.
|
|---|
| 1021 |
|
|---|
| 1022 | ?/?/99 Change to gbmpgm.c and gbmppm.c to use \n in header.
|
|---|
| 1023 | Splitting out of OS/2 specific stuff to seperate package.
|
|---|
| 1024 | Fixed 32 bit DOS port to work properly with JPEG support.
|
|---|
| 1025 |
|
|---|
| 1026 | 21/11/99 Fixed reading OS/2 bitmaps with < 2**N colours.
|
|---|
| 1027 |
|
|---|
| 1028 | 04/01/2000 Fixed reading of 24 bit GemRas image files.
|
|---|
| 1029 |
|
|---|
| 1030 | 12/05/2000 Improved TIFF and GIF LZW readers corrupt data detection.
|
|---|
| 1031 | Improved TIFF LZW decompressor to work if EOI missing (ta Doug).
|
|---|
| 1032 |
|
|---|
| 1033 | 31/12/2000 A few minor tweaks to make source more friendly to Mac compiler.
|
|---|
| 1034 | Basically factored in Karl Timmermann suggestions, fixed a few
|
|---|
| 1035 | minor signed/unsigned char problems, and removed some #includes.
|
|---|
| 1036 |
|
|---|
| 1037 | 05/02/2001 gbmsize -a option, Jeroen Mosterts idea.
|
|---|
| 1038 |
|
|---|
| 1039 | 12/02/2001 gbmbpp -c palNbpp options to map to user defined palette.
|
|---|
| 1040 |
|
|---|
| 1041 | Future? Palette Manager capability in GBMV.EXE and GBMV2.EXE?
|
|---|
| 1042 | Non-scaled and fixed scale print for GBMV2.EXE?
|
|---|
| 1043 | Special logic for print to 1bpp and 3bpp printers for GBMV2.EXE?
|
|---|
| 1044 | Photo-CD, RLE-Bitmap, G3-TIFF, G3-Bitmap for GBM.DLL?
|
|---|
| 1045 | My free time is scarce - don't hold your breath!
|
|---|
| 1046 | </PRE>
|
|---|
| 1047 | <!--...e-->
|
|---|
| 1048 | <!--...sAuthor:0:-->
|
|---|
| 1049 | <HR>
|
|---|
| 1050 | This documentation is written and maintained by the GBM author, Andy Key
|
|---|
| 1051 | <ADDRESS>nyangau@interalpha.co.uk</ADDRESS>
|
|---|
| 1052 | <!--...e-->
|
|---|
| 1053 |
|
|---|
| 1054 | </BODY>
|
|---|
| 1055 | </HTML>
|
|---|