Title Banner

Previous Book Contents Book Index Next

Newton Developer Technical Information: Newton Programmer's Guide: 2.1 OS Addendum /
Chapter 6 - Drawing and Graphics 2.1 / Using Drawing and Graphics in the Newton 2.1 OS


Gray Transfer Modes

The transfer modes are used to specify how a graphic object is drawn onto an existing bitmap, usually the screen. The system combines the two images at the pixel level, combining the images with the operation specified in the transfer mode. The transfer mode constants are described in "Transfer Mode Constants".

The effect of the different transfer modes is illustrated in Figure 6-6.

Figure 6-6 Two bitmaps combined with the different transfer modes



The value of the individual pixels is determined by first looking up the value in the color lookup table. If the default color table is used, no lookup is required as the indices and the tones are identical. Secondly, the source bitmap must be changed to the bit depth of the destination bitmap. Then the source bitmap is scaled, if necessary. Finally the individual pixels are combined as indicated by the transfer mode.

In most cases, you do not need to worry about how it is that the source bitmap is scaled (in both size and bit depth). Some of the transfer modes, modeXor and modeBic, operate by a bitwise combination of the pixel values. These transfer modes are most useful when using black and white sources, and have unexpected results when combining grays. Using modeBic is especially useful for drawing white text over a black or gray background.

If you do wish to use these transfer modes with two shades of gray, and you want to understand what the result will be, you must consider the effect of scaling the source bitmap. This information is provided in "How the System Scales Bitmaps."

How the System Scales Bitmaps

Before two bitmaps can be merged, the two bitmaps must be made to agree in bit depth, and the source bitmap may need to be scaled. The source bitmap is always the one to be shrunk or enlarged to match the destination bit depth.

If the source bitmap needs to be shrunk in size, it is partitioned into as many groups of pixels as are desired, and the darkest pixel in each source group is used. For example, if a 4-bit scan line contains the indices 0x56 34 A2 C8..., and is being shrunk 50%, the indices 0x64AC... are used. The darkest of each 2 pixel group is used. Since the following scan line of source data will also be combined with the current line, this algorithm is repeated, and the darkest of each 2x2 block of source pixels is mapped to each destination pixels.

When the source bitmap is expanded to fit a larger destination bitmap, pixels are repeated as necessary. For example if the same 0x56 34 A2 C8... scan line is being increased horizontally by 100%, the individual pixels are simply repeated to produce 0x55663344AA22CC88...

When the bit depth of the source bitmap is reduced or increased, it is necessarily changed by a power of 2. If the bitmap is being expanded, the pixel's bit patterns are simply repeated. For example if a pixel with the 2-bit binary value 01 is being increase to 4-bits, the zero is repeated and the one is repeated to produce the binary value 0011. The 2-bit pixel 01 is expanded to the 8-bit pixel 00001111.

If a bitmap is being reduced in bit depth, the high bits of each pixel is used. For example, an 8-bit scan line 0x08 17 28 A5... is reduced to the four-bit scan line 0x012A... As a further example, the 8-bit pixel 0xA2 (binary 10100010) is reduced to the 4-bit pixel 1010 and to the 2-bit pixel 10.

Once the two bitmaps have been made to agree in bit depth and size, the affect of the transfer modes can be established. These are described in "Transfer Mode Constants".


Previous Book Contents Book Index Next

© Apple Computer, Inc.
26 APR 1997



Navigation graphic, see text links

Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help