Page 1 of 1

[SOLVED]Applying image manipulators (ex:crop) to thumbnails?

Posted: Wed Apr 30, 2014 11:32 pm
by Lora
Just wondering if it's possible to add image manipulators (crop, alpha mask, color matrices, etc) to the thumbnail of a save file before it's displayed via add FileScreenshot() to the File Picker. Not necessary but would be a cool touch!

Re: Applying image manipulators (ex: crop) to thumbnails?

Posted: Wed Apr 30, 2014 11:38 pm
by PyTom
Hm... doing so will probably work, but it will be slow. If you can do what you want with a Transform, it will work better (and I know it will work).

Re: Applying image manipulators (ex: crop) to thumbnails?

Posted: Thu May 01, 2014 1:14 am
by Asceai
crop is best done with the crop transform property. alphamask is best done with alphablend. colour matrices.. you're on your own.

Re: Applying image manipulators (ex: crop) to thumbnails?

Posted: Fri May 02, 2014 5:27 am
by Lora
Ah, I didn't realize there was a crop transform property! That's working out nicely! I've tried out the AlphaBlend, but it doesn't really work the way an AlphaMask would, does it, since you have to provide the image to blend into? I have a complicated background (for the entire file picker screen) that I have "fading into" the thumbnail image. (non-animated)

Anyway, conclusion reached, image manipulators DO work with the thumbnails, which is cool! I haven't tried color matrices, but the AlphaMask was most of what I was going for. I haven't noticed any slowness yet, though I have a fairly good computer. I really like the effect I got, but I also don't wanna tax the system too much. Hmm. Well, will cross that bridge when I get to it I guess!

Re: Applying image manipulators (ex: crop) to thumbnails?

Posted: Fri May 02, 2014 5:51 am
by Asceai
Lora wrote:Ah, I didn't realize there was a crop transform property! That's working out nicely! I've tried out the AlphaBlend, but it doesn't really work the way an AlphaMask would, does it, since you have to provide the image to blend into? I have a complicated background (for the entire file picker screen) that I have "fading into" the thumbnail image. (non-animated)
Just provide Solid("#0000") or some other transparent displayable to fade to.

Re: Applying image manipulators (ex: crop) to thumbnails?

Posted: Sat May 10, 2014 3:23 am
by Lora
D'oh, I should have thought of that. Might implement that later.

Sooo my fading images loadscreen works well, until I try to access the second page (where no saves and hence thumbnails exist)


Then I get this error:
I'm sorry, but an uncaught exception occurred.

While running game code:
File "renpy/common/_layout/screen_main_menu.rpym", line 29, in script
File "game/screens.rpy", line 303, in python
File "game/screens.rpy", line 284, in python
File "game/screens.rpy", line 233, in python
Exception: Expected an image, but got a general displayable.

-- Full Traceback ------------------------------------------------------------

Full traceback:
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\execution.py", line 294, in run
node.execute()
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\ast.py", line 732, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\python.py", line 1382, in py_exec_bytecode
exec bytecode in globals, locals
File "renpy/common/_layout/screen_main_menu.rpym", line 29, in <module>
$ ui.interact()
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\ui.py", line 237, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\display\core.py", line 2059, in interact
scene_lists.replace_transient()
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\display\core.py", line 577, in replace_transient
self.remove(layer, tag)
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\display\core.py", line 851, in remove
self.hide_or_replace(layer, remove_index, "hide")
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\display\core.py", line 775, in hide_or_replace
d = oldsle.displayable._hide(now - st, now - at, prefix)
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\display\screen.py", line 189, in _hide
hid.update()
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\display\screen.py", line 270, in update
self.screen.function(**self.scope)
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\screenlang.py", line 1236, in __call__
renpy.python.py_exec_bytecode(self.code.bytecode, locals=scope)
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\python.py", line 1382, in py_exec_bytecode
exec bytecode in globals, locals
File "game/screens.rpy", line 303, in <module>
use file_picker
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\display\screen.py", line 599, in use_screen
screen.function(**scope)
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\screenlang.py", line 1236, in __call__
renpy.python.py_exec_bytecode(self.code.bytecode, locals=scope)
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\python.py", line 1382, in py_exec_bytecode
exec bytecode in globals, locals
File "game/screens.rpy", line 284, in <module>
use load_save_slot(number=1)
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\display\screen.py", line 599, in use_screen
screen.function(**scope)
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\screenlang.py", line 1236, in __call__
renpy.python.py_exec_bytecode(self.code.bytecode, locals=scope)
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\python.py", line 1382, in py_exec_bytecode
exec bytecode in globals, locals
File "game/screens.rpy", line 233, in <module>
add im.AlphaMask(FileScreenshot(number), "gui/testmask.jpg") xpos 12 ypos 12
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\display\im.py", line 1482, in __init__
self.base = image(base)
File "C:\Users\Lora\Downloads\renpy-6.17.4-sdk\renpy\display\im.py", line 1551, in image
raise Exception("Expected an image, but got a general displayable.")
Exception: Expected an image, but got a general displayable.

Windows-post2008Server-6.2.9200
Ren'Py 6.18.0.409
High Fog 0.0
I know it's something to do with how FileScreenshot(number) doesn't exist for those nonexistent saves. Here's the original code:

Code: Select all

    
$ file_text = "{font=fonts/pfarma.ttf}{color=#fff}{size=16}% s\n  {/size}%s{/color}" % (FileTime(number, empty="Empty Slot."), FileSaveName(number))
add im.AlphaMask(FileScreenshot(number), "gui/testmask.jpg") xpos 12 ypos 12
text file_text  xpos 180 ypos -10 size 20

then I tried to fix it I tried something like:

Code: Select all

    
if renpy.exists(FileScreenshot(number)):
        add im.AlphaMask(FileScreenshot(number), "gui/testmask.jpg") xpos 12 ypos 12
However, this stops all screenshots from being displayed, even the ones that exist. I'm guessing renpy.exists wasn't meant to be used with this sort of functionality...?

Any ideas?

(Thanks Asceai and PyTom for the help so far!)

Re: Applying image manipulators (ex: crop) to thumbnails?

Posted: Sat May 10, 2014 4:19 am
by Asceai
FileScreenshot on an empty saveslot returns a Null(), which is a displayable, not an image manipulator, _unless_ you specify an 'empty' param, then it returns that param instead.

So you need to supply an empty param. Something like:
default empty_screenshot = Image("empty_screenshot.png")
add im.AlphaMask(FileScreenshot(number, empty=empty_screenshot), "gui/testmask.jpg") xpos 12 ypos 12

Re: Applying image manipulators (ex: crop) to thumbnails?

Posted: Sat May 10, 2014 4:46 am
by Lora
Ohh, I get it! Thanks so much! It works perfectly now! :D