Page 1 of 1
Transparency with .pngs... I can't figure it out.
Posted: Fri Oct 19, 2012 12:10 am
by Knaimhe
In Love version 7, I could do transparency just fine... All I had to do was load and draw a .png image, and it would automatically be transparent wherever the image was transparent.
Lots of changes since then... I can't get the .png image for my current game to draw with transparency. I tried all of the Blend modes, too.
Inside love.draw()...
Code: Select all
love.graphics.setColor(0, 0, 0)
love.graphics.draw(VividRing, 1, 1, 0, 1/10, 1/10, 0, 0, 0, 0)
The background color is (200, 200, 250), which is a very light blue. The image is black.
The image I'm trying to draw is 4000x2000 pixels, and the screen is only 1000x500. But I've shrunk the image by a factor of 10 so it fits fully on the screen.
There is supposed to be a transparent aperture in the middle of the image, but I only get solid blocks when I try to draw it.
I've tried this with a .png compression of 1, and a .png compression of 0.
How should I be going about drawing a transparent image?
(I've attached the image I'm trying to draw. The uncompressed (level 0) file is pretty big, so I don't think I can post that one. The center of the image is definitely transparent and not just white, as it appears. I'm not that stupid.)
Re: Transparency with .pngs... I can't figure it out.
Posted: Fri Oct 19, 2012 1:35 am
by Ser_Mitch
Worked fine for me...
I opened your image in Paint.NET (to make sure the transparency was there
) and resaved it...
I used the bits of your code in the .love file below... See how it works.
P.S try and submit a .love file with help requests... makes it easier to solve
Re: Transparency with .pngs... I can't figure it out.
Posted: Fri Oct 19, 2012 2:29 am
by Knaimhe
Huh.
Well when I run your .love, all I see is this... *points at attached image*
I'm guessing I've got a problem with Love itself. Or maybe some OS incompatibility.
*goes to re-download*
Re: Transparency with .pngs... I can't figure it out.
Posted: Fri Oct 19, 2012 3:11 am
by slime
Just a note, video cards (especially old and low-end ones) are not designed to support very large textures/images. Many Intel integrated GMA chips won't support anything above 1024x1024.
Re: Transparency with .pngs... I can't figure it out.
Posted: Fri Oct 19, 2012 4:46 pm
by qaisjp
I got the same black image, I confirm slime's message.
Re: Transparency with .pngs... I can't figure it out.
Posted: Sat Oct 20, 2012 12:49 am
by Knaimhe
*sigh*
Hardware! Imprecations on ye!
I'll just go shrink my image. Do you think it'll help to compress it at a higher level than just zero or one?
Re: Transparency with .pngs... I can't figure it out.
Posted: Sat Oct 20, 2012 1:20 am
by Ser_Mitch
On my gaming/coding laptop ( Windows 7 home edition, i7 2nd gen, 4gb ram, 2gb Nvidia 610m ded graphics, love 0.8.0) I got the transparency just fine. No idea what your issue is
I'll send you a screenshot when I get home, just to prove that I'm not insane...
Re: Transparency with .pngs... I can't figure it out.
Posted: Sat Oct 20, 2012 2:06 am
by slime
Knaimhe wrote:*sigh*
Hardware! Imprecations on ye!
I'll just go shrink my image. Do you think it'll help to compress it at a higher level than just zero or one?
I'm not sure why you wouldn't compress it to a high level for distribution - the png format has lossless compression.
Re: Transparency with .pngs... I can't figure it out.
Posted: Sat Oct 20, 2012 2:19 am
by Knaimhe
I was worried that the decompression was part of the problem.
But it's been fixed now! I shrank my image down about 8x, and the transparency works. It'll take a bit of scaling in the code to get it right, but I'm just glad I can see through the middle.
Thanks, slime.
Oh, and Ser_Mitch... it probably works for you because your computer is just better.
Edit: I recompressed the image to a higher level, and it works fine. Frame rate is 'bout the same too, though I wasn't reloading the image every frame so I wouldn't expect much of a difference.
On the upside, the filesize shrank approximately 950 KB.
Edit Again: On the rather strange downside, the compressed (in .zip) file for the more-compressed .png image is actually one KB larger than the uncompressed one. So... I'll be using the uncompressed one.
Re: Transparency with .pngs... I can't figure it out.
Posted: Sat Oct 20, 2012 9:53 am
by Boolsheet
Knaimhe wrote:Edit Again: On the rather strange downside, the compressed (in .zip) file for the more-compressed .png image is actually one KB larger than the uncompressed one. So... I'll be using the uncompressed one.
That's quite normal with entropy coders, especially if the same coder is used twice (zip and png both use DEFLATE). If png already got it very close to the smallest possible message length, then zip will have a hard time compressing it more. In fact, it will use more bits because there's the overhead for the blocks.