mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 12:29:21 +02:00
* Graphic: fixed rendering of gray-alpha images. Partially fixes #13266
git-svn-id: trunk@25258 -
This commit is contained in:
parent
9f0a3a69df
commit
996ccb8aac
@ -152,6 +152,7 @@ type
|
|||||||
procedure GetColor_RGBA_NoPalette(x, y: integer; out Value: TFPColor);
|
procedure GetColor_RGBA_NoPalette(x, y: integer; out Value: TFPColor);
|
||||||
procedure GetColor_RGB_NoPalette(x, y: integer; out Value: TFPColor);
|
procedure GetColor_RGB_NoPalette(x, y: integer; out Value: TFPColor);
|
||||||
procedure GetColor_Gray_NoPalette(x, y: integer; out Value: TFPColor);
|
procedure GetColor_Gray_NoPalette(x, y: integer; out Value: TFPColor);
|
||||||
|
procedure GetColor_GrayAlpha_NoPalette(x, y: integer; out Value: TFPColor);
|
||||||
procedure GetColor_NULL(x, y: integer; out Value: TFPColor);
|
procedure GetColor_NULL(x, y: integer; out Value: TFPColor);
|
||||||
// 32 bpp alpha
|
// 32 bpp alpha
|
||||||
procedure GetColor_BPP32_A8R8G8B8_BIO_TTB(x, y: integer; out Value: TFPColor);
|
procedure GetColor_BPP32_A8R8G8B8_BIO_TTB(x, y: integer; out Value: TFPColor);
|
||||||
@ -194,6 +195,7 @@ type
|
|||||||
procedure SetColor_RGBA_NoPalette(x, y: integer; const Value: TFPColor);
|
procedure SetColor_RGBA_NoPalette(x, y: integer; const Value: TFPColor);
|
||||||
procedure SetColor_RGB_NoPalette(x, y: integer; const Value: TFPColor);
|
procedure SetColor_RGB_NoPalette(x, y: integer; const Value: TFPColor);
|
||||||
procedure SetColor_Gray_NoPalette(x, y: integer; const Value: TFPColor);
|
procedure SetColor_Gray_NoPalette(x, y: integer; const Value: TFPColor);
|
||||||
|
procedure SetColor_GrayAlpha_NoPalette(x, y: integer; const Value: TFPColor);
|
||||||
procedure SetColor_NULL(x, y: integer; const Value: TFPColor);
|
procedure SetColor_NULL(x, y: integer; const Value: TFPColor);
|
||||||
// 32 bpp alpha
|
// 32 bpp alpha
|
||||||
procedure SetColor_BPP32_A8R8G8B8_BIO_TTB(x, y: integer; const Value: TFPColor);
|
procedure SetColor_BPP32_A8R8G8B8_BIO_TTB(x, y: integer; const Value: TFPColor);
|
||||||
@ -1762,8 +1764,16 @@ begin
|
|||||||
ByteOrder,
|
ByteOrder,
|
||||||
BitOrder,
|
BitOrder,
|
||||||
FReadRawImageBits, FWriteRawImageBits);
|
FReadRawImageBits, FWriteRawImageBits);
|
||||||
FGetInternalColorProc := @GetColor_Gray_NoPalette;
|
|
||||||
FSetInternalColorProc := @SetColor_Gray_NoPalette;
|
if AlphaPrec = 0
|
||||||
|
then begin
|
||||||
|
FGetInternalColorProc := @GetColor_Gray_NoPalette;
|
||||||
|
FSetInternalColorProc := @SetColor_Gray_NoPalette;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
FGetInternalColorProc := @GetColor_GrayAlpha_NoPalette;
|
||||||
|
FSetInternalColorProc := @SetColor_GrayAlpha_NoPalette;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
@ -1878,6 +1888,20 @@ begin
|
|||||||
Value.Alpha:=high(Value.Alpha);
|
Value.Alpha:=high(Value.Alpha);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLazIntfImage.GetColor_GrayAlpha_NoPalette(x, y: integer; out Value: TFPColor);
|
||||||
|
var
|
||||||
|
Position: TRawImagePosition;
|
||||||
|
begin
|
||||||
|
GetXYDataPosition(x,y,Position);
|
||||||
|
with FRawImage.Description do
|
||||||
|
begin
|
||||||
|
FReadRawImageBits(FRawImage.Data, Position, RedPrec, RedShift, Value.Red);
|
||||||
|
FReadRawImageBits(FRawImage.Data, Position, AlphaPrec, AlphaShift, Value.Alpha);
|
||||||
|
end;
|
||||||
|
Value.Green := Value.Red;
|
||||||
|
Value.Blue := Value.Red;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TLazIntfImage.GetColor_BPP32_A8B8G8R8_BIO_TTB(x, y: integer; out Value: TFPColor);
|
procedure TLazIntfImage.GetColor_BPP32_A8B8G8R8_BIO_TTB(x, y: integer; out Value: TFPColor);
|
||||||
var
|
var
|
||||||
VBytes: TFPColorBytes absolute Value;
|
VBytes: TFPColorBytes absolute Value;
|
||||||
@ -2511,6 +2535,19 @@ begin
|
|||||||
FWriteRawImageBits(FRawImage.Data, Position, RedPrec, RedShift, Value.Red);
|
FWriteRawImageBits(FRawImage.Data, Position, RedPrec, RedShift, Value.Red);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TLazIntfImage.SetColor_GrayAlpha_NoPalette(x, y: integer; const Value: TFPColor);
|
||||||
|
var
|
||||||
|
Position: TRawImagePosition;
|
||||||
|
begin
|
||||||
|
GetXYDataPosition(x,y,Position);
|
||||||
|
with FRawImage.Description do
|
||||||
|
begin
|
||||||
|
FWriteRawImageBits(FRawImage.Data, Position, RedPrec, RedShift, Value.Red);
|
||||||
|
FWriteRawImageBits(FRawImage.Data, Position, AlphaPrec, AlphaShift, Value.Alpha)
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TLazIntfImage.SetColor_NULL(x, y: integer; const Value: TFPColor);
|
procedure TLazIntfImage.SetColor_NULL(x, y: integer; const Value: TFPColor);
|
||||||
begin
|
begin
|
||||||
// NULL, not implemented
|
// NULL, not implemented
|
||||||
@ -5615,17 +5652,29 @@ begin
|
|||||||
else begin
|
else begin
|
||||||
// no palette, adjust description
|
// no palette, adjust description
|
||||||
if IsGray
|
if IsGray
|
||||||
then Desc.Depth := Header.BitDepth
|
then begin
|
||||||
else if IsAlpha
|
Desc.RedPrec := Header.BitDepth;
|
||||||
then Desc.Depth := 4 * Header.BitDepth
|
Desc.RedShift := 0;
|
||||||
else Desc.Depth := 3 * Header.BitDepth;
|
if IsAlpha
|
||||||
|
then begin
|
||||||
|
Desc.BitsPerPixel := 2 * Header.BitDepth;
|
||||||
|
Desc.AlphaPrec := Header.BitDepth;
|
||||||
|
Desc.AlphaShift := Header.BitDepth;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
Desc.BitsPerPixel := Header.BitDepth;
|
||||||
|
end;
|
||||||
|
Desc.Depth := Desc.BitsPerPixel;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
if IsAlpha
|
||||||
|
then Desc.Depth := 4 * Header.BitDepth
|
||||||
|
else Desc.Depth := 3 * Header.BitDepth
|
||||||
|
end;
|
||||||
|
|
||||||
case Header.BitDepth of
|
case Header.BitDepth of
|
||||||
1,2,4: begin
|
1,2,4: begin
|
||||||
// only gray
|
// only gray
|
||||||
Desc.BitsPerPixel := Header.BitDepth;
|
|
||||||
Desc.RedPrec := Header.BitDepth;
|
|
||||||
Desc.RedShift := 0;
|
|
||||||
end;
|
end;
|
||||||
8: begin
|
8: begin
|
||||||
// no change
|
// no change
|
||||||
@ -5761,16 +5810,18 @@ begin
|
|||||||
// no palette, adjust description
|
// no palette, adjust description
|
||||||
if IsGray
|
if IsGray
|
||||||
then begin
|
then begin
|
||||||
|
Desc.RedPrec := FirstImg.GrayBits;
|
||||||
|
Desc.RedShift := 0;
|
||||||
if IsAlpha
|
if IsAlpha
|
||||||
then begin
|
then begin
|
||||||
Desc.Depth := FirstImg.GrayBits + FirstImg.AlphaBits;
|
Desc.Depth := FirstImg.GrayBits + FirstImg.AlphaBits;
|
||||||
|
Desc.AlphaPrec := FirstImg.AlphaBits;
|
||||||
|
Desc.AlphaShift := FirstImg.GrayBits;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
Desc.Depth := FirstImg.GrayBits;
|
Desc.Depth := FirstImg.GrayBits;
|
||||||
Desc.BitsPerPixel := FirstImg.GrayBits;
|
Desc.BitsPerPixel := FirstImg.GrayBits;
|
||||||
end;
|
end;
|
||||||
Desc.RedPrec := FirstImg.GrayBits;
|
|
||||||
Desc.RedShift := 0;
|
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
Desc.Depth := FirstImg.RedBits + FirstImg.GreenBits + FirstImg.BlueBits + FirstImg.AlphaBits;
|
Desc.Depth := FirstImg.RedBits + FirstImg.GreenBits + FirstImg.BlueBits + FirstImg.AlphaBits;
|
||||||
|
Loading…
Reference in New Issue
Block a user