This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

Import Pictures into a LabVIEW Picture Control

Updated Dec 13, 2023

Reported In

Software

  • LabVIEW

Issue Details

Sometimes it's necessary to import an image on the Front Panel, for example if you would like to have a logo. To do that you have to use a Picture Control. Picture Control is a LabVIEW control that allows you to visualize an image on the Front Panel. Unfortunatly you cannot copy and paste images into a Picture Control, so you have to do this programmatically. If you copy and paste a picture from the clipboard or drag and drop a picture into the Front Panel simply makes the picture a Front Panel object decoration. In this document you'll learn how to import pictures into a picture control and resize the control for fit it to the imported image.
 

Solution

The process to correctly insert an image into a picture control and programmatically resize 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, as shown in Figure 1.     

Figure 1 - Types of Read Picture File VI
                                                                                                     
  1. On that Read Picture File VI, right-click on the path to picture file input (ex: path to JPEG file) and select Create»Control.
  2. 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.
  3. 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.
  4. Expand the Unbundle By Name to have four outputs and choose the Rectangle»right for the top output, Rectangle»bottom for the bottom output, Rectangle»right for the right output and Rectangle»left for the left output.
  5. Place a Bundle function next to the Unbundle By Name.
  6. 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.
  7. Right click on the property node and select Change to Write.
  8. Wire the functions as shown in LabVIEW snipped.
  9. The final Block Diagram should be as the Figure 2 below:
 

Figure 2 - LabVIEW VI Snipped