Microsoft Windows CE 3.0  

Node2D

Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

This class is a helper class for display devices that allocate memory as single rectangular blocks. For these types of device, the stride of bit block transfer (blit) operations is a constant, regardless of the width of the actual surface. Many devices, such as the S3Trio64 chipset, use the current screen width as the width of the video memory. All blit operations are assumed to have the same stride, or pitch, as the screen and the same pixel format.

To allocate a memory rectangle, create an initial Node2Dobject, using the same height and width as the memory block. Enter the width either in pixels or in bytes. Queries to allocated subrectangles of memory return the origin of the allocated memory in the same units with which the original Node2Dobject was created.

You must allocate subrectangles in the same units, as well. Allocate subrectangles using the Allocmethod of the root node. Examine the origin of the new node, using the Topand Leftmethods of the node. As a final step, free the node, using the Freemethod. The following code example shows how the Freemethod is usually implemented.

// Assume there is a 640x1000-pixel line // block
of memory starting at memBase // to be allocated as a rectangle.
#define MEM_WIDTH_IN_PIXELS 640 #define PIXEL_BYTES 2 #define
MEM_HEIGHT 1000 extern unsigned char *memBase; Node2D
AllMem(MEM_WIDTH_IN_PIXELS, MEM_HEIGHT); // Allocations are done in
pixels. // Create a 20x40 surface. Node2D *pSurf1 =
AllMem->Alloc( 20, 40 ); // Check that pSurf1 is not NULL. //
Create a 100x100 surface. Node2D *pSurf2 = AllMem->Alloc( 100,
100 ); // Check that pSurf2 is not NULL. int strideInBytes =
MEM_WIDTH_IN_PIXELS * PIXEL_BYTES; // Create a pointer the the top
left of the block of // memory in surf1. unsigned char *ptr1 =
memBase + strideInBytes * pSurf1->Top() + PIXEL_BYTES *
pSurf1->Left(); // Now delete the surface(s). pSurf1->Free();
pSurf2->free();


 Last updated on Tuesday, July 13, 2004

© 2004 Microsoft Corporation. All rights reserved.