Over 10 Million Study Resources Now at Your Fingertips


Download as :
Rating : ⭐⭐⭐⭐⭐
Price : $10.99
Language:EN
Pages: 2

Animation image set stored rectangular bitmap

screen. In each particular case you must decide whether the rendering is done using Blt() or BltFast(), with or without transparency, using source or destination color keys, or applying any blit-time transformations. The sprite image sequence is usually stored in a single bitmap, but it is also possible to store various bitmaps in different disk files and then read all of these files into a single surface. The final result, in either case, is a surface with multiple images. At blit time the program logic must select the corresponding image in the animation set.

The display of several images stored in a contiguous memory area or surface is made possible by the source area definition capabilities of both Blt() and BltFast(). In Chapter 10 we saw that a structure of type RECT is used to store the offset of the source rectangle in the surface. If an animation image set is stored in a rectangular bitmap, and the bitmap is then loaded onto a surface, then code can select which of the images in the set is displayed during each time-pulse iteration. You can do this by assigning values to the corresponding members of the RECT structure variable that defines the source surface. For example, the final bitmap image set in Figure 12-5 contains a sequence of 18 individual rotations of the gears. Each of these individual bitmaps is often called an animation frame, or simply, a frame. Figure 12-6 shows the image set partitioned into six columns and three rows. The dimensions labeled x and y refer to the size of each frame in the set.

Figure 12-6: Rendering the sprite image set

Given the number of rows and columns in the image set, and the pixel size of each image, code can determine the coordinates of the RECT structure variable for each frame in the set. The dotted rectangle in Figure 12-6 binds each frame in the sequence. The members of a structure variable named rect, of type RECT, are calculated using the consecutive frame number and the number of columns in the bitmap. The case illustrated shows frame number 8, of a bitmap with six columns and three rows.

In this case the programmer defines the name of the bitmap and states the number of image columns and rows. Code uses these values to calculate the number of frames; this number is stored in the variable frameCount. The dimensions of the bitmap are obtained after it is loaded into memory. The x dimension is stored in the variable bmapXSize and the y dimension in bmapYSize. The bitmap dimensions are also used in the sample program to define the size of the application window, all of which is shown in the following code fragment:

//**************************************
// Load bitmap into memory
//**************************************
// Load the bitmap image into memory
aBitmap = ( HBITMAP )LoadImage( NULL, bmapName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE );
if ( aBitmap == NULL )
DDInitFailed(hWnd, hRet,
"Bitmap load failed in DDLoadBitmap()");
// Get bitmap data
GetObject(aBitmap, sizeof (BITMAP), &bMap1);

How It Works
Login account
Login Your Account
Add to cart
Add to Cart
Payment
Make payment
Document download
Download File
PageId: ELI49B34B7
img
Uploaded by :
BmbwewzA
Page 1 Preview
animation image set stored rectangular bitmap
Sell Your Old Documents & Earn Wallet Balance