MGL_createMemoryDC

Create a new memory device context.

Declaration

MGLDC * MGLAPI MGL_createMemoryDC(
int xSize,
int ySize,
int bitsPerPixel,
pixel_format_t *pf)

Prototype In

mgraph.h

Parameters

xSize | x resolution for the memory context
ySize | y resolution for the memory context
bitsPerPixel | Pixel depth for the memory context
pf | Pixel format for memory context (NULL for 8 bits and below)

Return Value

Pointer to the allocated memory device context, NULL if not enough memory.

Description

Creates a new memory device context, allocating the necessary memory resources to hold the surface of the memory device given the specified resolution and pixel depth. The surface of a memory device context is always allocated using the appropriate operating system specific functions, and you can always directly access the surface of the device context via the surface pointer of the MGLDC structure. If you do directly access the surface, the dimensions and pixel format of the device context surface are stored in the gmode_t field of the MGLDC structure, and you should use these values to write your own direct rendering code.

For memory device contexts with pixel depths greater than 8 bits per pixel, you must also pass a valid pixel_format_t structure which defines the pixel format to be used for the device context. If you wish to create a memory device context for your main rasterizing context which you then wish to Blt to the screen, you must ensure that you use the same pixel format for the memory device as the display device for the current graphics mode, otherwise the pixel formats will be translated on the fly by the MGL_bitBlt function resulting in very low performance. You can use the MGL_getPixelFormat function to obtain the pixel format information for the display device context you are using.

Note that all device contexts have an associated color palette, even RGB device contexts. In RGB modes the color palette is used for converting color index pixel values to RGB values during BitBlt operations and with the MGL_realColor and MGL_setColorCI function.

See Also

MGL_createCustomDC, MGL_createDisplayDC, MGL_destroyDC

Copyright © 2002 SciTech Software, Inc. Visit our web site at http://www.scitechsoft.com