Example Code

Load Centered Image

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.

    Programming Language

  • LabVIEW G

Code and Documents

Attachment

Description

Demonstrates how to use the picture and picture support functions to center and scale an image file in a picture control.

 

This might be useful to load one or more images for display in a dialog when the image files are of different sizes.

 

This example uses a file as input, but you could generalize it to accept image data and load other file types using something like G-Image ( https://github.com/dataflowg/g-image )

 

blobid1743172017328.png

 

How to Use

Provide a path to a supported LabVIEW image type ( BMP, JPG or PNG ).  Test with an example file from examples\Graphics and Sound\2D Picture Control\images\

If a picture refnum is provided, the control draw area properties will be read and the resulting image loaded into the control.

Optional inputs provided for using an 8 bit color table (jpg) and Transparency Thres (png).

 

Additional Information

I created this for a dialog box that I use for prompting an operator to perform multiple steps. I'm sharing it after commenting on Brian Powell's blog:

https://stravaro.com/2020/01/oauth2-part-2/#comment-144

( Saved for LabVIEW 2019 )

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

Contributors