"Wrong" colours in png files

Just starting out? Need help? Post your questions and find answers here.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

mskuma wrote:I could be wrong, but I think there's absolutely nothing wrong with the decoder - did you guys try the code I posted above & see netmaestro's result also? Using the 'defective' image, I could get the same result (i.e. alpha/transparency effects) as exhibited on the original web page (i.e. http://www.w3.org/Graphics/PNG/inline-alpha.html). [edit: Note that the alphatest.png image is from that page].
But that's using PB's own drawing commands. We don't know whether it subtracts away the whiteness.

Actually, if you try this transparent png: http://www.libpng.org/pub/png/img_png/s ... l_rgba.png (Which works using my code!) Then you'll see that using YOUR code the colours are way too dark.

Can we get an official comment on this?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Well I pulled that parrot or whatever it is into photoshop, dropped it against a light gray background and compared it to PB's DrawAlphaImage() to WindowOutput(). The results are identical. I see that it appears lighter viewed in IE, but does that mean Photoshop and PB are rendering it wrong? Also, I saved the image from Photoshop as a .TIFF and repeated the test in PB with the TIFFImageDecoder. Exactly the same output, indistinguishable from everything except the IE rendering.
BERESHEIT
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

mskuma wrote:Using the following code with the examples you've mentioned, the PNGs seem to display correctly, which would suggest PB's PNG decoder is ok:

Code: Select all

UsePNGImageDecoder() 
LoadImage(0,"alphatest.png") 
OpenWindow(0,0,0,640,480,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) 
StartDrawing(WindowOutput(0)) 
  Box(10,10,620,460,RGB(212,220,234))
  DrawAlphaImage(ImageID(0),100,50) 
StopDrawing() 
Repeat 
  ev=WaitWindowEvent() 
Until ev=#PB_Event_CloseWindow
What do you think?
Theres no such thing as PB PNG decoder/encoder, PB uses PNGLIB I'm 100% Sure (even though I didnt even check myself if this is true but I feel it). If its not PNGLIB, then its another.. but I'm sure theres no custom decoder here.

By the way, when you draw anything on a grey background, you might see a color change in this anything you've drawn, but thats just your pathetic eyes or brain interpretation being confused, not a programming error perse. If you are not sure about this, just take a screen grab.. zoom in your favourite application and compare. And this happens with anything and any color.

IE didnt support alpha channel until "now"... Its blending routine is just different, deal with it. Who cares about IE anyway. If you want the same result as in IE, then blend the alpha yourself with the background.. or find another way. This is the first time I see someone who wants something to look like in IE :shock:
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

PNGLIB is used, but: that shouldn't be our problem.

Look, I converted my faulty image to tiff and voila, it shows correctly with my code. Is there still not a bug in the png decoder?
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

Not in the decoder, yes a bug by Fred (add registered trademark sign here, if you will).

Because I use pnglib in C++ and never found a problem like this. But, you should get Dev-C++ and download PNGLIB, then try by yourself and if you step into the same problem, I'll ship you a 6 pack :oops: .

I'm not sure about IE, I don't think it uses pnglib... That'd be fun, I can already sense what it uses though.

About PB: I don't like how many things are done "on the shades" without giving you any real low-level access... Or will/did this change and I didnt noticed?.
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Well, with decoder I mean something hidden under UsePNGImageDecoder(), not neccessarily in libpng itself.

Edit: PB is using libpng 1.0.8 which is not available for download any more so I can't test it with Dev-C++. The current version is 1.2.10.
Post Reply