[SOLVED] pixel.c Spline does not transparency fix
Posted: 2012-06-12T07:54:58-07:00
IM7 v8200.
Compare the code for SplineInterpolatePixel that starts at line 4432 of pixel.c with the code for CatromInterpolatePixel that starts at L4210 for example. Specifically, compare L4273 with L4475.
With Catrom, what we have decided is the right thing to do is done: The interpolated transparency is reciprocated and multiplied by the interpolated pre-multiplied colour.
With Spline, the transparency at "n" is unmultiplied, which means it's just canceled out (it's multiplied at L4463 and unmultiplied at L4475) and never interpolated. Spline does not implement the "transparency bug fix". (Spline is not hurt as much by the "non-fix" because it's monotone. This would be obvious with Catrom.)
-----
I'm just about to check in code (into IM7 through the ImageMagick-Windows svn) that fixes everything and unifies the treatment of Catrom and Spline. It runs more slowly than the current Spline, but it's because it interpolates alpha, which the current Spline code does not. It is also structured so that I could easily add Mitchell.
(I've tried using a coding style which is closer to what's usually found in IM. Let me know if I'm missing something. I've also untabified. Let me know if this is verboten.
I've also used the safe coding practice described here: http://stackoverflow.com/questions/1810 ... fixed-size)
Compare the code for SplineInterpolatePixel that starts at line 4432 of pixel.c with the code for CatromInterpolatePixel that starts at L4210 for example. Specifically, compare L4273 with L4475.
With Catrom, what we have decided is the right thing to do is done: The interpolated transparency is reciprocated and multiplied by the interpolated pre-multiplied colour.
With Spline, the transparency at "n" is unmultiplied, which means it's just canceled out (it's multiplied at L4463 and unmultiplied at L4475) and never interpolated. Spline does not implement the "transparency bug fix". (Spline is not hurt as much by the "non-fix" because it's monotone. This would be obvious with Catrom.)
-----
I'm just about to check in code (into IM7 through the ImageMagick-Windows svn) that fixes everything and unifies the treatment of Catrom and Spline. It runs more slowly than the current Spline, but it's because it interpolates alpha, which the current Spline code does not. It is also structured so that I could easily add Mitchell.
(I've tried using a coding style which is closer to what's usually found in IM. Let me know if I'm missing something. I've also untabified. Let me know if this is verboten.
I've also used the safe coding practice described here: http://stackoverflow.com/questions/1810 ... fixed-size)