PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

PNG image problem

I am completely at a loss to explain this... I have a PNG image that is not rendering properly in a GD app. I've tried it in the sample apps (just replaced the ipaq image for instance), and it still renders incorrectly... The image is squished to about half of the area it should take up, and the background color is changed to green, the other half is empty black.

Could someone take a peek at this image file:

http://www.omnytex.com/gfx_logo_crackhead.png

... and see if you can figure out why it's not displaying properly (at the least verify that it's not just me, that you see it not rendering properly too).

I've re-saved it a number of times using the same settings I use for all my other PNGs, but this is the only one I'm having a problem with. Thanks all!
Update: If I save the image in 24-bit color, it renders fine. I'm doing the same optimization I do on all my other images, that is, I make them 256-color paletized (optimized octree). I do this for space considerations, since I don't really need more than 256 colors.

This of course makes the image 14k instead of the 8k it really should be, so I'd really like to know why this is still...
Update #2...

I resolved the issue by doing a flood fill with RGB 0,0,1 in the "background" black areas. That solved the problem, and has no real perceptible effect on the image's appearance.

My suspicion is that the optimizer thinks this image is greyscale, which I suppose is a fair thing to think, and does something funky with it in that special case. Does PNG have a special greyscale mode maybe that GD doesn't fully or properly support? I don't know.

I'm leaving this post open to comment because it's possible this represents a bug in the GD code. I'll leave that image that I linked to out there for Johan, or anyone else, to take a look it.

I'd still like to know why that image didn't work as it was.
My suspicion is that the optimizer thinks this image is greyscale


I tried reading the image in Photoshop 7.0 and Photoshop also thinks the image is GrayScale. I guess it's your image program that saves the image as gray scale if it cannot find any colors in it (and I disabled gray scale import in GapiDraw)...
Yep, that seems a good conclusion. I'm using Paint Sbop Pro 7 by the way. I didn't realize GD didn't support greyscale though. Not that it's a big deal, but what was your reasoning for that?
Um.. Good question.. :) I'll check the PNG code to see if I can enable it easily.. Otherwise I can fix it up in a future update...
Sounds good Johan. This certainly isn't any kind of priority, I wouldn't be surprised if I'm the first person that encountered this limitation, and it was only back accident anyway :)
Frank: I don't know if this is any good for you, PSP has an optimiser available at save time:

Image

select options...

Image

select run optimizer...

Image

Do your thing :)
Yep, that's what I used. Seems that if the image uses colors with nothing but gray tones, it treats it as a grayscale image no matter what, regardless of what you select in the optimizer settings. May be just a bug in the optimizer, that's my guess, I'm not sure though. I didn't go so far as to look at the PNG specs to see if the image is truly saved as a grayscale PNG, but it makes sense in light of what Johan said. No big deal, my work-around worked just fine. Gives me a reason to upgrade to PSP 8.0 anyway (I did at work, time to do so at home too I guess).
Talking about PNGs, a very weird problem is happening with my application...

When I run the debug compilation, a certain PNG file loads OK. But, when I try the release version of the EXACT same code, that PNG doesn't seem to be loaded. CreateSurface returns no errors, but when I blit the image, nothing appears. I've already tried resaving the file (who knows it got corrupt somehow), with no success.

Any idea of what may be happening?

P.S.: Yes, all other PNG files load OK even in the release version.
Pejo Software - Per · 06 Oct 2003, 06:01 UTC
When it works in debug mode and not in release mode or the opposite, it generally is a sympthom of overwriting memory somewhere.