Supported Browsers Home   
MGL_closeFontLib Previous   
MGL_copyBitmapToBuffer Next   
External Functions Up   

MGL_computePixelAddr

Computes the address of a pixel in the device context surface.

Declaration

void * MGLAPI MGL_computePixelAddr(
    MGLDC *dc,
    int x,
    int y)

Prototype In

mgraph.h

Parameters

dc

Device context to compute the pixel address for

x

X coordinate of pixel to address

y

Y coordinate of pixel to address

 

Return Value

Pointer to the start of the pixel in the surface of the device context.

Description

This function computes the address of a pixel in the surface of a specific device context. This function is most useful for developing custom rendering routines that draw directly to the surface of a device context, and will compute the address of the pixel correctly regardless of the color depth of the device context. Essentially this function computes the following:

addr = dc->surface + (y * bytesPerLine) + (x * bytesPerpixel)

If you are going to be doing a lot of address calculations, it will be faster to optimise your code to do the calculations directly in place (such as with a macro) and specifically to eliminate the last multiply if you know in advance what color depth you are working with (ie: change it to be x, x*2, x*3 or x*4 depending on the color depth).

Note:    You cannot use this function to address the device context surface if the device surface access type returned by MGL_getSurfaceAccessType is set to MGL_NO_ACCESS.

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