Functions
Painting

Functions

BOOL CreatePaintableImage (CVD3D d3d, long lDimension, long Width, long Height, IMG &Img)
 The function creates a CVB image located in the GPU memory.
 
HRESULT D3DGetObjectDC (CVD3DOBJECT d3dObject, HDC &hDC)
 This function returns a DC to the given CVD3DOBJECT object.
 
HRESULT D3DPresentBackbuffer (CVD3D d3d)
 The function displays the actual content of the backbuffer in the window attached to CVD3D context.
 
HRESULT D3DReleaseObjectDC (CVD3DOBJECT d3dObject, HDC &hDC)
 Releases a DC to the given CVD3DOBJECT object that was allocated using D3DGetObjectDC.
 
HRESULT D3DRenderText (CVD3DOBJECT d3dObject, const char *lpText, long x, long y, COLORREF color, float fAlpha)
 This function renders a given text string to a given destination texture using a default font and a given colour and alpha value.
 
BOOL GetImageDC (IMG img, HDC &dc)
 Returns a DC to the given CVB image object.
 
BOOL ReleaseImageDC (IMG img, HDC dc)
 The function releases a DC allocated by GetImageDC.
 

Detailed Description

Function Documentation

BOOL CreatePaintableImage ( CVD3D  d3d,
long  lDimension,
long  Width,
long  Height,
IMG &  Img 
)

The function creates a CVB image located in the GPU memory.

It supports monochrome (lDimension = 1) or colour images (lDimension = 3). It's possible to get a DC to the image to use standard GDI functions to paint into the image e.g., to create synthetic images.

Attention
Reference counting is implemented using the ShareObject and ReleaseObject functions of the Image Manager. To finally free the object use ReleaseObject.
Parameters
[in]d3dThe D3D context.
[in]lDimensionThe dimension of the image (maximum value is 4 for RGBA images).
[in]WidthThe width of the image which has to be less or equal to the maximum width of the D3D context.
[in]HeightThe height of the image which has to be less or equal to the maximum height of the D3D context.
[out]ImgHandle to the newly created CVB image object.
Returns
TRUE on success, FALSE otherwise.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreate
GetImageDC
ReleaseImageDC
Sample Code:
Refer to the sample in GetImageDC.
HRESULT D3DGetObjectDC ( CVD3DOBJECT  d3dObject,
HDC &  hDC 
)

This function returns a DC to the given CVD3DOBJECT object.

Using the DC you can write destructive overlays to the image.

Attention
To release the DC call D3DReleaseObjectDC. You can only get a DC to a texture source.
Parameters
[in]d3dObjectThe source object.
[out]hDCHandle to the newly created DC.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateTextureEntrance
Sample Code in Visual C++:
// create direct3d
CVD3D m_d3d = NULL;
D3DCreate (m_cvDisp.m_hWnd, 512, 512, m_d3d);
...
...
// create GPU object
CVD3DOBJECT obj = NULL;
D3DCreateTextureEntrance (m_d3d, 256, 256, TCF_XRGB, obj);
// create an image around the texture
IMG img = NULL;
// get the DC
HDC dc = NULL;
D3DGetObjectDC (obj, dc);
// create pen
HPEN hPen = CreatePen (PS_SOLID, 10, RGB(255,255,255));
// select pen
HPEN hOldPen = (HPEN)SelectObject (dc, hPen);
// create a brush
HBRUSH hBrush = CreateSolidBrush (RGB(255,255,255));
// select brush
HBRUSH hOldBrush = (HBRUSH)SelectObject (dc, hBrush);
// draw circle
Ellipse (dc, 50, 50, 128, 128);
// restore pen
SelectObject (dc, hOldPen);
DeleteObject (hPen);
// restore brush
SelectObject (dc, hOldBrush);
DeleteObject (hBrush);
// release the dc
// display the image
m_cvDisp.SetImage ((long)img);
// release the image
ReleaseImage (img);
...
...
ReleaseObject (obj);
ReleaseObject (m_d3d);
HRESULT D3DPresentBackbuffer ( CVD3D  d3d)

The function displays the actual content of the backbuffer in the window attached to CVD3D context.

The backbuffer always represents the result of the last render operation. The backbuffer will be stretched to match the width and the height of the window. To preserve the aspect ratio of the original image make sure that the aspect ratio of the windows matches the aspect ratio of the image.

