[ Pobierz całość w formacie PDF ]
.Code has little controlover the type of scaling performed by the driver.The only possibility is to set theDDBLTFX_ARITHSTRETCHY flag in the dwDDFX member of the DDBLTFX structure passed toBlt().This flag requests that arithmetic stretching be done on the y-axis.Arithmetic stretching onthe x-axis and arithmetic shrinking are not currently supported in the DirectDraw API, but a drivermay perform them on its own.MirroringMirroring is another transformation supported by the HEL.Applications can assume that it isavailable even if it is not supported in the hardware.Mirroring is defined in the x- and y-axes of theblit rectangle.Figure 10-8 shows mirroring along either axis. Figure 10-8: Mirroring transformationsTable 10-8 lists the predefined constants used in mirroring transformations during Blt().Table 10-8: Mirroring Flags for the Blt() FunctionFlags MeaningDDBLTFX_MIRRORLEFTRIGHTMirrors on the y-axis.The surface is mirroredfrom left to right.DDBLTFX_MIRRORUPDOWNMirrors on the x-axis.The surface is mirroredfrom top to bottom.Applications sometimes need several versions of a symmetrical sprite, in which the image faces indifferent directions.Rather than creating a bitmap for each image, it is possible to generate themby mirroring the original.Hardware support for mirroring can be determined by the presence of theDDFXCAPS_BLTMIRRORLEFTRIGHT and DDFCAPS_BLTMIRRORUPDOWN identifiers in thedwFXCaps member of the DDCAPS structure.Raster operationsBlit-time transformations can include some of the standard raster operations (ROPs) used by theGDI BitBlt() functions.At present only SRCCOPY (the default), BLACKNESS, and WHITENESS aresupported by the HEL.Hardware support for other raster operations can be determined byexamining the DDCAPS structure.Code that uses any of the standard ROPs with the Blt() methodmust set the corresponding flag in the dwROP member of the DDBLTFX structure.The dwDDROPmember of the DDBLTFX structure is for specifying ROPs specific to DirectDraw.No such ROPshave been defined at this time. SummaryIn this chapter we discussed the DirectDraw blit operation and the transformations that take placeat blit time.We started by reviewing surfaces because DirectDraw bitmap rendering operationsalways take place at the surface level.We also looked at transparency and color keys as thefundamental tool for overlaying bitmaps.The basic rendering functions, Blt() and BltFast(),were analyzed in detail, as well as the blit-time transformations consisting of color fills, scaling,mirroring, and raster operations.The next chapter is devoted to bitmap programming in DirectDraw. Chapter 11: Rendering Bitmaps in DirectDrawOverviewBitmaps are one of the most powerful structures available to the graphics programmer.In today'stechnological world, with an abundance of real-color and True-color modes, bitmaps can be usedto encode images with photo-realistic accuracy.The processing capabilities available in thisgeneration of PCs make possible the effective manipulation of bitmapped images.DirectDrawimplements a new dimension of functionality in bitmap processing and display operations.Manytypes of applications rely heavily on bitmaps; these include image processing, simulations, virtualreality, artificial life, and electronic games.This chapter is devoted to bitmap rendering in the context of a DirectDraw windowed application.The use of bitmaps in animated programs that execute DirectDraw exclusive mode is the topic ofChapter 12. Rendering a BitmapIn DirectDraw programming bitmap manipulations consists of four basic steps:" Loading the bitmap into application memory" Obtaining bitmap data necessary for displaying it on the screen" Moving the bitmap onto a DirectDraw surface" Blitting the bitmap onto the video displayLoading the bitmapLoading a bitmap onto the application's memory space is an operation of GDI graphics, notactually part of DirectDraw.In the demonstration program named Bitmap Demo, contained in thebook's CD-ROM, we load several bitmaps during WM_CREATE message processing.In this casewe used Developer Studio to define the bitmaps as program resources, and then usedLoadBitmap() to load them into the application's memory space.Alternatively, instead ofdefining the bitmap as a program resource, you can use LoadImage() to load the bitmap directlyfrom the disk file in which it is stored.At this time you can also perform certain preliminary checksto make sure that the DirectDraw surface is compatible with the bitmap to be displayed.Note thatthe sample code requires that the surface be nonpalettized.The GetSurfaceDesc() DirectDrawfunction is used to fill a DDSURFACEDESC2 structure, discussed in Chapter 9.TheDDPIXELFORMAT structure, which is part of DDSURFACEDESC2, contains two relevant values: theflag DDPF_RGB indicates that the RGB data is valid, and the dwRGBBitCount member containsthe number of RGB bits per pixel.If the DDPF_RGB flag is set and dwRGBBitCount is greater than15, you can assume that the surface is nonpalettized, and therefore compatible.Note that the LoadImage() function does not return palette information.Microsoft KnowledgeBase Article Q158898 lists the function LoadBitmapFromBMPFile(), which uses theDIBSection's color table to create a palette.If no color table is present, then a half-tone palette iscreated.You can find the source for this function in the MSDN Library that is part of Visual C++.When code has determined that a compatible surface is available, it can proceed to load thebitmap.The general form of the LoadImage() function is as follows:HANDLE LoadImage(HINSTANCE hInst, // 1LPCTSTR lpszName, // 2UINT uType, // 3int cxDesired, // 4int cyDesired, // 5UINT fuLoad // 6 );The first parameter is a handle to an instance of the module that contains the image to be loaded.In the case of an image contained in a file, this parameter is set to zero.The second parameter isa pointer to the image to load.If it is nonNULL and the sixth parameter (described later) does notinclude LR_LOADFROMFILE, then it is a pointer to a null-terminated string that contains thefilename of the image resource.The third parameter is the image type.It can be one of thefollowing constants:IMAGE_BITMAPIMAGE_CURSORIMAGE_ICONThe fourth and fifth parameters specify the pixel width and height of the bitmap, cursor, or icon [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • personata.xlx.pl