mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 02:18:03 +02:00
Cocoa: Add new TCocoaBitmapTypes for non-premultiplied images
For our image compare we need to know when low level images are premultiplied or not. Current types do not indicate this information so we have added the cbtARGBN and cbtRGBAN indicated when images are created to distinguish from cbtARGB and cbtRGBA images that are premultiplied. And then modified the creation code to specify and use those new types. While working in that same area of our code we found that we needed to be able to query the TCocoaBitmapAlignment value of the images and so added the Alignment: TcocoaBitmapAlignment property
This commit is contained in:
parent
26c9e04c8e
commit
cd003249dc
@ -33,7 +33,9 @@ type
|
||||
cbtARGB, // color bitmap with alpha channel first 8-8-8-8 A-R-G-B
|
||||
cbtRGBA, // color bitmap with alpha channel last 8-8-8-8 R-G-B-A
|
||||
cbtABGR, // color bitmap with alpha channel first 8-8-8-8 A-B-G-R
|
||||
cbtBGRA // color bitmap with alpha channel last 8-8-8-8 B-G-R-A
|
||||
cbtBGRA, // color bitmap with alpha channel last 8-8-8-8 B-G-R-A
|
||||
cbtARGBN, // color bitmap with alpha channel first 8-8-8-8 A-R-G-B No premultiplication
|
||||
cbtRGBAN // color bitmap with alpha channel last 8-8-8-8 R-G-B-A No premultiplication
|
||||
);
|
||||
|
||||
const
|
||||
@ -297,6 +299,7 @@ type
|
||||
property Depth: Byte read FDepth;
|
||||
property Width: Integer read FWidth;
|
||||
property Height: Integer read FHeight;
|
||||
property Alignment: TCocoaBitmapAlignment read FAlignment;
|
||||
end;
|
||||
|
||||
// device context data for SaveDC/RestoreDC
|
||||
@ -1112,9 +1115,14 @@ var
|
||||
i: Integer;
|
||||
lAlpha, lRed, lGreen, lBlue: Byte;
|
||||
begin
|
||||
if not (FType in [cbtARGB, cbtRGBA]) then Exit;
|
||||
if not (FType in [cbtARGB, cbtRGBA, cbtARGBN, cbtRGBAN]) then Exit;
|
||||
if FData = nil then Exit;
|
||||
|
||||
if FType = cbtARGBN then
|
||||
FType := cbtARGB;
|
||||
if FType = cbtRGBAN then
|
||||
FType := cbtRGBA;
|
||||
|
||||
// Keep the original data in a copy, otherwise we cant get access to it
|
||||
// because pre-multiplying destroys the original value if we had alpha=0
|
||||
if FOriginalData <> nil then
|
||||
|
@ -816,7 +816,7 @@ begin
|
||||
end;
|
||||
|
||||
// alpha
|
||||
if ABitmap.BitmapType in [cbtARGB, cbtRGBA] then
|
||||
if ABitmap.BitmapType in [cbtARGB, cbtARGBN, cbtRGBA, cbtRGBAN] then
|
||||
ADesc.AlphaPrec := Prec;
|
||||
|
||||
case ABitmap.BitmapType of
|
||||
@ -828,7 +828,7 @@ begin
|
||||
Dec(Shift, Prec);
|
||||
ADesc.BlueShift := Shift;
|
||||
end;
|
||||
cbtARGB: begin
|
||||
cbtARGB, cbtARGBN: begin
|
||||
Shift := 32 - Prec;
|
||||
ADesc.AlphaShift := Shift;
|
||||
Dec(Shift, Prec);
|
||||
@ -838,7 +838,7 @@ begin
|
||||
Dec(Shift, Prec);
|
||||
ADesc.BlueShift := Shift;
|
||||
end;
|
||||
cbtRGBA: begin
|
||||
cbtRGBA, cbtRGBAN: begin
|
||||
Shift := 32 - Prec;
|
||||
ADesc.RedShift := Shift;
|
||||
Dec(Shift, Prec);
|
||||
|
Loading…
Reference in New Issue
Block a user