Functions
Transferring Images

Functions

HRESULT D3DCreateImageFromMirror (CVD3DMIRROR d3dMirror, long lChannel, IMG &Img)
 This function creates a CVB image around the given CVD3DMIRROR object.
 
HRESULT D3DCreateImageFromObject (CVD3DOBJECT d3dObject, long lChannel, IMG &Img)
 This function creates a CVB image around the given CVD3DOBJECT object.
 
HRESULT D3DCreateMirror (CVD3D d3d, DWORD dwWidth, DWORD dwHeight, TColorFormat tcf, CVD3DMIRROR &d3dMirror)
 Creates a mirror to transfer an image back to the host using D3DUpdate after it has been rendered.
 
HRESULT D3DGet3DObject (IMG img, OBJ &pObj)
 This function returns the CVD3DOBJECT attached to given image.
 
HRESULT D3DGetChannel (IMG img, long &lChannel)
 This function returns the channel currently being used by a monochrome CVB image that was created around a colour GPU image.
 
HRESULT D3DGetMirrorInfo (CVD3DMIRROR d3dMirror, DWORD &dwWidth, DWORD &dwHeight, TColorFormat &tcf)
 Returns information about the given CVD3DMIRROR object.
 
BOOL D3DIsIMG (OBJ d3dImg)
 This function checks if the given handle points to a CVB IMG type.
 
BOOL D3DIsLocked (IMG img)
 This function returns the current locking state of the given image.
 
BOOL D3DIsMirror (OBJ d3dMirror)
 This function checks if the given handle points to a CVD3DMIRROR type or not.
 
HRESULT D3DLock (IMG img)
 This function locks the frame buffer of the given image that was created around a GPU object.
 
HRESULT D3DSetChannel (IMG img, long lChannel)
 This function sets the channel to be used by a monochrome CVB image that was created around a colour GPU image.
 
HRESULT D3DUnlock (IMG img)
 This function unlocks the fame buffer of the given image that was created around a GPU object and that was locked using D3DLock.
 
HRESULT D3DUpdate (CVD3DMIRROR d3dMirror)
 Updates the given mirror with the data of the last rendering step.
 
HRESULT D3DWriteImageToObject (IMG Img, long lPlane, CVD3DOBJECT d3dObject, long lChannel)
 This function writes the data of the given CVB image plane to the given CVD3DOBJECT.
 

Detailed Description

Function Documentation

HRESULT D3DCreateImageFromMirror ( CVD3DMIRROR  d3dMirror,
long  lChannel,
IMG &  Img 
)

This function creates a CVB image around the given CVD3DMIRROR object.

The channel to be used may be specified using lChannel. Use -1 to select the default which is a mono CVB image for a mono CVD3DOBJECT and a colour CVB image for colour CVD3DOBJECT objects.

Attention
The image memory is not copied. It can be updated using D3DUpdate. Reference counting is implemented using the ShareObject and ReleaseObject functions of the Image Manager. To finally free the object use ReleaseObject.
Parameters
[in]d3dMirrorThe source mirror object.
[in]lChannelThe channel to be used or -1 for a colour image, respectively, to use the default channel.
[out]ImgHandle to the newly created CVB image.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateMirror
D3DIsMirror
D3DUpdate
D3DRender
Examples:
Delphi - Delphi BayerToRGB Example
Visual Basic .Net - VB.NET GPU Example
Visual C++ - VC GPU Demo
Sample Code in Visual C++:
CVD3DOBJECT obj = NULL;
IMG imgSrc = NULL;
IMG img = NULL;
if (!D3DIsD3D (m_D3D))
{
AfxMessageBox ("D3d context not available");
return;
}
LoadImageFile ("c:\\CVB\\tutorial\\clara.bmp", imgSrc);
if (!IsImage (imgSrc))
AfxMessageBox ("unable to load image");
D3DCreateSurfaceEntrance (m_D3D, m_cvImg.GetImageWidth(), m_cvImg.GetImageHeight(), TCF_XRGB, obj);
if (!D3DIsObject (obj))
AfxMessageBox ("unable to create object");
D3DCreateImageFromObject (obj, -1, img);
if (!IsImage (img))
AfxMessageBox ("unable to create image");
TArea area;
MaxImageArea(img, area);
CopyImageArea (imgSrc, img, 0, 0, area, 0, 0);
CopyImageArea (imgSrc, img, 0, 1, area, 0, 0);;
CopyImageArea (imgSrc, img, 0, 2, area, 0, 0);
m_cvDisp.SetImage ((long)img);
// ...
// do not forget to release imgSrc, obj and img
HRESULT D3DCreateImageFromObject ( CVD3DOBJECT  d3dObject,
long  lChannel,
IMG &  Img 
)

