From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the original size of an image in a picture control

Hello all,

how do I get the original size of the image contained within a picture control (which has been resized) ?

I thought I could simply do:

 

SetCtrlAttribute(pnl, ctrl, ATTR_FIT_MODE, VAL_SIZE_TO_IMAGE);
GetCtrlAttribute(pnl, ctrl, ATTR_WIDTH,  &W);
GetCtrlAttribute(pnl, ctrl, ATTR_HEIGHT, &H);

But I still get the size of the control, not the image. Even if I call ProcessDrawEvents in between.

0 Kudos
Message 1 of 5
(2,936 Views)

You may be running into this trouble if your picture controle is overlapped or hidden while you resize it: see Luis explanation in this discussion.



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
(2,921 Views)

Hmmm, yes, that's the situation described: my control is behind a partially transparent other control (it's a background image which must be positionned precisely).

I read the thread you mention so I tried the following but it still doesn't work:

	SetCtrlAttribute(pnl, ctrl, ATTR_ZPLANE_POSITION, 0);
	SetCtrlAttribute(pnl, ctrl, ATTR_FIT_MODE, VAL_SIZE_TO_IMAGE);
	ProcessDrawEvents ();
	GetCtrlAttribute(pnl, ctrl, ATTR_WIDTH,  &P_W);
	GetCtrlAttribute(pnl, ctrl, ATTR_HEIGHT, &P_H);
	SetCtrlAttribute(pnl, ctrl, ATTR_FIT_MODE, VAL_SIZE_TO_PICTURE);
	SetCtrlAttribute(pnl, ctrl, ATTR_ZPLANE_POSITION, 255);

 

0 Kudos
Message 3 of 5
(2,917 Views)

Well, the strange thing is that I don't need to play with the zplane position to have the correct dimensions of the control! I made a sample project for the original poster of the discussion I linked: now I have modified it placing a graph on top of the picture control but I get the correct height and width with no additional calls than load the picture and get the corresponding attributes!

I am attaching the project so you can play with it and see if and how our codes differ: maybe differences can help us understand what's happening.



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 4 of 5
(2,905 Views)

Thanks. Your code works as expected. I modified it to look like mine (same kind of controls) and it still works. Mine doesn't. I'm gonna sleep on it...

0 Kudos
Message 5 of 5
(2,899 Views)