This chapter presents fast drawing techniques, animation using bitmaps, and color palettes. First, fast drawing using the exclusive-or (R2_XORPEN) and the exclusive-nor (R2_NOTXORPEN) ROP2 codes is explored. Then, fast drawing using the “backing store” technique is discussed. Bitmaps are used in the backing store technique, and their use is introduced. After this, an example of creating animation using bitmaps is presented. Finally, the device independent bitmap (DIB) and color palettes are discussed.
In the graphics example of the previous chapter, the area enclosed in a rectangle surrounding the shape being formed is redrawn whenever the mouse moves. This causes the entire rectangular area to flicker while drawing. Drawing techniques can be used that only need to change the area within the shape being drawn. When the shape is an ellipse, the shape itself need only be erased and redrawn, rather than the entire rectangular area surrounding the ellipse. But a way to erase its previous shape from the screen needs to be provided prior to redrawing it in its new shape. In this chapter such techniques, which promote fast drawing and minimum screen flicker, are explained. Using Exclusive-or and Exclusive-nor for Fast
The first fast drawing technique presented is the use of either of the fast drawing modes: exclusive-or or exclusive-nor. This technique is demonstrated by modifying the graphics program presented in the previous chapter in Listing 3-3. The running program is shown in Figure 4-1. The program called “FastDraw” looks a lot like the graphics program with the exception that the menu item “ROP2” has been replaced with a new menu item, “FastRedrawMode,” which creates a popup menu with two choices: “XORMode” or “NotXORMode.” These menu choices, of course, are used to set the parameters of the fast drawing mode; “XORMode” gives the choice of drawing with the exclusive-or mode, and “NotXORMode” gives the choice of...