This function creates a CVB image around the given CVD3DOBJECT object.

The channel to be used may be specified using lChannel. Use -1 to select the default which is a mono CVB image for a mono CVD3DOBJECT and a colour CVB image for colour CVD3DOBJECT objects.

Attention
The image memory is not copied, it might be located within the GPU frame buffer. It's possible to create multiple CVB images around the given object e.g., to view the red, green, and blue channel as monochrome images. Reference counting is implemented using the ShareObject and ReleaseObject functions of the Image Manager. To finally free the object use ReleaseObject.
Parameters
[in]d3dObjectThe source object.
[in]lChannelThe channel to be used or -1 for a colour image, respectively, to use the default channel.
[out]ImgHandle to the newly created CVB image.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateTextureEntrance
D3DCreateTexture
D3DCreateSurfaceEntrance
D3DCreateSurface
Sample Code in Visual C++:
CVD3DOBJECT obj = NULL;
IMG imgSrc = NULL;
IMG img = NULL;
if (!D3DIsD3D (m_D3D))
{
AfxMessageBox ("D3d context not available");
return;
}
LoadImageFile ("c:\\CVB\\tutorial\\clara.bmp", imgSrc);
if (!IsImage (imgSrc))
AfxMessageBox ("unable to load image");
D3DCreateSurfaceEntrance (m_D3D, m_cvImg.GetImageWidth(), m_cvImg.GetImageHeight(), TCF_XRGB, obj);
if (!D3DIsObject (obj))
AfxMessageBox ("unable to create object");
D3DCreateImageFromObject (obj, -1, img);
if (!IsImage (img))
AfxMessageBox ("unable to create image");
TArea area;
MaxImageArea(img, area);
CopyImageArea (imgSrc, img, 0, 0, area, 0, 0);
CopyImageArea (imgSrc, img, 0, 1, area, 0, 0);;
CopyImageArea (imgSrc, img, 0, 2, area, 0, 0);
m_cvDisp.SetImage ((long)img);
...
// do not forget to release imgSrc, obj and img
HRESULT D3DCreateMirror ( CVD3D  d3d,
DWORD  dwWidth,
DWORD  dwHeight,
TColorFormat  tcf,
CVD3DMIRROR d3dMirror 
)

Creates a mirror to transfer an image back to the host using D3DUpdate after it has been rendered.

Use D3DCreateImageFromMirror to create a standard CVB image attached to the mirror. You can create multiple CVB images attached to one particular mirror to implement different views of the mirror e.g., three mono CVB images to view the red, green, and blue channel of a mirror.

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]dwWidthThe width of the image which has to be less or equal to the maximum width of the D3D context.
[in]dwHeightThe height of the image which has to be less or equal to the maximum height of the D3D context.
[in]tcfThe colour format of the image. See TColorFormat for possible colour formats.
[out]d3dMirrorHandle to the newly created CVD3DMIRROR object.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DGetMirrorInfo
D3DCreate
D3DCreateTextureEntrance
D3DCreateTexture
D3DCreateImageFromMirror
D3DUpdate
Examples:
Delphi - Delphi BayerToRGB Example
Visual Basic .Net - VB.NET GPU Example
Visual C++ - VC GPU Demo
HRESULT D3DGet3DObject ( IMG  img,
OBJ &  pObj 
)

This function returns the CVD3DOBJECT attached to given image.

Parameters
[in]imgHandle to the image.
[out]pObjHandle to the CVD3DOBJECT object attached to the given image or NULL if no CVD3DOBJECT is attached to this image.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateImageFromObject
D3DCreateImageFromMirror
HRESULT D3DGetChannel ( IMG  img,
long &  lChannel 
)

This function returns the channel currently being used by a monochrome CVB image that was created around a colour GPU image.

