To put an image in a pdf file, I need to get the individual pixel colors. WEBLIB.graphics provides this property for a canvas. So, this would be easy to do. However, there are several issues:
- The picture is a png file with transparency. All transparent pixels are shown in black, when accessing the pixels. Is there a way to find out whether a black pixel is really black or black because of transparency?
- When getting the pixels from a TGraphic, they are all black. To get the pixels from an image, I first have to draw the TGraphic on a TBitmap canvas and get the pixels from there.
- The definition of "Pixels" is different in Vcl.graphics (defined in TCustomCanvas) and using "Single" as indexes) and WEBLib.graphics (defined in TCanvas and using "Integer" as indexes).
Attached a screenshot of different copies the same image:
Picture 1: original picture loaded at design time. Transparency is correctly interpreted.
Picture 2: copied from the original through drawing a TGraphic on a paintbox: correct
Picture 3: copied drawing the TGraphic on a TBitmap. Pixel colors are available and editable, but transparency lost.
Picture 4: accessing pixels from a TGraphic returns black pixels.
Attached the program demonstrating this behavior.
Transparent.zip (22.9 KB)
The biggest problem is the loss of transparency, as pictures in the real application come from a server or from a database (blob). All of them are transparent and must appear in a pdf report.
Thank you for looking into this.
Kind regards,
Michel Huybrechts
Micriconsult BV