# GBM - Introduction

## Overview

The Generalised Bitmap Module (GBM) is a library capable of loading and saving bitmap files in a variety of popular bitmap file formats. Programs may be written to use this code, and thus be able to access a variety of file formats without actually knowing what format the pictures are in, or any details about file format itself.

Additionally the GBM package contains of a number of other components:

- Some pieces of code that perform common operations on bitmap data such as reflection, X-Y transposition, rotation, cropping, scaling, halftoning, error-diffusing, palette mapping, and colour space mapping. These operations are available as ready to use C libraries.
- Some command line programs which use the above code.
- REXX libraries for loading and saving bitmap formats, scaling, reflecting, rotating and colour conversions.
- A PM bitmap viewer and an editor supporting all the above functionality.
- Plugins for the Lucide Document Viewer and the webbrowsers Netscape, Mozilla, Firefox and SeaMonkey.

## Platforms

GBM is available for several platforms, namely OS/2, DOS, Windows, Linux and AIX.
Note:
The version provided here is so far only supported on OS/2. Though it shouldn't be a problem to compile it for other platforms as it uses pure ANSI C code. You can get versions for other platforms supporting a smaller feature set on the homepage of the initial author Andy Key.

## Enhancements included

Many enhancements have been applied compared to the original version provided by Andy Key:

GBM format handler library

- PNG (new codec)
  - based on latest Libpng
  - supports all RGB/Gray color depths (1,2,4,8,16,24,32,48,64bpp)
  - supports transparency and alpha channel
  - supports PNG provided and custom backgrounds
- TIF (replacement codec)
  - based on latest Libtiff
  - supports multipage bitmaps
  - supports most RGB/Gray color depths (1,2,4,8,16,24,32,48,64bpp), partly CMYK (8/16bpp)
  - supports alpha channel (with rendering against a custom background)
  - Compression schemes: LZW, PackBits, ThunderScan, NeXT, JPEG, CCITT, Deflate, Adobe Deflate
- PBM (new codec)
  - reads and writes 1bpp black/white bitmaps
  - supports format types P1 (ASCII) and P4 (binary)
  - supports multipage P4 bitmaps
- PGM (enhanced codec)
  - reads and writes 8bpp grey bitmaps
  - supports format types P2 (ASCII) and P5 (binary)
  - supports multipage P5 bitmaps
- PPM (replacement codec)
  - reads and writes 24 and 48bpp RGB bitmaps
  - supports format types P3 (ASCII) and P6 (binary)
  - supports multipage P6 bitmaps
- PNM (new codec)
  - PNM consolidates the formats PBM, PGM and PPM under one extension
  - supports format types P1,P2,P3 (ASCII) and P4,P5,P6 (binary)
  - supports multipage P4,P5 and P6 bitmaps
- BMP (enhanced codec)
  - reads also RLE24 encoded OS/2 bitmaps
  - reads also Windows MultiMedia bitmaps (RGB, BITFIELDS: 16bpp, 32bpp)
  - handles now 1bpp color bitmaps rather than always mapping them to black/white
- JPEG (enhanced codec)
  - updated to IJG JPEG 6B
  - reads also YCCK and CMYK encoded JPEGs
  - writes grayscale JPEGs (8bpp)
  - some new write options are available like smoothing and optimizing
- TGA (enhanced codec)
  - reads also horizontally flipped TGAs
  - reads TGAs with alpha channel (32 bpp)
  - writes TGAs with alpha channel (32 bpp)
- XPM (new codec)
  - XPM2 and XPM3 formats without extensions (no XPM1, XPM2C)
  - supports RGB files with hex or X11 symbolic coded colours (4,8,12,16 bit per R,G or B)
  - supports transparency
- REXX adapter DLL available (GBMRX)

Command line tools

- gbmsize, gbmhdr, gbmref, gbmsub, gbmgamma
  - now also support 32, 48 and 64bpp (with/without alpha channel)
- gbmsize now supports also resampled scaling with several filters (Nearest Neigbor, Bilinear, Bell, BSpline, Mitchell, Lanczos)
- gbmconv added (format converter)
- gbmver added (helps analyzing all installed GBM DLLs and provides version compatibility hints for users)
- Enhanced command line parser to fix some issues when filenames with comma where specified

## JPEG support

The Independant JPEG Group have generously allowed others to use their source code to their JPEG handling library. The only condition of use is that the IJG must be credited for their work. Try looking for this library at:

- ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs851/jpegsr6b.zip.

Martin Lisowski has generously donated his `gbmjpg.c` to GBM. This file allows GBM to use the IJG 6a/IJG 6b library.