The channel can be changed by D3DSetChannel.

Attention
Supported only by monochrome images.
Parameters
[in]imgHandle to the image.
[out]lChannelChannel currently being used by this image.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateImageFromObject
D3DCreateImageFromMirror
D3DSetChannel
Examples:
Visual C++ - VC Processing 3 Mono Images Parallel Example
Sample Code:
Refer to D3DSetChannel.
HRESULT D3DGetMirrorInfo ( CVD3DMIRROR  d3dMirror,
DWORD &  dwWidth,
DWORD &  dwHeight,
TColorFormat tcf 
)

Returns information about the given CVD3DMIRROR object.

Parameters
[in]d3dMirrorThe CVD3DMIRROR object.
[out]dwWidthWidth of the mirror image.
[out]dwHeightHeight of the mirror image.
[out]tcfColour format of the mirror image. See TColorFormat for possible values.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateMirror
D3DCreateTextureEntrance
D3DCreateTexture
D3DCreateSurfaceEntrance
D3DCreateSurface
D3DCreateImageFromMirror
D3DUpdate
Examples:
Delphi - Delphi BayerToRGB Example
Visual Basic .Net - VB.NET GPU Example
Visual C++ - VC GPU Demo
BOOL D3DIsIMG ( OBJ  d3dImg)

This function checks if the given handle points to a CVB IMG type.

Typically you will use #3DCreateImageFromObject or D3DCreateImageFromMirror to create CVB images around GPU image objects.

Parameters
[in]d3dImgHandle to the object to be processed.
Returns
TRUE if it is a image object, FALSE otherwise.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateImageFromObject
D3DCreateImageFromMirror
BOOL D3DIsLocked ( IMG  img)

This function returns the current locking state of the given image.

Parameters
[in]imgHandle to the object to be processed.
Returns
TRUE if the image is currently locked, FALSE otherwise.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateImageFromObject
D3DCreateImageFromMirror
D3DLock
D3DUnlock
BOOL D3DIsMirror ( OBJ  d3dMirror)

This function checks if the given handle points to a CVD3DMIRROR type or not.

Parameters
[in]d3dMirrorHandle to the object to be processed.
Returns
TRUE if it is a CVD3DMIRROR object, FALSE otherwise.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateMirror
Examples:
Delphi - Delphi BayerToRGB Example
Visual Basic .Net - VB.NET GPU Example
Visual C++ - VC GPU Demo
HRESULT D3DLock ( IMG  img)

This function locks the frame buffer of the given image that was created around a GPU object.

The buffer of a CVD3DOBJECT can be accessed by the host OR the pixel shader. By calling this function the host gets access to the image data. The pixel shader can't access the image data before D3DUnlock is called. Normally locking and unlocking is done internally to ensure accessibility of the GPU image at any time.

Parameters
[in]imgHandle to the image to be processed.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateImageFromObject
D3DCreateImageFromMirror
D3DUnlock
D3DIsLocked
HRESULT D3DSetChannel ( IMG  img,
long  lChannel 
)

This function sets the channel to be used by a monochrome CVB image that was created around a colour GPU image.

Using this function you can access individual channels of a GPU colour image via a monochrome CVB image. E.g., to process three monochrome images in one pixel shader program like shown in the VC Processing 3 Mono Images Parallel Example example.

