Academic Company Events Community Support Solutions Products & Services Contact NI MyNI
19 ratings:
 3.52 out of 5   

How Can I Programmatically Insert An Image Into A Picture Control and Resize The Control?

Primary Software: LabVIEW Development Systems>>LabVIEW Full Development System
Primary Software Version: 8.2
Primary Software Fixed Version: N/A
Secondary Software: N/A

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:

  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. File Type Read Picture File VI
    .bmp Read BMP
    .jpeg Read JPEG
    .png Read PNG

  4. On that read picture file VI, right-click on the path to picture file input (ex: path to JPEG file) and select Create»Control
  5. Place a Draw Flattened and a Empty on the block diagram from Programming»Graphics and Sounds»Picture Functions in the Functions Palette
  6. 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
  7. 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.
  8. Place a Bundle VI next to the Unbundle By Name
  9. 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
  10. Right click on the property node and select Change to Write
  11. Wire the functions as shown in the image below

An example program called Insert is attached that performs this operation.

Related Links:
LabVIEW 2013 Help: Read BMP File
LabVIEW 2013 Help: Read JPEG File
LabVIEW 2013 Help: Read PNG File


Insert Image Snippet.png

Insert Image.viInsert

Report Date: 09/22/2000
Last Updated: 01/21/2014
Document ID: 21L86HLI

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit