|
Documentation
|
|||||||||||||||
|
CGapiRGBASurfaceOverviewCGapiRGBASurface is a memory area with embedded alpha information. You can use CGapiRGBASurface in operations such as CGapiSurface::AlphaBlt for easy to use alpha blends. This document has been updated for use with GapiDraw 4.0 or later.
CGapiRGBASurface::CreateSurfaceThis method allocates memory for the surface and prepares it for graphic operations.
Parameters
|
|
Type |
Description |
|---|---|
|
GDRGBASURFACE_CLEAR |
Clears the surface memory area after creation. |
|
GDRGBASURFACE_12BIT |
Store the surface as 444A WORD aligned. |
|
GDRGBASURFACE_32BIT |
Store the surface as 555A or 565A DWORD aligned. |
|
GDRGBASURFACE_SYSTEMMEMORY |
Store the surface in system memory - default. |
If this method succeeds, the return value is GD_OK.
If the method fails, the return value may be one of the following return values:
GDERR_BITMAPNOTFOUND
GDERR_INCOMPATIBLEPRIMARY
GDERR_INVALIDBITMAP
GDERR_INVALIDPARAMS
GDERR_INVALIDSURFACETYPE
GDERR_LOCKEDSURFACES
GDERR_OUTOFMEMORY
If CreateSurface is called multiple times on the same instance, memory
will not be re-allocated if:
(((newwidth == oldwidth) && (newheight == oldheight)) || ((newwidth
== oldheight) && (newheight == oldwidth))).
Previous data stored in the surface will be deleted, even if the call to CGapiRGBASurface::CreateSurface failed. All data allocated by a surface object will automatically be freed when the surface object is deleted. If you manually want to free all data allocated by a surface you can call CGapiRGBASurface::CreateSurface((DWORD)0, (DWORD)0, (DWORD)0).
The width and height of the surface will be adjusted to fit the entire image. Supported image file types are PNG images with an embedded variable alpha map. PNG images are loaded with zero-memory-overhead.
When images are loaded from file, GapiDraw will use an absolute file path if pImageFile begins with "\" or "x:\". If pImageFile does not begin with "\" or "x:\", GapiDraw will use the application path of your executable file and append the image file name (e.g. if your executable is "\Program Files\Games\MyGame\MyGame.exe" and you call CreateSurface with pImageFile set to "MyPicture.png", GapiDraw will try to load the image as "\Program Files\Games\MyGame\MyPicture.png").
This method returns the width of the surface in pixels.
|
DWORD GetWidth(); |
The width of the surface in pixels. If the surface has not yet been created, the returned width will be 0.
This method returns the height of the surface in pixels.
|
DWORD GetHeight(); |
The height of the surface in pixels. If the surface has not yet been created, the returned height will be 0.
This method obtains a pointer to the internal memory buffer used by CGapiRGBASurface.
|
HRESULT GetBuffer(GDBUFFERDESC* pGDBufferDesc); |
If this method succeeds, the return value is GD_OK.
If the method fails, the return value may be one of the following return values:
GDERR_INCOMPATIBLEPRIMARY
GDERR_INVALIDPARAMS
GDERR_LOCKEDSURFACES
GDERR_NOTINITIALIZED
CGapiRGBASurface::GetBuffer is used to directly access the internal memory buffer of a surface. You can use CGapiRGBASurface::GetBuffer if you want to draw full screen video, 3D, plasma effects or if you in any other way need to set multiple pixels and cannot afford the overhead of a function call.
CGapiRGBASurface::GetBuffer will place a lock on the surface that is not be released until CGapiRGBASurface::ReleaseBuffer is called. The lock prevents other operations to use the surface until CGapiRGBASurface::ReleaseBuffer is called.
RGBA Surfaces in GapiDraw can be of 444A, 555A or 565A pixel formats (see the GapiDraw overview for details). To convert standard RGB color values to a native surface color value you can use the routines available in the file GapiDrawExtension.h.
Releases the previously locked internal memory buffer used by CGapiRGBASurface.
|
HRESULT ReleaseBuffer(); |
If this method succeeds, the return value is GD_OK.
If the method fails, the return value may be one of the following return values:
GDERR_NOTINITIALIZED
GDERR_NOTLOCKED
GDERR_DCLOCKED