View Issue Details

IDProjectCategoryView StatusLast Update
0020774LazarusLCLpublic2020-03-31 10:49
Reporterszali Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Product Version0.9.30.2 
Summary0020774: Setting TBitmap.PixelFormat to pf32bit zeroes the alpha channel
DescriptionTake a TBitmap which has e.g. pf24bit pixel format. Set its PixelFormat to pf32bit. Then access the RawImage property and try to retrieve raw image data. You will find out that all 32-bit pixels have zero alpha in the raw image data.
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetWin32/Win64
Attached Files

Activities

Vincent Snijders

2014-09-25 16:01

manager   ~0077649

Please attach an example application.

What is the expected result?

Eric Heijnen

2016-07-13 13:02

reporter  

invalidpng.zip (2,258 bytes)

Michl

2016-07-13 15:08

developer   ~0093690

Last edited: 2016-07-13 15:16

View 4 revisions

> while the image object can load the generated png file back without issue

In my point of view, this is the only thing, which is maybe wrong, cause with a alpha channel, where all entries are 0, no picture should be drawn. See https://www.w3.org/TR/PNG-Decoders.html#D.Alpha-channel-processing
"The equation for computing a composited sample value is
   output = alpha * foreground + (1-alpha) * background"


> This is an issue for my current project as I am making use of the alpha
> channel to build up a fontmap to display text on the screen

On Windows a canvas has only 24bit depth. There is no alpha channel. You can add a alpha channel by your self or take the recommend ways here: http://wiki.freepascal.org/Developing_with_Graphics
You can also use external packages e.g. http://wiki.freepascal.org/BGRABitmap


I changed your example, where a alpha channel with entries 255 is added. I'm not sure, if it runs everywhere (just tested Windows and Linux Mint). With this change, here the png is loaded by every tested app.

General, I would do it this way: http://wiki.freepascal.org/Developing_with_Graphics#Working_with_TLazIntfImage.2C_TRawImage_and_TLazCanvas

Michl

2016-07-13 15:09

developer  

test.zip (2,179 bytes)

Eric Heijnen

2016-07-14 13:57

reporter   ~0093708

Last edited: 2016-07-14 14:04

View 2 revisions

Thanks, I've adjusted your routine to keep in mind the TransparentColor property of the png, so now it functions as intended again

Juha Manninen

2020-03-31 10:49

developer   ~0121791

I understand this is ok now. Resolving.

Issue History

Date Modified Username Field Change
2011-11-29 12:39 szali New Issue
2011-11-29 12:39 szali Widgetset => Win32/Win64
2012-03-13 10:19 Vincent Snijders LazTarget => 1.2
2012-03-13 10:19 Vincent Snijders Status new => acknowledged
2012-03-13 10:19 Vincent Snijders Target Version => 1.2.0
2014-01-14 15:10 Martin Friebe LazTarget 1.2 => 1.4
2014-01-14 15:12 Martin Friebe Target Version 1.2.0 => 1.4
2014-09-25 16:01 Vincent Snijders Note Added: 0077649
2014-09-25 16:01 Vincent Snijders Status acknowledged => feedback
2015-04-27 21:59 Juha Manninen LazTarget 1.4 => -
2015-04-27 22:02 Juha Manninen Target Version 1.4 =>
2016-07-13 13:02 Eric Heijnen File Added: invalidpng.zip
2016-07-13 15:08 Michl Note Added: 0093690
2016-07-13 15:09 Michl File Added: test.zip
2016-07-13 15:11 Michl Note Edited: 0093690 View Revisions
2016-07-13 15:15 Michl Note Edited: 0093690 View Revisions
2016-07-13 15:16 Michl Note Edited: 0093690 View Revisions
2016-07-14 13:57 Eric Heijnen Note Added: 0093708
2016-07-14 14:04 Eric Heijnen Note Edited: 0093708 View Revisions
2020-03-31 10:49 Juha Manninen Assigned To => Juha Manninen
2020-03-31 10:49 Juha Manninen Status feedback => resolved
2020-03-31 10:49 Juha Manninen Resolution open => no change required
2020-03-31 10:49 Juha Manninen Widgetset Win32/Win64 => Win32/Win64
2020-03-31 10:49 Juha Manninen Note Added: 0121791