|| 3.35 out of 5
How Can I Programmatically Insert An Image Into A Picture Control and Resize The Control?
LabVIEW Development Systems>>LabVIEW Full Development System
Primary Software Version:
Primary Software Fixed Version:
I want to insert an image into a picture control in LabVIEW and match the size of the image and control programmatically. How can this be done without manually resizing the picture on the front panel?
Copying and pasting a picture from the clipboard or dragging a picture into the front panel simply makes the picture a front panel object decoration. The process to correctly insert an image into a picture control and programmatically resize it is:
- Insert a 2D Picture control on the front panel from Modern»Graph»Control in the Controls Palette
- Go to the block diagram and place the appropriate read picture file VI from Programming»Graphics and Sounds»Graphics Formats in the Functions Palette. Depending on the type of picture, choose the appropriate read picture file VI:
||Read Picture File VI
||Read BMP File.vi
||Read JPEG File.vi
||Read PNG File.vi
- On that read picture file VI, right-click on the path to picture file input (ex: path to JPEG file) and select Create»Control
- Place a Draw Flattened Pixmap.vi and a Empty Picture.vi on the block diagram from Programming»Graphics and Sounds»Picture Functions in the Functions Palette
- Place an Unbundle By Name function on the block diagram from Cluster & Variant in the Functions Palette and wire it to the output of the read picture file VI
- Expand the Unbundle By Name to have two outputs and choose the Rectangle»right for the top output and Rectangle»bottom for the bottom output.
- Place a Bundle VI next to the Unbundle By Name
- Right-click on the Picture Control indicator and select Create»Property Node»Draw Area Size to place the area property node onto the block diagram
- Right click on the property node and select Change to Write
- Wire the functions as shown in the image below
An example program called Insert Image.vi
is attached that performs this operation.
Related Links: LabVIEW 2013 Help: Read BMP FileLabVIEW 2013 Help: Read JPEG FileLabVIEW 2013 Help: Read PNG File
Insert Image Snippet.png