═══ 1. Introduction to GbmV2 ═══ This is a simple bitmap viewer. Bitmap files in various formats may be loaded into memory. This is the actual bitmap data. The program displays a view of the bitmap in its window. This is called the view bitmap. The choice of how the view is made from the actual data may be changed from the View menu. If the bitmap is smaller than the window, it is displayed centralised within the window. If the bitmap is larger than the window, then scrollbars may be used to pick the visible part of the bitmap. Once a bitmap is loaded, it may be printed to the default PM printer. All, or a part of, the current bitmap can be selected, and then copied to the clipboard. 1bpp bitmaps are typically tricky to handle under OS/2 PM. This program will display a 1bpp bitmap using the 2 colours in the bitmap files header, rather than the users current PM colour scheme. While files are loading, saving, printing etc., this program prevents you from using its other functions. From the menu bar you can use: File To transfer the text to and from disk Edit To transfer some or all of the bitmap to the OS/2 clipboard Bitmap To perform simple operations on the bitmap View To select how you see the current bitmap Help To display various types of help for using this utility. You can display online help for GbmV2 by using the following methods. o For help about any pull-down option, highlight it and press F1. o For help about any displayed dialog box, select the Help pushbutton. o To see the Help Index, use the Help pull-down, or press F11. o To see the Help table of contents, display a help panel and use the Help Options pull-down (or press Ctrl+C). ═══ 2. File menu ═══ The File menu allows you to load a new bitmap, to save to a bitmap file, and to print. You can use: New To clear out the current bitmap. Open To discard the current bitmap and read a new file from disk. The file to load is selected via the Bitmap File dialog. Save To save the current bitmap to a file, under the current filename. The actual bitmap data, rather than the view what you see of it that is saved. Save as To save the current bitmap to a file with a filename you specify. The filename to save to is specified via the Bitmap File dialog. The actual bitmap data, rather than the view what you see of it that is saved. ═══ 2.1. New ═══ Will clear any loaded bitmap from memory. You can also begin a New file by pressing Ctrl+N. ═══ 2.2. Open ═══ Brings up a dialog box which allows you to specify the bitmap file to load. The file to load to is specified via the Bitmap File dialog. You can also Open a file by pressing Ctrl+O. ═══ 2.3. Save ═══ Saves the currently loaded bitmap. It is the actual bitmap data, not the view you see, that is actually saved. For example, the actual bitmap map can be 24 bit, but you may be looking at an (8 bit) error diffused version on the screen. If you wish to save under a new filename, use Save as instead. You can also Save to a file by pressing Ctrl+S. ═══ 2.4. Save As ═══ Saves the currently loaded bitmap, but under a new filename. The filename to save to is specified via the Bitmap File dialog. If you wish to save under the current name, use Save instead. It is the actual bitmap data, not the view you see, that is actually saved. For example, the actual bitmap can map be 24 bit, but you may be looking at an (8 bit) error diffused version on the screen. You can also Save as to a named file by pressing Ctrl+A. ═══ 2.5. Print ═══ Prints the currently loaded bitmap to the default PM printer. It is the screen view of the bitmap, not the actual bitmap data itself, that is transferred to the printer. Works best when the default PM printer is a PostScript printer, as they typically can simulate 26 gray-scale levels via halftoning. You can also Print by pressing Ctrl+P. ═══ 3. Edit menu ═══ The Edit menu allows you to select a sub-rectangle of the bitmap and then copy it to the clipboard. You can use: Undo To undo the last operation performed on the bitmap. Select To select a part of the current bitmap. Select all To select all the current bitmap. Deselect To cancel the current selection. Copy This copies the current selection to the clipboard. ═══ 3.1. Undo ═══ The Undo operation undoes the last change to the bitmap. It is only selectable after a change has been done to the bitmap, such as those provided under the Bitmap menu. In low memory situations, it may be impossible to undo a previous operation. Certain operations, such as New and Open are not undoable. ═══ 3.2. Select ═══ After choosing this menu selection, the mouse pointer changes into a angle-bracket-L shape which you move to the bottom left of the region of the bitmap you wish to select, and then press the left mouse button. Then it changes to an angle-bracket-7 shape, which you then move to the top right of the region you wish to select, and then press the left mouse button. This newly selected region becomes selected and is marked with a rectangle. This is the region that can subsequently become copied to the clipboard using Copy. Alternatively, the whole bitmap can be selected using Select all. The Esc key cancels the selection process. ═══ 3.3. Select all ═══ After choosing this menu selection, the whole current bitmap is selected. This newly selected region becomes selected and is marked with a a rectangle. This is the region that can subsequently become copied to the clipboard using Copy. Alternatively, just a part of the bitmap can be selected using Select. You can also Select all by pressing Ctrl+/. ═══ 3.4. Deselect ═══ This menu item removes the current selection. You can also Deselect by pressing Esc, or by clicking the right mouse button on the bitmap. ═══ 3.5. Copy ═══ This can only occur if there is a selected region. This menu item copies the current selected region to the clipboard. A region can be selected using Select or Select all. It is the version you see on the screen that is copied to the clipboard, not the actual original bitmap data itself. You can also Copy by pressing Ctrl+Ins. ═══ 4. Bitmap menu ═══ The Bitmap menu allows you to perform simple operations on the current bitmap. You can use: Reflect horizontally To reflect the bitmap left-to-right. Reflect vertically To reflect the bitmap left-to-right. Rotate 90 degrees To rotate the bitmap 90 degrees anticlockwise. Rotate 180 degrees To rotate the bitmap 180 degrees. Rotate 270 degrees To rotate the bitmap 90 degrees clockwise. Transpose x for y To transpose the bitmap x for y. Crop to selection To discard all but the selected part of the bitmap. Colour space... To map bitmap pixels / palettes between colour spaces. Map... To map between various numbers of bits per pixel and between various palettes. The Undo menuitem can be used to undo the last operation performed on a bitmap. ═══ 4.1. Reflect horizontally ═══ This reflects the whole bitmap left-to-right. Reflecting vertically can be done using the similar Reflect vertically selection. Other operations on the bitmap can be accessed from the Bitmap menu. ═══ 4.2. Reflect vertically ═══ This reflects the whole bitmap top-to-bottom. Reflecting horizontally can be done using the similar Reflect horizontally selection. Other operations on the bitmap can be accessed from the Bitmap menu. ═══ 4.3. Rotate 90 degrees ═══ This rotates the bitmap through 90 degrees clockwise. Other rotations may be acheived via the Rotate 180 degrees and Rotate 270 degrees commands. Other operations on the bitmap can be accessed from the Bitmap menu. ═══ 4.4. Rotate 180 degrees ═══ This rotates the bitmap through 180 degrees clockwise. Other rotations may be acheived via the Rotate 90 degrees and Rotate 270 degrees commands. Other operations on the bitmap can be accessed from the Bitmap menu. ═══ 4.5. Rotate 270 degrees ═══ This rotates the bitmap through 270 degrees clockwise. Other rotations may be acheived via the Rotate 90 degrees and Rotate 180 degrees commands. Other operations on the bitmap can be accessed from the Bitmap menu. ═══ 4.6. Transpose x for y ═══ This reflects the bitmap through the line y=x. Other operations on the bitmap can be accessed from the Bitmap menu. ═══ 4.7. Crop to selection ═══ This discards all the bitmap except the selected bit. Other operations on the bitmap can be accessed from the Bitmap menu. ═══ 4.8. Colour space... ═══ This menuitem will cause the Colour space dialog to appear. From here mappings between intensity, L* cyclometric and gamma corrected colour spaces may be performed. Other operations on the bitmap can be accessed from the Bitmap menu. ═══ 4.9. Map... ═══ This menuitem will cause the Map dialog to appear. From here mappings between various numbers of bits per pixel and various palettes may be performed. Other operations on the bitmap can be accessed from the Bitmap menu. ═══ 5. View menu ═══ The View menu allows you to choose what representation (or view) of the bitmap you have loaded will be used for display on the screen. You can use: Raw PM mapping To tell this program to perform no image enhancment for display purposes. The view bitmap is displayed as good as PM will, with no improvement. Halftoned To tell this program to show a halftoned version of the bitmap to the user, rather than the actual bitmap data itself. This generally looks slightly better and is quick to do. Error diffused To tell this program to show a error-diffused version of the bitmap to the user, rather than the actual bitmap data itself. This generally looks much better, but takes longer to do. This program makes a guess at the type of display adaptor you are using and chooses the most appropriate form of halftoning or error-diffusion to use. Specifically, it has algorithms known to work well on :- 16 colour VGA 256 colour 8514/A, XGA and Image Adaptor/A. 65536 direct colour XGA-2. If you actually wish to change the bitmap data itself, then you can use the Map dialog to do this. ═══ 5.1. Raw PM mapping ═══ This tells this program to not perform any image enhancement that will make a bitmap look closer to its true colours and shades on the screen. You can also select view Raw PM mapping by pressing Ctrl+R. It is possible to select other views from the View menu. ═══ 5.2. Halftoned ═══ This tells this program that it should present a halftoned view of the current bitmap to the user. The actual bitmap data itself is not affected, only what you see on the screen. Hence if Save or Save as are used, the unchanged actual bitmap data is saved. Halftoning is generally quicker than error diffusion. You can also select view Halftoned by pressing Ctrl+H. It is possible to select other views from the View menu. ═══ 5.3. Error diffused ═══ This tells this program that it should present an error-diffused picture of the current bitmap to the user. The actual bitmap data itself is not affected, only what you see on the screen. Hence if Save or Save as are used, the unchanged actual bitmap data is saved. Error diffusion takes longer than halftoning, but the quality is generally higher, especially on continuous tone images. You can also select view Error diffused by pressing Ctrl+E. It is possible to select other views from the View menu. ═══ 6. Help menu ═══ Use this menu to bring up the help system. ═══ 6.1. Help for help ═══ Use this choice to bring up the help for the help system. ═══ 6.2. Extended Help ═══ Use this choice to bring up general help for GbmV2. ═══ 6.3. Keys help ═══ The following keys may be used in the main window :- o Ctrl+N selects New which clears the bitmap. o Ctrl+O to Open a new bitmap file via the Bitmap File dialog. o Ctrl+S to Save the current bitmap. o Ctrl+A selects Save as which saves the bitmap under a new filename, specified via the Bitmap File dialog. o Ctrl+P to Print the current bitmap. o Ctrl+R to select Raw PM mapping view mode. o Ctrl+H to select Halftoned view mode. o Ctrl+E to select Error diffused view mode. o Ctrl+/ to Select all all of the current bitmap. o Ctrl+\ to Deselect any current selection. o Esc to Deselect any current selection. o Ctrl+Ins to Copy the current selection to the clipboard. o The Arrow keys may be used to scroll around the bitmap. Note that Shift+Arrows behave like page up/down/left or right. o F3 to close GbmV2. ═══ 6.4. Help index ═══ Use this to bring up an index of the help. ═══ 7. Colour space dialog ═══ If a light is physically twice as bright, the eye does not necessarily see it as twice as bright. Also, if a pixel is written onto a monitor screen with twice the value, the physical intensity of the pixel is not necessarily double. How exactly should numbers inside a bitmap file relate to physical or perceived intensitys when displayed on the screen? In OS/2 PM perceived intensitys are proportional to the values in the bitmap file. Pixels in such a bitmap are in the L* cyclometric colour space. This is done to ensure that an even scale of pixel values gives an even scale of brightness, when viewed by the human eye. Ray Tracers often write pixel values in the bitmap proportional to the physical intensity computed for that ray. Also this may be more suitable if certain image processing/enhancement techniques are to be applied to the image data. Such data is in the intensity colour space. Finally, if a bitmap holds values computed in such a way as to compensate for the gamma of the monitor (ie: intensitys transformed to cancel out the gamma of the monitor), then the data is in a gamma corrected colour space. Bitmap data that has come directly from a greyscale or colour scanner may also be in a gamma corrected colour space. Of course, despite OS/2 PM using the L* cyclometric colour space, this machine is attached to a monitor with specific characteristics and your eyes also have their own characteristics. But it is the responsibility of OS/2 PM screen drivers to perform the mapping from the L* cyclometric colour space to suitable palette entrys which take into account both the gamma (and shelf) of the monitor in use, and the visual characteristics of the human eye. This is done transparently to PM applications. The various mappings allow you map between any 2 of these 3 colour spaces. Examples of typical usage follow :- Intensity to L* cyclometric You have loaded a bitmap file where the pixel values are proportional to the physical intensity. Such bitmaps often tend to look too dark under OS/2 PM. This will map the pixels to the L* cyclometric colour space, giving a better rendition under OS/2 PM. Intensity to gamma corrected The resulting bitmap, may still look too dark/light under OS/2 PM, but when saved, and displayed on a monitor with the relevant gamma and shelf with a program that directly controls the hardware, the correct rendition will result. L* cyclometric to Intensity You have a regular OS/2 PM bitmap, and wish to make the pixel values in the file directly proportional to the physical intensity. You might do this to generate a bitmap suitable for feeding into a Ray Tracer as a 2D texture map. L* cyclometric to gamma corrected As above, but generating bitmap bits suitable for directly placing in hardware registers. Gamma corrected to Intensity You have loaded a bitmap that has come directly from some scanner hardware, and wish to make bitmap where bits are proportional to intensity. Gamma corrected to L* cyclometric You have loaded a bitmap from a scanner, and wish to make a bitmap best suited for OS/2 PM. When mapping to or from the gamma corrected colour space, the gamma and shelf values are significant. When the gamma corrected colour space is not involved, the gamma and shelf parameters are greyed. For example, the gamma of the 8514 monitor is about 2.1. The shelf parameter will normally be left 0.0, but has significance for some monitors. For example, on some 8514 monitors, if a greyscale of bitmap pixels 0 to 255 is displayed, the first 35 values come out equally black. So, here a shelf of 0.136 (as 0.136*255=35) should be used. Mapping of this sort should really be done on 24 bit data, before error-diffusion or halftoning takes place. If the current bitmap is 24 bpp, then each bitmap pixel is mapped. Otherwise, the palette entrys are mapped. This dialog is brought up from the Colour space... menuitem. ═══ 8. Map dialog ═══ When the Convert pushbutton is pressed on this dialog, the current bitmap is expanded from however many bits per pixel it currently is to 24 bits per pixel (with no palette). Then a mapping is performed, to the desired number of bits per pixel and palette specified. For some mappings, some or all of the values in the Values part of the dialog box are used. Those which have no effect are greyed. Also, when mapping to some palettes, the option of using halftoning or error diffusion may be available. When these are unavailable, they are greyed. 1bpp, black and white The bitmap is mapped to black and white. This is done by mapping each pixel to a grey value, and then seeing if the brightness is in the high 50% or not. 4bpp, 8 colours This maps each pixel to one of black, white, red, green, blue, cyan, magenta or yellow. This option is handy for generating bitmaps to be fed into colour printers. 4bpp, 16 colour VGA palette Each pixel is mapped to a colour in the VGA palette used by DOS, Windows and OS/2 PM. 4bpp, 16 shades of grey Each pixel is mapped to one of 16 shades of grey. 8bpp, 7Rx8Gx4B palette This is a palette consisting of 7 levels of red, 8 levels of green and 4 levels of blue. It is constructed this way because the eye is most sensitive to green, then to red, and least to blue. Most 32 bit OS/2 PM drivers, and the old 16 bit 8514/A driver use a palette with these colours in. 8bpp, 6Rx6Gx6B palette The old 16 bit XGA-1 OS/2 PM driver used a 6 red by 6 green by 6 blue palette. 8bpp, 256 shades of grey Each pixel is mapped to a greyscale via a weighted sum of the red, green and blue components. Grey = 30% red + 59% green + 11% blue. These correspond to the eyes relative sensitivities to these primary colours. 8bpp, 64R+64G+64B tri-pel palette The palette of the resulting bitmap has 64 shades of red, 64 of green and 64 of blue. Pixels in the source alternately have their red, green or blue component considered and a pixel written out from the relevant part of the palette. Therefore colour resolution is 6 bits of each of red, green and blue, at the expense of artifacts produced caused by the alternation and also at the expense of reducing the image brightness by a factor of 3. 24 bpp, keep R bits red, G green, B blue Although the resulting image has 24bpp, only R bits of red, G of green and B of blue are non-zero. XGA-2 in its 16bpp mode has 65536 colours, which are composed from 32 levels of red, 64 of green and 32 of blue. Thus R=5, G=6, B=5 can be used to transform an image into what can be displayed on XGA-2. 8bpp, as above, find N most used cols. After performing the above step, the 24bpp data is analysed to find the N most frequently occuring colours. Any pixels in the image in the N most used colours are mapped directly to that colour. Any pixel not in the N most used colours is mapped to the closest colour in the N most used. This may be used to make the best rendition for display by a DOS program that uses VGA 320x200 8bpp mode by setting R=6, G=6, B=6, N=256, since only 6 bits are significant in the VGA palette DACs, and we only have 256 colours in the palette. Important These mappings apply to the actual bitmap data and are nothing to do with the viewing options available from the View menu. Therefore, if you load a bitmap, error diffuse via this dialog box, and then save, the saved file is error-diffused. This directly contrasts the View menu, where the error diffusion is purely for display purposes. This dialog is brought up from the Map... menuitem. ═══ 9. Credits ═══ This code is the work of :- {{{ Andy Key Internet: ak@vnet.ibm.com IBM-VNET: AKEY AT HVTVM5 Electronic addresses valid at least until September 1994.