Microsoft Windows CE 3.0  

Accessing Surface Memory Directly

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.

You can directly access the frame buffer or off-screen surface memory by using the IDirectDrawSurface5::Lockmethod. When you call this method, the lpDestRectparameter is a pointer to a RECTstructure that describes the rectangle on the surface you want to access directly. To request that the entire surface be locked, set lpDestRectto NULL. Also, you can specify a RECTthat covers only a portion of the surface. Providing that no two rectangles overlap, two threads or processes can simultaneously lock multiple rectangles in a surface.

The Lockmethod fills a DDSURFACEDESC2structure with all the information you need to properly access the surface memory. The structure includes information about the pitch (or stride) and the pixel format of the surface, if different from the pixel format of the primary surface. When you finish accessing the surface memory, call the IDirectDrawSurface5::Unlockmethod to unlock it.

While you have a surface locked, you can directly manipulate the contents. The following list describes some tips for avoiding common problems with directly rendering surface memory: