PNG importing appears to be broken ( was Re: [squeak-dev] Who understand bilinear interpolation for reducing image size?)

tim Rowledge tim at
Fri Dec 12 03:47:43 UTC 2014

I’m going to snip out almost everything because this is getting confusing.

> IMHO it's not wrong if reading a file results in the exact contents of the file.

I think I have to disagree. At the most trivial level, reading a file with compressed data fails this assertion, for example. A little more seriously I claim that reading a file should provide a representation of the data contained in that file that we can use meaningfully within the context of our system. An obvious corollary is that our writing code must do the proper conversion too.

>> The black = very very dark blue thing is nothing to do with blending etc. Somewhere we have to decide if an incoming png pixel value is meant to be black and convert that to our pseudo-black. 
> No, it really depends on what you are going to do with that pixel. If you have a proper rendering pipeline down the road, FF000000 is a perfectly fine opaque black.

I can see that it ought to be so. Would we claim to have a proper rendering pipeline? 

Another factor that arise from the old scratch code for loading pngs is that apparently some applications (ab)use the low bits of the alpha channel for Foul Deeds and thus some true fudging was required; the code actually looks at the alpha and if it is < 2(or 3, or 4, whatever) sets the pixel as all-0. As a side effect this caught any 0-alpha/non-0-RGB cases.

Two good example images are
monkey1.png where the background should be transparent but appears as white -
bananas1.png (similar but different in detail) -

It’s probably relevant that these get rendered with paint in the scratch code. I’m not overly keen on having to change much of that. I suggest that our png reading code ought to deal with the issue of 0RGB pixels and possibly with the low-alpha pixels wrongly produced by some applications. Yes, it could be done with post-load code but is it really important to make life difficult?

tim Rowledge; tim at;
"Like, no bother man.." said Pooh as he spaced out on hash

More information about the Squeak-dev mailing list