PDA

View Full Version : Image size



Bidmaron
April 15th, 2009, 03:16
Is there a way to get the original, unscaled size of the graphic in an imagecontrol? I've looked at the ruleset docs and can't find such a thing. I'm interested in getting this size into a lua script.

Tenian
April 15th, 2009, 11:43
You might be able to back into it:

imagecontrol has:



function getViewpoint( )

Returns data on the current viewpoint of the user. The viewpoint is determined by the center point of the portion of image being viewed in the control as well as the used zoom level.

Return values
(number)
The X coordinate on the image acting as the center point of the viewpoint
(number)
The Y coordinate on the image acting as the center point of the viewpoint
(number)
The zoom level being used (a value of 1.0 represents 100% zoom)

And since it's a windowcontrol it should support:

function getSize( )

Get the current size of the control. The size is calculated based on the anchoring of the control and the dimensions of the containing window.

Return values
(number)
The width of the control, in pixels.
(number)
The height of the control, in pixels.

So if you take the size of the image control (from getSize) and multiply it by the zoom (from getViewpoint) the result should be the true image size....

.....I think

Foen
April 15th, 2009, 16:50
I thought about that, but I think it will just give you the size of the displayed portion of the image, not the bits that are scrolled out of view.

Bidmaron
April 16th, 2009, 00:20
That's what I believe also. We so direly need the ability to link to an outside program. We could solve so many problems if you could just invoke some outside program. I was contemplating how I might do that. What would you think about programatically updating a module that solely exists for communication with the outside world and then have a program running in the background that would check the module and notice the update. With that, it could then do the processing necessary (like determine the size of an image) and then create a module entry with the reply. I think all this would work, but I don't know how to do a polling routine within FG2 to wait for the reply from the outside program.

Tenian's technique would work if you could programatically ensure that the window was showing the entire graphic, but there is no such beast.

Tenian
April 16th, 2009, 03:17
Just out of curiosity...why do you need to know the size of the image?

Bidmaron
April 16th, 2009, 17:41
What I'd like to be able to do is take a window that has a thumbnail graphic in it and double-click the thumbnail to bring up a window showing the e tire graphic at 100%.
I had one thought that I am going to test. If I display a graphic in a window that I know is too big, I presume the zoom will be changed to fill the window. If I then set the zoom to 100% I should be able to determine either the image width or height whichever is smaller. Then I can constrain the other dimension and determine it. As a hack this will cause the window to do some rapid flashing while I figure out the image dimensions. I'll give that a try.

phantomwhale
May 7th, 2011, 10:06
Now I'm trying to do something that would like to know the size of the underlying image...

Did anyone get anywhere with this ?