trouble with the scale bug

Casper Boemann cbr at boemann.dk
Fri May 25 17:08:08 CEST 2007


On Friday 25 May 2007 16:54, Matthew Woehlke wrote:
> Casper Boemann wrote:
> > And as these transparent borders are mathmatically correct (eventhough
> > for a plain rect picture not attractive) I feel that we should come up
> > with something similar to what photosop does.
>
> To ask a "dumb" question, /why/ are they "mathematically correct"? It
> seems it should be possible to define the resize algorithm in a way that
> avoids this problem...

Well because the "new pixel" is sampled from the pixels it cover in the old 
image.

If half of the pixels it cover are transparent then the result shoul be 
transparent too.

Otherwise scaling irregular shaped images would provide jagged edges.

The questions is not as dumb though, since what you are asking for is an 
algorithm that automatically preserves hard edges and blurs in other places. 
Such algorithms do exist, but is a bit out of reach for us just yet.

Anyway I've commited a fix that resets the transparency of border pixels after 
the scaling is done. This way I calculate the correct color (without 
overrepresenting the border color). I also do the little trick of setting the 
transparency to that of the nearest pixel in the original image. That way I 
also preserve the transparency of the original transparency.
-- 
best regards / venlig hilsen
Casper Boemann


More information about the kimageshop mailing list