PDA

View Full Version : getImageSize() possible w/o loading an image?



celestian
July 19th, 2018, 04:07
If I know the image node (say image.id-00001) is there anyway to get the image size of the bitmap in that node?

I'm having a hard time figuring out how to do it.

Bidmaron
July 19th, 2018, 05:07
OK. I haven't tried this but I think it should work.
Use a tiny image control somewhere on a window (it could probably even be invisible).
in 3.3.6, change the image file name to the filename of the image node (with the new getValue return values for your image you want to know size of and then using setVAlue for the imageControl's node to change the filename to the image you are querying [also a new 3.3.6 feature - see the question I asked MW yesterday or day before in the Laboratory thread.).
Query the control using getImageSize (i.e. myControl.getImageSize(), where myControl is an imageControl)

Moon Wizard
July 19th, 2018, 07:29
We just chatted on Discord about this. I ended up suggesting something similar. (i.e. when you want to get the image size; create a simple window with only an imagecontrol, read the size, dispose of the window.)

I was thinking I might be able to just output the information if available already. However, the image size information is not available until the image is actually loaded; and the image is not loaded until it is needed (i.e. displayed in a control). Otherwise, load times would be ten times as long for data modules and campaigns.

Regards,
JPG

celestian
July 19th, 2018, 16:59
Yeap, I was hoping to do this w/o loading but no API hooks to directly interact with the file so I'll load it up and see how it works.

Thanks for the tips.