LabWindows/CVI

Content Type
Programming Language
Current manual
Table of Contents

Programming with Picture Controls

Programming with Picture Controls

This topic describes how to complete the following tasks programmatically.

Creating a Picture Control

Call NewCtrl to create a picture control.

int picImage, picBmp;

picImage = NewCtrl (panelHandle, CTRL_PICTURE_LS, "From Image File", 25, 20);

picBmp = NewCtrl (panelHandle, CTRL_PICTURE_LS, "From Bitmap", 25, 125);

Displaying an Image

Initially, the picture control is empty. You can display images from image files or from bitmaps.

int bitmapID;

/* Display an image from an image file */
DisplayImageFile (panelHandle, picImage, "c:\temp\cvi.ico");

/* Display an image from a bitmap */
GetBitmapFromFile ("c:\temp\cvi.ico", &bitmapID);
SetCtrlBitmap (panelHandle, picBmp, 0, bitmapID);
...
DiscardBitmap (bitmapID);

Copying the Bitmap from the Picture Control

Copy the bitmap from the picture control into memory.

int bitmapID;

GetCtrlBitmap (panelHandle, picBmp, 0, &bitmapID);

Deleting an Image

DeleteImage (panelHandle, picBmp);

Specifying the Placement and Sizing of the Image

DisplayImageFile (panelHandle, PANEL_PICTURE, "c:\temp\cvi.ico");
SetCtrlAttribute (panelHandle, PANEL_PICTURE, ATTR_FIT_MODE, VAL_SIZE_TO_PICTURE);
DisplayImageFile (panelHandle, PANEL_PICTURE_2, "c:\temp\cvi.ico");
SetCtrlAttribute (panelHandle, PANEL_PICTURE_2, ATTR_FIT_MODE, VAL_SIZE_TO_IMAGE);
DisplayImageFile (panelHandle, PANEL_PICTURE_3, "c:\temp\cvi.ico");
SetCtrlAttribute (panelHandle, PANEL_PICTURE_3, ATTR_FIT_MODE, VAL_PICT_CORNER);
DisplayImageFile (panelHandle, PANEL_PICTURE_4, "c:\temp\cvi.ico");
SetCtrlAttribute (panelHandle, PANEL_PICTURE_4, ATTR_FIT_MODE, VAL_PICT_CENTER);
DisplayImageFile (panelHandle, PANEL_PICTURE_5, "c:\temp\cvi.ico");
SetCtrlAttribute (panelHandle, PANEL_PICTURE_5, ATTR_FIT_MODE, VAL_PICT_TILE);

Getting and Setting Information about a Bitmap

To obtain information about a bitmap, call the GetBitmapDataEx.

unsigned char *mask, *bits, *alpha;
int height, width, pixelDepth, bytesPerRow, *colorTable;

AllocBitmapDataEx (bitmapID, &colorTable, &bits, &mask, &alpha);
GetBitmapDataEx (bitmapID, &bytesPerRow, &pixelDepth, &width, &height, colorTable, bits, mask, alpha);

To set information about a bitmap, call SetBitmapDataEx.

Related Topics

Programming with Controls

Picture Control Functions

Was this information helpful?

Help us improve your future ni.com experience.

What are you trying to do?

Submit