Page 1 of 1

Image scaling / zooming

Posted: Tue May 29, 2018 9:33 am
by Milkymalk
Currently I have three separate images for each item: One lying on the ground, one in the inventory, and one closeup view. As many items are small enough that the ground image and the inventory image can be the same, or large enough that the closeup image and the ground image can be the same, or they just differ in size but not in the actual image, I wanted to store a filename and zoom for each image inside the item.

For example, a potion looks the same no matter where it is (as opposed to a coat, which looks different on the ground than in detail view).

So I tried this:

Code: Select all

Image("filename.png", zoom=0.5))
But the image is displayed at full size. I tried "add" instead of "imagebutton" to see if that's only with imagebuttons, but still, no zoom.

Then I tried im.FactorScale instead of using the zoom property:

Code: Select all

im.FactorScale(Image("filename.png"), 0.5))
That worked, but made the image ugly compared to the original and also the formerly used, downscaled saved version: semi-transparent areas became dull, smaller white lines almost disappeared etc. See attached image.

What I don't get is why zoom doesn't work with Image(), when it's listed in the property list where also xalign is listed, which is used in the docs as an example property for Image().

Re: Image scaling / zooming

Posted: Tue May 29, 2018 10:11 am
by philat
Zoom isn't a STYLE property. It's a transform property. Not sure if using zoom would be any better (tends not to look great below 0.5 anyway), but you can try using an At(). https://www.renpy.org/doc/html/displayables.html#At

Re: Image scaling / zooming

Posted: Tue May 29, 2018 12:11 pm
by Milkymalk
Using At got me an exception:
File "game/inventory.rpy", line 385, in keywords
imagebutton idle im.Composite((50,50), (0,0), "images/interface/emptyinv.png", (0,0), At("images/items/"+i.inv.slot[j].getimage('icon')[0]+".png", itemzoom(0.5))) action [SensitiveIf(renpy.get_screen("waitforevent")), Function(i.inv.grab,j)] xpos 20+(j%2)*50 ypos inv_ystart+(j//2)*50
Exception: Expected an image, but got a general displayable.
EDIT: Scrap that, I will just use scaled down versions of the image in addition to the large ones. Less trouble.

Re: Image scaling / zooming

Posted: Tue May 29, 2018 5:57 pm
by Remix
try (untested though pretty sure it works)

image diddy_potion = Transform( "potion.png", zoom=0.5 )

or just the Transform() part as an idle/hover/whatever-state reference

Re: Image scaling / zooming

Posted: Wed May 30, 2018 8:54 am
by Milkymalk
It works on its own (even looks okay, just a bit darker where it's translucent), but it doesn't work inside an im.Composite. I can rewrite that part though. Thank you, I can use this!

Re: Image scaling / zooming

Posted: Wed May 30, 2018 9:07 pm
by philat
Well, yeah, im.Composite is so deprecated it's not even documented anymore.

Re: Image scaling / zooming

Posted: Thu May 31, 2018 8:12 am
by Milkymalk
Oh okay, I just use it without looking it up :D
What is an alternative way of compositing images that is not deprecated?

Re: Image scaling / zooming

Posted: Thu May 31, 2018 8:21 am
by kivik
Composite() is the current way: https://www.renpy.org/doc/html/changelo ... -6-99-14-3

I think it was previously replaced by LiveComposite(), and now Composite()

Re: Image scaling / zooming

Posted: Thu May 31, 2018 11:48 am
by Milkymalk
Ah cool, thanks. I always thought LiveComposite was something different than im.composite (due to the "Live" part). But I do see a trend of classes taking the place of functions.

Re: Image scaling / zooming

Posted: Thu May 31, 2018 12:03 pm
by kivik
I've been lucky that I started recently enough that the im. class seems to have retired already and the documentation stated that, so I only learnt about LiveComposite - which of course others tend to remind me should be changed to Composite now as well. Luckily I don't do any compositing in my game, for now :P

Re: Image scaling / zooming

Posted: Thu May 31, 2018 1:05 pm
by rames44a
Oddly enough, "Composite" doesn't appear to be listed in the current 6.99.14.3 documentation, although it's in the 7.0 beta stuff. Guess it inadvertently got removed. (There are still one or two references to LiveComposite, but again no docs for it.)