LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Load File onto Canvas

Greetings,

 

I am trying to load a canvas control programatically with a user-selected file,

I assume that there is a way to do this because I can do a Load Image from the control editor and that works.

 

It seems that there is a function call to do this that I just cannot find.

I thought that it would be SetCtrlAttribute(panel, ctl, ATTR_IMAGE_FILE, fileName);

But when I do that I get the error:

 

NON-FATAL RUN-TIME ERROR:   "Test.c", line 55, col 18, thread id 0x000000C0:   Library function error (return value == -46 [0xffffffd2]). The attribute passed is not valid.

 

The definition of fileName is:

char fileName[500];  and that is retrieved from a FileSelectPopup.

I am assuming that IMAGE_FILE is not a valid attribute for a canvas control.

 

Any help is appreciated.

THanks

 

0 Kudos
Message 1 of 5
(3,232 Views)

To draw an image onto a canvas control you can use CanvasDrawBitmap function, passing in the handle of a bitmap image in memory: refer to the online help for some guidance on function parameters.

In case of doubts on some control it's a good habit to make reference to the online help: right click on the control in the UIR editor and select Control Help: you'll see a page with links to control attributes, functions, events that apply to it and a general page with details on programming on that control. This procedure is valid for every control CVI offers you and is a powerful resource to use: the links I added to this post show the corresponding help pages for the canvas control.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(3,229 Views)

Thanks for the feedback and I have seen posts related to using a bitmap.

However, since the Load Image button will accept a .JPG file for display, it seems to me that I should be able to just load an image.

 

Is there not a direct way to just load a file?

 

Jacob

 

0 Kudos
Message 3 of 5
(3,220 Views)

You can combine the two functions GetBitmapFromFile and CanvasDrawBitmap

0 Kudos
Message 4 of 5
(3,213 Views)

Be aware that "bitmap" here is not a synonim of "BMP file": GetCtrlBitmap can load image files in several formats, including .JPG



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 5
(3,211 Views)