Now, if originally the files were in PNG format, then I wouldn't even have to convert them, everything would be all fine and good. I'm not trying to save space.
But my issue is the images in this game are all JPG, and everything with transparency already has its mask attached. Like so (actual example):
I'd like to be able to use the original sprites without converting or tampering with them.
Is this possible at all in Ren'Py? Because I would really hate to have to put them all through Photoshop and such.
JPG transparency
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.
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.
-
- Lemma-Class Veteran
- Posts: 2299
- Joined: Mon Feb 06, 2012 9:50 pm
- Completed: Icebound, Selenon Rising Ep. 1-2
- Projects: Selenon Rising Ep. 3-4
- Organization: Fastermind Games
- Deviantart: sundownkid
- Location: NYC
- Contact:
Re: JPG transparency
This is the only way I know of to use transparent jpgs with Ren'py. (The mask has to be separate). Otherwise, you'll have to run them through Photoshop unless there's another converter that can do them in bulk.
- PyTom
- Ren'Py Creator
- Posts: 16088
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: JPG transparency
you could use im.AlphaMask with im.Crop to do this.
Code: Select all
init python:
def Masked(filename, width, height):
return im.AlphaMask(im.Crop(filename, (0, 0, width, height)), im.Crop(filename, (width, 0, width, height)))
image test = Masked("test.jpg", 400, 400)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: JPG transparency
That's certainly progress, but not quite there. Thanks though.
Switching the im.Crop order gives me this:
I'm... not very good at these sorts of things, as you can see.
-
- Miko-Class Veteran
- Posts: 829
- Joined: Sun Feb 20, 2005 8:45 pm
- Projects: NaNoRenO 2016, Ren'Py tutorial series
- Location: USA
- Contact:
Re: JPG transparency
Looks like your mask is inverted - traditionally, for image masks, the black pixels are transparent while the light pixels are opaque.
tweaking PyTom's code to account for this, I think this should do the trick:
(Also, there are a couple spots on your image that I think should be transparent, but the mask itself has to be fixed for that)
tweaking PyTom's code to account for this, I think this should do the trick:
Code: Select all
init python:
matrix_invert = [ -1, 0, 0, 0, 1,
0, -1, 0, 0, 1,
0, 0, -1, 0, 1,
0, 0, 0, 1, 0, ]
def Masked(filename, width, height):
return im.AlphaMask(im.Crop(filename, (0, 0, width, height)),
im.MatrixColor(im.Crop(filename, (width, 0, width, height)), matrix_invert))
image test = Masked("test.jpg", 400, 400)
~Kitsune Zeta
Re: JPG transparency
It works! Thank you very much.
Who is online
Users browsing this forum: Google [Bot], Majestic-12 [Bot]