mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 12:00:29 +02:00
Gtk, Gtk2: fixed drawing bitmaps with pf32bit. issue #8553
git-svn-id: trunk@35177 -
This commit is contained in:
parent
8cb0f814ef
commit
0e876bd527
@ -250,10 +250,12 @@ var
|
||||
Data: Pointer;
|
||||
Src, Dst, SrcRowPtr, DstRowPtr: PByte;
|
||||
x, y: Cardinal;
|
||||
CreateWithAlpha: boolean;
|
||||
begin
|
||||
Result := False;
|
||||
ABitmap := 0;
|
||||
AMask := 0;
|
||||
CreateWithAlpha := True;
|
||||
|
||||
if ImgWidth = 0 then Exit;
|
||||
if ImgHeight = 0 then Exit;
|
||||
@ -343,10 +345,21 @@ begin
|
||||
end
|
||||
else begin
|
||||
// components are in place
|
||||
|
||||
// gtkPixbuf doesn't like invalid dataSize/MaskSize < 32. issue #8553.
|
||||
if (ARawImage.MaskSize > 0) and (ImgDepth = 32) then
|
||||
begin
|
||||
CreateWithAlpha := Trunc(ARawImage.DataSize / ARawImage.MaskSize) = 32;
|
||||
{$IFDEF VerboseRawImage}
|
||||
if not CreateWithAlpha then
|
||||
DebugLn('TGtkWidgetSet.CreateBitmapFromRawImage B WARNING: This image have invalid DataSize / MaskSize.');
|
||||
{$ENDIF}
|
||||
end;
|
||||
Data := ImgData;
|
||||
end;
|
||||
|
||||
TmpPixBuf := gdk_pixbuf_new_from_data(Data, GDK_COLORSPACE_RGB, True, 8, ImgWidth, ImgHeight, RowStride, nil, nil);
|
||||
TmpPixBuf := gdk_pixbuf_new_from_data(Data, GDK_COLORSPACE_RGB, CreateWithAlpha,
|
||||
8, ImgWidth, ImgHeight, RowStride, nil, nil);
|
||||
// we need to copy our pixbuf into a new one to allow data deallocation
|
||||
Pixbuf := gdk_pixbuf_copy(TmpPixBuf);
|
||||
gdk_pixbuf_unref(TmpPixBuf);
|
||||
|
@ -265,6 +265,7 @@ var
|
||||
Data: Pointer;
|
||||
Src, Dst, SrcRowPtr, DstRowPtr: PByte;
|
||||
x, y: Cardinal;
|
||||
CreateWithAlpha: boolean;
|
||||
begin
|
||||
Result := False;
|
||||
ABitmap := 0;
|
||||
@ -273,6 +274,7 @@ begin
|
||||
if ImgWidth = 0 then Exit;
|
||||
if ImgHeight = 0 then Exit;
|
||||
|
||||
CreateWithAlpha := True;
|
||||
try
|
||||
{$IFDEF VerboseRawImage}
|
||||
DebugLn('TGtk2WidgetSet.CreateBitmapFromRawImage A ',
|
||||
@ -328,8 +330,8 @@ begin
|
||||
// check if the pixels are in order, pixbuf expects them in R-G-B-A
|
||||
Desc.GetRGBIndices(Ridx, Gidx, Bidx, AIdx);
|
||||
|
||||
if (Ridx <> 0) or (Gidx <> 1) or (Bidx <> 2) or (AIdx <> 3)
|
||||
then begin
|
||||
if (Ridx <> 0) or (Gidx <> 1) or (Bidx <> 2) or (AIdx <> 3) then
|
||||
begin
|
||||
// put components in right order
|
||||
GetMem(Data, ImgDataSize);
|
||||
DstRowPtr := Data;
|
||||
@ -358,10 +360,22 @@ begin
|
||||
end
|
||||
else begin
|
||||
// components are in place
|
||||
|
||||
// gtkPixbuf doesn't like invalid dataSize/MaskSize < 32. issue #8553.
|
||||
if (ARawImage.MaskSize > 0) and (ImgDepth = 32) then
|
||||
begin
|
||||
CreateWithAlpha := Trunc(ARawImage.DataSize / ARawImage.MaskSize) = 32;
|
||||
{$IFDEF VerboseRawImage}
|
||||
if not CreateWithAlpha then
|
||||
DebugLn('TGtk2WidgetSet.CreateBitmapFromRawImage B WARNING: This image have invalid DataSize / MaskSize.');
|
||||
{$ENDIF}
|
||||
end;
|
||||
Data := ImgData;
|
||||
end;
|
||||
|
||||
TmpPixBuf := gdk_pixbuf_new_from_data(Data, GDK_COLORSPACE_RGB, True, 8, ImgWidth, ImgHeight, RowStride, nil, nil);
|
||||
TmpPixBuf := gdk_pixbuf_new_from_data(Data, GDK_COLORSPACE_RGB, CreateWithAlpha,
|
||||
8, ImgWidth, ImgHeight, RowStride, nil, nil);
|
||||
|
||||
// we need to copy our pixbuf into a new one to allow data deallocation
|
||||
Pixbuf := gdk_pixbuf_copy(TmpPixBuf);
|
||||
gdk_pixbuf_unref(TmpPixBuf);
|
||||
|
Loading…
Reference in New Issue
Block a user