Gtk2: better guess for invalid mask. issue #21616

git-svn-id: trunk@36481 -
This commit is contained in:
zeljko 2012-03-31 13:51:05 +00:00
parent 69f2bc9bd7
commit a4f13f7bd2

View File

@ -266,6 +266,7 @@ var
Src, Dst, SrcRowPtr, DstRowPtr: PByte; Src, Dst, SrcRowPtr, DstRowPtr: PByte;
x, y: Cardinal; x, y: Cardinal;
CreateWithAlpha: boolean; CreateWithAlpha: boolean;
ADivResult, ARemainder: DWord;
begin begin
Result := False; Result := False;
ABitmap := 0; ABitmap := 0;
@ -364,7 +365,11 @@ begin
// gtkPixbuf doesn't like invalid dataSize/MaskSize < 32. issue #8553. // gtkPixbuf doesn't like invalid dataSize/MaskSize < 32. issue #8553.
if (ARawImage.MaskSize > 0) and (ImgDepth = 32) then if (ARawImage.MaskSize > 0) and (ImgDepth = 32) then
begin begin
CreateWithAlpha := Trunc(ARawImage.DataSize / ARawImage.MaskSize) = 32; // seem that gdkPixbuf does not like many of our masks
ADivResult := 0;
ARemainder := 0;
DivMod(ARawImage.DataSize, ARawImage.MaskSize, ADivResult, ARemainder);
CreateWithAlpha := ARemainder = 0;
{$IFDEF VerboseRawImage} {$IFDEF VerboseRawImage}
if not CreateWithAlpha then if not CreateWithAlpha then
DebugLn('TGtk2WidgetSet.CreateBitmapFromRawImage B WARNING: This image have invalid DataSize / MaskSize.'); DebugLn('TGtk2WidgetSet.CreateBitmapFromRawImage B WARNING: This image have invalid DataSize / MaskSize.');