Png-Alphachannel does not work.

BlitzMax Forums/BlitzMax Programming/Png-Alphachannel does not work.

DocFritz(Posted 2005) [#1]
Hi

I don't know, why, but all my Png's, I save with Photoshop, won't work in Blitzmax. They use the Alpha-Channel for transparency, of course. Here is an Example:


Well, the strange thing is, that it isn't displayed correct when rotated or drawn at float-positions. Take a look at this:


Graphics 800, 600, 0

test=LoadImage("hammer.png")
SetBlend ALPHABLEND
MidHandleImage test

While Not KeyHit(KEY_ESCAPE)
Cls

angle:+1
SetRotation angle
DrawImage test, 100, 100

Flip
Wend



Why the hell doesn't the Alpha-Channel work properly? It's a regular, Non-Interlanced Image, I saved with photoshop, there shouldn't be any problem.


FlameDuck(Posted 2005) [#2]
I know this isn't what you want to hear, but it works perfectly here. Your example, your image, no problem.

What kind of graphics card / OS / driver combination do you have?


DocFritz(Posted 2005) [#3]
....don't you see the white border? o_O

Nvidea Geforce 6800 GT, newest official Driver, Windows XP SP2


Steve Elliott(Posted 2005) [#4]
Nope - works fine here. You could try reverting to a previous driver (newer ones are not always the best) and perhaps adjusting some driver options in Windows.


WendellM(Posted 2005) [#5]
Your test works fine on my XP SP2, Radeon 9600 Pro PC: no white area, just the ship. I've been using alpha-transparent PNGs in my current Max game, too, and they all work.

I also tried your test on my Mac and it works fine with its GeForce4 MX.


Steve Elliott(Posted 2005) [#6]

I've been using alpha-transparent PNGs in my current Max game, too, and they all work.



Same here.


DocFritz(Posted 2005) [#7]
Hm.... I'll report this as a bug since we don't know, if it's a Nvidia- or a BlitzMax-Problem. Thanks for testing.


FlameDuck(Posted 2005) [#8]
....don't you see the white border? o_O
No. It looks exactly the same as the image you posted in the thread (except rotating, obviously). In Firefox, as I'm aware IE doesn't do PNG (particularly not transparent ones) too well.

You could try reverting to a previous driver (newer ones are not always the best)
Or in the case of nVidia, newest drivers are almost always the worst. I recommend you get the second latest WHQL certified drivers.

Still don't regret getting an ATi this time around, sure it doesn't have shader model 3, but at least alpha channel transparency actually works. *Sigh*

I've been using alpha-transparent PNGs in my current Max game, too, and they all work.
Same here. Much better than a single color mask, soft edges are SO sexy! :o>

Alernatively you could try switching to the OpenGL renderer, like so:
I'll report this as a bug since we don't know, if it's a Nvidia- or a BlitzMax-Problem.
Well it could be argued that the fact that you're the only one having this issue, narrows down the likelyhood of it being a BlitzMAX bug. I'm sure someone with a 6K8 will be along shortly to tell you which driver actually works.


mr.keks(Posted 2005) [#9]
I've also got a white border. But I can solve the problem by resaving the image with thegimp2.0...


DocFritz(Posted 2005) [#10]
Well... someone with a Geforce 6800GT? Would be nice to hear, if it works.


mr.keks(Posted 2005) [#11]
Hmm, I can't fix the file again ^^. lol. Whatever.

P.S. I've got a GeforceFX 5700..


Yan(Posted 2005) [#12]
It's neither a BMax or an Nvidia problem.

It's because Photoshop makes transparent pixels white when it exports them. This doesn't normally matter as they're, well, transparent. When such images are filtered, however, the edge pixels are averaged with the white (transparent) pixels and you get the ghostly white glow.

Try using this...



DocFritz(Posted 2005) [#13]
great, it works =)

How did you save it? I tried with Gimp some hours ago, same problem.


IPete2(Posted 2005) [#14]
Yes I use Fireworks - it never does that, but I have exported from Photoshop Elements and kept the transparency so it should be possible.

IPete2.


Yan(Posted 2005) [#15]
When you're saving from The GIMP, make sure that 'Save background colour' and 'Save colour values from transparent pixels' are unchecked in the PNG save dialogue.

Funnily enough, I've got a half written tool that'll scan a directory tree and convert any PNGs it comes across. I've been awaiting MaxGUI so I can give it a decent front end.


Jay Kyburz(Posted 2005) [#16]
convert any PNG's to what?

I've been using tga's because of this problem. (stupid photoshop)


IPete2(Posted 2005) [#17]
From Photoshop save as... a copy (not in layers) as a .png and ensure if you have a white layer at the bottom of your layers, turn it off.

IPete2.


Yan(Posted 2005) [#18]
convert any PNG's to what?
To PNGs, of course. ;o)

Here's a simplified version, it'll only convert (maybe 'convert' is the wrong word to use) single images and it appends '_cnvt' onto the output...

DeFringe.exe ~75KB


@IPete2 - That's how I save PNGs anyway and it still produces the fringe I'm afraid, in version 6 at least.


IPete2(Posted 2005) [#19]
TwoEyedPete,

Have you tried saving as a 32 bit *.Tga file? Does that keep the transparency?

Also when you save the PSD and the PNG out and load them back in again how do they load back in?

IPete2.


RiK(Posted 2005) [#20]
Also when you save the PSD and the PNG out and load them back in again how do they load back in?


I always save my Photoshop (.PSD) masters in a seperate location and work from them, just export what I need for the game and save them locally.


Yan(Posted 2005) [#21]
Ipete2, I think you're misunderstanding the problem. The problem isn't a lack of transparency on the exported PNGs.

Look at these grabs from B3D (click on the thumbnails)...

Notice the white fringing around the inside edge of the reticule.


This is how is should look.

The fringing is the problem and is happening because of Photoshop forcing transparent pixels to white, as described above. It's a well known problem and there isn't a way to fix it from within Photoshop.


Robert Cummings(Posted 2005) [#22]
1. ensure there is a clear layer at the bottom of your layers palette and that you can see the checker pattern. It pays to have the clear layer at the bottom on some versions of photoshop.

2. use save for web then choose png with transparency. Simple.

3. use png crush to reduce the size of your photoshop exported pngs as photoshop still makes a poor job of sizes.


IPete2(Posted 2005) [#23]
Hmm, I think we got mixed up in the thread somehow. I see you are talking about a white fringe appearing. I was still on the get it out of Photoshop with a transparent bgd - as per the thread title - sorry.

If I post 2 images for you tell me if this has the same problem or if the hard one is ok.

www.smartscreenuk.com/sight001_hard.png

www.smartscreenuk.com/sight001_soft.png


IPete2.


Yan(Posted 2005) [#24]
Better still, try it for yourself...

fringingexample.zip ~450KB

You should see something like this...


It may not be as pronounced on ATI cards, but it's still there.

Try replacing 'img.png' with your own. Make the image about 64x64 and make sure it has a dark/black edge.


Yan(Posted 2005) [#25]
As you went to all the trouble of creating and uploading the images, I tried them anyway, with the following results...


soft edge


hard edge


[edit]The image server seems to be playing up today. Please be patient, the images will load eventually[/edit]


FlameDuck(Posted 2005) [#26]
You should see something like this...
I don't see anything at all in the "corrected texture" half.


Yan(Posted 2005) [#27]
Don't worry about that too much, I'm copying directly from one texture to another which is a no go with some hardware. ;o)
It's just a quick demo to highlight the problem.

The important thing is whether you see the fringing in the left window or not.

Thanks for trying it, BTW.


Sonic(Posted 2007) [#28]
I'm getting this problem and it's driving me mad!

Any solutions? Can't seem to get defringe.exe, and I'm on OSX anyway. Some of my photoshop png's appear to have black backgrounds when viewed in the Finder's preview, and they render ok, but others have white backgrounds and come up with the dreaded white halo.

Help!


FlameDuck(Posted 2007) [#29]
Any solutions?
Save from the GIMP (or get a newer version of Photoshop). You can get it here.