View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0022245FPCFCLpublic2012-06-10 13:582012-06-18 11:02
ReporterBernd Kreuss 
Assigned ToMarco van de Voort 
PlatformallOSallOS Versionall
Product Version2.6.1Product Build 
Target VersionFixed in Version 
Summary0022245: [Patch] fcl-image, interpolation, wrong initialization of alpha channel
DescriptionThere is a small bug in packages/fcl-image/src/ that essentially makes it impossible to use TFPImageCanvas.StretchDraw() with images that have alpha transparency.

Attached is a patch.

When it calculates the interpolated value of the new pixel it will first initialize this pixel with colBlack. This is wrong.

The intention is to initialize all 4 channels of the pixel with zero but colBlack only has the RGB values set to zero, alpha is set to $ffff. The correct value would have been colTransparent which has them all four set to zero. The attached patch will fix it.

Without the patch any attempt to use StretchDraw() on an image with alpha transparency would end up with most of the resulting alpha values in the resulting image set to $ffff.

I am also attaching a small demo program (interpoltest.lpr), there is also a small PNG file with alpha channel in this archive for convenience, running the program should scale the image 'original.png' to 64*64 and save it to 'scaled.png' where you can then examine it with gimp to observe how the alpha channel gets messeed up during this operation.

The patch was made against the current 2.6 fixes branch, I have not yet tested 2.7 trunk but most likely it is there also.

(also maybe after it is fixed it would be nice to add a small example how to scale images to the fcl-image examples, it took me a while to figure out that it actually even *has* the capability to do this)
Steps To ReproduceTo reproduce it unzip and compile the attached demo in the attached interpoltest.tar.bz2 archive. Run the program, it will create an image 'scaled.png', observe how the alpha channel in this image was corrupted during scaling.
Fixed in Revision21639
Attached Filespatch file icon interpol-must-be-all-zero.patch [^] (755 bytes) 2012-06-10 13:58 [Show Content]
bz2 file icon interpoltest.tar.bz2 [^] (18,982 bytes) 2012-06-10 13:59

- Relationships

-  Notes
Bernd Kreuss (reporter)
2012-06-11 18:39

btw, the attached demo has a memory leak, I forgot to free the canvas object but this does not impact its function.
Marco van de Voort (manager)
2012-06-18 11:02

Applied, committed test as examples/interpoldemo (no picture though, to keep svn lean)
Marco van de Voort (manager)
2012-06-18 11:02
edited on: 2012-06-18 11:02

Note that I expect 0011217 to be something similar.

- Issue History
Date Modified Username Field Change
2012-06-10 13:58 Bernd Kreuss New Issue
2012-06-10 13:58 Bernd Kreuss File Added: interpol-must-be-all-zero.patch
2012-06-10 13:59 Bernd Kreuss File Added: interpoltest.tar.bz2
2012-06-11 15:48 Marco van de Voort Tag Attached: fcl-image
2012-06-11 18:39 Bernd Kreuss Note Added: 0060447
2012-06-18 11:02 Marco van de Voort Fixed in Revision => 21639
2012-06-18 11:02 Marco van de Voort Status new => resolved
2012-06-18 11:02 Marco van de Voort Resolution open => fixed
2012-06-18 11:02 Marco van de Voort Assigned To => Marco van de Voort
2012-06-18 11:02 Marco van de Voort Note Added: 0060606
2012-06-18 11:02 Marco van de Voort Note Added: 0060607
2012-06-18 11:02 Marco van de Voort Note Edited: 0060607

MantisBT 1.2.12[^]
Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker