Transparency with .pngs... I can't figure it out.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Knaimhe
Prole
Posts: 34
Joined: Mon Jan 23, 2012 7:23 pm

Transparency with .pngs... I can't figure it out.

Post 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.)
Attachments
VividRing(Compression1).png
VividRing(Compression1).png (311.63 KiB) Viewed 3931 times
User avatar
Ser_Mitch
Prole
Posts: 12
Joined: Wed Oct 17, 2012 12:06 am

Re: Transparency with .pngs... I can't figure it out.

Post by Ser_Mitch »

Worked fine for me...

I opened your image in Paint.NET (to make sure the transparency was there :P ) 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 :)
Attachments
Transparency test.love
(243.42 KiB) Downloaded 188 times
Knaimhe
Prole
Posts: 34
Joined: Mon Jan 23, 2012 7:23 pm

Re: Transparency with .pngs... I can't figure it out.

Post 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*
Attachments
StillSolid.jpg
StillSolid.jpg (39.11 KiB) Viewed 3913 times
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Transparency with .pngs... I can't figure it out.

Post 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.
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: Transparency with .pngs... I can't figure it out.

Post by qaisjp »

I got the same black image, I confirm slime's message.
Lua is not an acronym.
Knaimhe
Prole
Posts: 34
Joined: Mon Jan 23, 2012 7:23 pm

Re: Transparency with .pngs... I can't figure it out.

Post 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?
User avatar
Ser_Mitch
Prole
Posts: 12
Joined: Wed Oct 17, 2012 12:06 am

Re: Transparency with .pngs... I can't figure it out.

Post 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...
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Transparency with .pngs... I can't figure it out.

Post 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.
Knaimhe
Prole
Posts: 34
Joined: Mon Jan 23, 2012 7:23 pm

Re: Transparency with .pngs... I can't figure it out.

Post 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. :P

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.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Transparency with .pngs... I can't figure it out.

Post 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.
Shallow indentations.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 8 guests