Loadimage() size arguments not working

Using Script.Loadimage('button_alpha.png', 10, 10, true); to try and size the image in a script dialog does not work. (the alpha argument is working by the way)

here is script (under construction), the Loadimage() is at line 125 (VSCode, tabs at 4 spaces)

Text controls.opusscriptinstall (100.5 KB)

I've clarified what the width and height arguments do in the docs:

If width and height are not provided, they default to 0, meaning the image is loaded at its native size. The width and height parameters only specify the desired size; the resultant image may be smaller or larger, and should be scaled after loading if you need it to be an exact size. The main purpose of the width and height parameters is to influence which image within an icon is loaded; most other image formats either ignore the parameters or only use them to speed things up, such as avoiding a full JPEG decode if a partial decode can satisfy the desired image size.

1 Like

changing the cx cy properties will change the control size, the image will scale smaller in the control but not bigger than it's original size if the control is bigger. Did you mean there is a way of scaling the image to a specific and exact size (stretch ? crop ? fit ?). If so please tell.

Also it is difficult to size a control (measured in dlu's) to fit an image (measured in pixels) exactly.

The Control.cx and cy properties are in pixels, not DLUs, so that should be easy.

I thought there was, but not sure now. We could add that if needed.

Doesn't the control resize the image to fit inside it anyway? (Not something I can test quickly very easily, but if it doesn't do that we could add an option for that as well.)

Yes please.

The images show the control in magenta

TLDR; image does not scale up when control is larger, but will scale down if control is smaller.

Probably related is that an image extracted from a DLL appears to be loaded at its native size regardless of what height and width is requested. e.g.

ctl.label = DOpus.LoadImage('/system/zipfldr.dll',200,200);
ctl.label = DOpus.LoadImage('/system/zipfldr.dll',10,10);
ctl.label = DOpus.LoadImage('/system/zipfldr.dll');

all produce the same result.