Image scaling / zooming

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Image scaling / zooming

#1 Post 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().
Attachments
2018-05-29 15_31_44-Dungeoncrawl.png
2018-05-29 15_31_44-Dungeoncrawl.png (5.78 KiB) Viewed 1308 times
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Image scaling / zooming

#2 Post 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

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Image scaling / zooming

#3 Post 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.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Image scaling / zooming

#4 Post 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
Frameworks & Scriptlets:

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Image scaling / zooming

#5 Post 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!
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Image scaling / zooming

#6 Post by philat »

Well, yeah, im.Composite is so deprecated it's not even documented anymore.

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Image scaling / zooming

#7 Post 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?
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Image scaling / zooming

#8 Post 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()

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: Image scaling / zooming

#9 Post 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.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Image scaling / zooming

#10 Post 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

rames44a
Newbie
Posts: 11
Joined: Sat May 12, 2018 11:48 am
Contact:

Re: Image scaling / zooming

#11 Post 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.)

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Toma