Parameters
[in]d3dHandle to the object to be processed.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
Glossary
D3DRender
D3DRenderText
D3DBlt
D3DBltRect
D3DCreate
Examples:
Visual C++ - VC Bayer To RGB Conversion (GPU Display) Example
HRESULT D3DReleaseObjectDC ( CVD3DOBJECT  d3dObject,
HDC &  hDC 
)

Releases a DC to the given CVD3DOBJECT object that was allocated using D3DGetObjectDC.

Using the DC you can write destructive overlays to the image. You can only get a DC to a texture source.

Parameters
[in]d3dObjectThe source object.
[in]hDCThe DC to be released.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateTextureEntrance
Sample Code:
Refer to the sample in D3DGetObjectDC.
HRESULT D3DRenderText ( CVD3DOBJECT  d3dObject,
const char *  lpText,
long  x,
long  y,
COLORREF  color,
float  fAlpha 
)

This function renders a given text string to a given destination texture using a default font and a given colour and alpha value.

Attention
As rendering is done by the graphics driver the capability to render text to a defined target varies from driver to driver. The following table lists the capabilities of a GeForce 9800 graphics card:

RenderText to Backbufferok
RenderText to SurfaceEntrancenot applicable
RenderText to Surfacenot applicable
RenderText to TextureEntrancenot applicable
RenderText to Texture ok ok
Parameters
[in]d3dObjectThe texture.
[in]lpTextThe text to be rendered.
[in]xX-position of the string in the texture specified by its top, left position in pixel.
[in]yY-position of the string in the texture specified by its top, left position in pixel.
[in]colorRGB colour to be used.
[in]fAlphaThe alpha value to be used. A value of 1.0 indicates no transparency of the overlay. A value of 0.5 will end up in 50% of the colour value of the overlay plus 50% of the colour value of the texture.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
Glossary
D3DCreateTextureEntrance
D3DCreateTexture
D3DRender
D3DIsRenderSource
D3DIsRenderTarget
D3DCreateShaderFromFile
D3DCreateShaderFromString
Examples:
Delphi - Delphi BayerToRGB Example
Visual Basic .Net - VB.NET GPU Example
Visual C++ - VC GPU Demo
BOOL GetImageDC ( IMG  img,
HDC &  dc 
)

Returns a DC to the given CVB image object.

Using the DC you can write destructive overlays to the image.

Attention
To release the DC call ReleaseImageDC.
Parameters
[in]imgThe source image.
[out]dcHandle to the newly created DC.
Returns
TRUE on success, FALSE otherwise.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreate
CreatePaintableImage
ReleaseImageDC
Sample Code in Visual C++:
// create direct3d
CVD3D m_d3d = NULL;
D3DCreate (m_cvDisp.m_hWnd, 512, 512, m_d3d);
...
...
// create GPU image
IMG img = NULL;
CreatePaintableImage (m_d3d, 3, 256, 256, img);
if !(!IsImage (img))
return;
// get the DC
HDC dc = NULL;
GetImageDC (img, dc);
// create pen
HPEN hPen = CreatePen (PS_SOLID, 10, RGB(255,255,255));
// select pen
HPEN hOldPen = (HPEN)SelectObject (dc, hPen);
// create a brush
HBRUSH hBrush = CreateSolidBrush (RGB(255,255,255));
// select brush
HBRUSH hOldBrush = (HBRUSH)SelectObject (dc, hBrush);
// draw circle
Ellipse (dc, 50, 50, 128, 128);
// restore pen
SelectObject (dc, hOldPen);
DeleteObject (hPen);
// restore brush
SelectObject (dc, hOldBrush);
DeleteObject (hBrush);
// release the dc
D3DReleaseImageDC (img, dc);
// display the image
m_cvDisp.SetImage ((long)img);
// release the image
ReleaseImage (img);
...
...
ReleaseObject (m_d3d);
BOOL ReleaseImageDC ( IMG  img,
HDC  dc 
)

The function releases a DC allocated by GetImageDC.

Parameters
[in]imgThe image to be used.
[in]dcThe DC to be released.
Returns
TRUE on success, FALSE otherwise.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreate
CreatePaintableImage
Sample Code:
Refer to the sample in GetImageDC.