Example Code

Save image from a picture control or load a saved image into a picture control

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview

This code demonstrates how to save the content of a picture control on hard disk as image (*.png, *.jpg, ...) or how to load an image into a picture control.

 

Description

LabVIEW provides 6 VIs to allow reading and writing image files - each one pertains to a specific format:

graphics1.png

I felt that it would be useful to have a VI which figures out which image format is given, and use the correct VI.

The 2 VIs here do just that - using the Get File Extension VI, the correct read or write VI is selected to open or save the file. The VI also automatically promps the user for a path if none is provided when calling the VI.

 

Requirements

 Software

  • LabVIEW Base Development System 2012 (or compatible)
  • If running in a Real-Time context, you will need the LabVIEW Real-Time Module 2012 (or compatible)

 Hardware

  • No hardware is necessary to use this example VI

 

 Steps to Implement or Execute Code

  1. Download the attached VIs
  2. Add the VIs to your application. Call the Write Image File VI to store the content of an image control on disk ot the Read Image File VI to load the content of a file as image datatype.

 

Additional Information or References

Write Image File LV2012 NIVerified - Front Panel.png

 

Write Image File LV2012 NIVerified - Block Diagram.png

 

**The code for this example has been edited to meet the new Community Example Style Guidelines. The edited copy is marked with the text ‘NIVerified’. Read here for more information about the new Example Guidelines and Community Platform.**  

Al B.
Staff Software Engineer - TestStand
CTA/CLD

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.