Programmatically Insert An Image Into A Picture Control and Resize The Control

Updated Jan 26, 2018

Reported In

Software

  • LabVIEW

Issue Details

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?

Solution

Solution: 
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:

 
File TypeRead Picture File VI
.bmpRead BMP File.vi
.jpegRead JPEG File.vi
.pngRead PNG File.vi
 
  1. Insert a 2D Picture control on the front panel from Modern»Graph»Control in the Controls Palette
  2. 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:
  3. On that read picture file VI, right-click on the path to picture file input (ex: path to JPEG file) and select Create»Control
  4. 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
  5. 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
  6. 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.
  7. Place a Bundle VI next to the Unbundle By Name
  8. Right-click on the Picture Control indicator and select Create»Property Node»Draw Area Sizeto place the area property node onto the block diagram
  9. Right click on the property node and select Change to Write
  10. Wire the functions as shown in the image below

WAS THIS ARTICLE HELPFUL?

Not Helpful