GBM may be compiled up either with or without JPEG support. If you use the JPEG enabled variety of GBM in your project, you must credit the IJG. This code has been tested on OS/2, AIX, Linux and Windows.

## PNG support (extension to base version)

The official Open Source reference libraries Libpng 1.2.25 and Zlib 1.2.3 can be used to build GBM with PNG support. Try looking for these libraries at:

- http://www.libpng.org
- http://www.zlib.org

I (Heiko Nitzsche) have donated `gbmpng.c` and `gbmmap.c` to GBM. These files allow GBM to use the Libpng 1.2.25 library.

GBM may be compiled up either with or without PNG support. If you use the PNG enabled variety of GBM in your project, you should credit the Open Source projects for Libpng and Zlib. This code has been tested on OS/2.

## TIF support (replacement of base version)

The official Open Source reference libraries Libtiff 3.8.2 can be used to build GBM with TIF support. Required are Zlib 1.2.3 and the IJG Group lib IJG 6b that is also used for standard JPEG support. Try looking for these libraries at:`
`

- http://www.libtiff.org
- http://www.zlib.org
- ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs851/jpegsr6b.zip.

I (Heiko Nitzsche) have donated `gbmtif.c` and `gbmmap.c` to GBM. These files allow GBM to use the Libtiff 3.8.2 library.

GBM may be compiled up either with or without TIF support. If you use the TIF enabled variety of GBM in your project, you should credit the Open Source projects for Libtiff, Zlib and the IJG. This code has been tested on OS/2.

## PBM support (extension to base version)

I (Heiko Nitzsche) have donated `gbmpbm.c` to GBM. This file allows GBM to read and write black/white PBM (binary P4, ASCII P1) files. This code has been tested on OS/2.

## PGM support (enhancement of base version)

I (Heiko Nitzsche) have donated `gbmpgm.c` to GBM. This file allows GBM to read and write greyscale PGM (binary P5, ASCII P2) files. This code has been tested on OS/2.

## PPM support (replacement of base version)

I (Heiko Nitzsche) have donated `gbmppm.c` to GBM. This file allows GBM to read and write unpalettised 24 and 48 bpp multipage RGB PPM (binary P6, ASCII P3) files. This code has been tested on OS/2.

## PNM support (extension to base version)

I (Heiko Nitzsche) have donated `gbmpnm.c` to GBM. This file allows GBM to read and write PNM (binary P4,P5,P6, ASCII P1,P2,P3) files. This code has been tested on OS/2.

## XPM support (extension to base version)

I (Heiko Nitzsche) have donated `gbmxpm.c` and `gbmxpmcn.c` to GBM. These files allow GBM to read and write XPM2 and XPM3 files. This code has been tested on OS/2.

## Related code

GBM was originally written as the file handling part of Andy Key's homebrew ray tracer, RT. His follow-on Modular Renderer package, MR, uses GBM. It does wire-frame, polygon rendering and raytracing.

From time to time I notice people (other than myself) using GBM either in its precompiled DLL form, or by recompiling bits of the source. Sometimes people email me to let me know.

Of course, simply using the code unmodified makes it easier for you to pick up improvements in the code, as and when they happen. Here are some example applications using GBM code.

GBM.DLL is used unmodified on OS/2 or eComStation by:

- The GBM tools and plugins:
  - GBM command line tools
  - GBMV
  - GBMV2
  - GBM File Dialog
  - GBMRX
  - GBMDLGRX
  - GBM plugin for Lucide
  - GBM plugin for Netscape/Mozilla/Firefox/SeaMonkey
- eComStation 1.2/1.2R ships with version 1.12.
- PM-Raw, PM-Exif, Calydos and CD-Magic
- The replacement JPEG IO Codec
- ShowImage and SlideShow modules for Doodle's Screen Saver

GBM code is internally used by:

- Maul Publisher uses GBM source code in it's gbm handler code (OS/2, Windows).
- PM123 Digital Audio Player uses GBM source code (OS/2). (see also: old pages)
- Papyrus apparently uses parts of GBM source code.
- IBM WebExplorer (OS/2) uses the Bitmap, GIF and XBM handling parts of GBM to some degree - in `webexwin.dll`.
- IBM VisualAge C++ 3.0 for OS/2 uses large wedges of GBM source code in their supplied `class IGBitmap`.
- The IBM Person to Person personal conferencing system for OS/2 used the PCX and TIFF parts of GBM, and I think the AIX variant used whole loads more.
- BluePaint, an OS/2 PM painting program uses GBM.DLL unmodified.
- BITMAP32, a bitmap viewer for OS/2 PM, uses GBM.DLL unmodified. Because the IBM Developer Connection shipped BITMAP32, they shipped GBM too.
- ...