Attention
Supported only by monochrome images.
Parameters
[in]imgHandle to the image to be used.
[in]lChannelChannel to be used by this image in the range from 0 to 3.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateImageFromObject
D3DCreateImageFromMirror
D3DWriteImageToObject
D3DGetChannel
Sample Code in Visual C++:
#define MAXINDEX 2
...
// create a destination texture
D3DCreateTexture (m_D3D, dwWidth, dwHeight, TCF_XRGB, m_D3DTextureDst);
if (!D3DIsObject (m_D3DTextureDst))
{
AfxMessageBox ("Unable to create dst texture");
exit (-1);
}
// create a colour mirror image
D3DCreateMirror (m_D3D, dwWidth, dwHeight, TCF_XRGB, m_D3DMirror);
if (!D3DIsMirror (m_D3DMirror))
{
AfxMessageBox ("Unable to create mirror");
exit (-1);
}
// create a mono cvb image of the mirror
D3DCreateImageFromMirror (m_D3DMirror, 0, m_ImgDst);
if (!IsImage (m_ImgDst))
{
AfxMessageBox ("Unable to create mono mirror IMG");
exit (-1);
}
// create an additional RGB image of the mirror
D3DCreateImageFromMirror (m_D3DMirror, -1, m_ImgDstRGB);
if (!IsImage (m_ImgDstRGB))
{
AfxMessageBox ("Unable to create mono mirror IMG");
exit (-1);
}
...
...
void CVC3MonoDlg::ImageSnapedCvimagectrl1()
{
...
// refresh display
if (m_bRefreshSrc)
m_cvDisp.Refresh();
// copy image to src texture
D3DWriteImageToObject (m_ImgSrc, 0, m_D3DTextureSrc, m_ImgIndex);
// if all images are transfered render it to the dst texture
if (m_ImgIndex == MAXINDEX)
{
D3DRender (m_D3DTextureSrc, m_D3DTextureDst, m_D3DActiveShader);
// update image data
D3DUpdate (m_D3DMirror);
}
// inc. index
m_ImgIndex++;
if (m_ImgIndex > MAXINDEX)
m_ImgIndex = 0;
// switch the index
D3DSetChannel (m_ImgDst, m_ImgIndex);
// and refresh the display
if (m_bRefreshD3D)
m_cvDispD3D.Refresh();
// and refresh the RGB display
if (m_bRefreshD3DRGB)
m_cvDispD3DRGB.Refresh();
...
}
}
Examples:
Visual C++ - VC Processing 3 Mono Images Parallel Example
HRESULT D3DUnlock ( IMG  img)

This function unlocks the fame buffer of the given image that was created around a GPU object and that was locked using D3DLock.

The buffer of a CVD3DOBJECT can be accessed by the host OR the pixel shader. By calling this function the pixel shader gets access to the image data. Normally locking and unlocking is done internally to ensure accessibility of the GPU image at any time.

Parameters
[in]imgHandle to the image to be processed.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateImageFromObject
D3DCreateImageFromMirror
D3DLock
D3DIsLocked
HRESULT D3DUpdate ( CVD3DMIRROR  d3dMirror)

Updates the given mirror with the data of the last rendering step.

The data is transfered back to the host memory and the CVB image attached to the mirror will be updated as well.

Parameters
[in]d3dMirrorThe source mirror object to be updated.
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateMirror
D3DIsMirror
D3DCreateImageFromMirror
D3DRender
Examples:
Delphi - Delphi BayerToRGB Example
Visual Basic .Net - VB.NET GPU Example
Visual C++ - VC GPU Demo
HRESULT D3DWriteImageToObject ( IMG  Img,
long  lPlane,
CVD3DOBJECT  d3dObject,
long  lChannel 
)

This function writes the data of the given CVB image plane to the given CVD3DOBJECT.

The plane index of the CVB image to be written can be specified as well as channel of the CVD3DOBJECT. A value of -1 for the plane and/or the channel writes the data from/to the default plane/channel. For a monochrome image the default writes a monochrome plane to all channels of the CVD3DOBJECT. For colour images the RGB planes will be written to the red, green, and blue channel.

Attention
Note that you can write the image only to surface or texture sources. To use >8 to 16 Bit CVB images you need to create the CVD3DOBJECT in TCF_GR16 colour mode.
Parameters
[in]ImgThe source image to be written.
[in]lPlaneThe source image plane or -1 to select the default (all planes for a colour image or plane 0 for a monochrome image).
[in]d3dObjectThe destination to be written.
[in]lChannelThe destination channel (RGBA) to be written or -1 to select the default (RGB for a colour image or the red channel for monochrome images).
Returns
0 if no error occurred, otherwise a value != 0 indicates the error code.
Supported platforms:
Win32
Win64
Related Topics:
D3DCreateTextureEntrance
D3DCreateTexture
D3DCreateSurfaceEntrance
D3DCreateSurface
Examples:
Delphi - Delphi BayerToRGB Example
Visual Basic .Net - VB.NET GPU Example
Visual C++ - VC GPU Demo
Sample Code:
Refer to sample in D3DCreateImageFromObject.