From beec66d795c1ba19d5a480b59b9a5c84740911ed Mon Sep 17 00:00:00 2001 From: tombo Date: Wed, 9 Apr 2008 09:54:12 +0000 Subject: [PATCH] LCL IntfGraphics: fixed bug #0011109: Bitmap "Invalid Size" error. - Mac OS X - Leopard - negative height in bmp header only means bitmap data is not upside-down git-svn-id: trunk@14792 - --- lcl/intfgraphics.pas | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lcl/intfgraphics.pas b/lcl/intfgraphics.pas index b791e4c8fe..375d969d94 100644 --- a/lcl/intfgraphics.pas +++ b/lcl/intfgraphics.pas @@ -4654,7 +4654,8 @@ begin { This will move past any junk after the BFI header } TheStream.Position := TheStream.Position + TStreamSeekType(BFI.biSize-SizeOf(BFI)); - TheImage.SetSize(BFI.biWidth, BFI.biHeight); + TheImage.SetSize(BFI.biWidth, Abs(BFI.biHeight)); + // Note for Abs - height can be negative if bitmap data is not stored upside-down FBitsPerPixel := BFI.biBitCount; case BFI.biBitCount of @@ -4765,13 +4766,21 @@ begin Row := TheImage.Height - 1; ReadScanLine(Row); SaveTransparentColor; - WriteScanLine(Row); + + if BFI.biHeight > 0 then + WriteScanLine(Row) // upside-down + else + WriteScanLine(TheImage.Height - 1 - Row); while Row > 0 do begin Dec(Row); ReadScanLine(Row); // Scanline in LineBuf with Size ReadSize. - WriteScanLine(Row); + + if BFI.biHeight > 0 then + WriteScanLine(Row) // upside-down + else + WriteScanLine(TheImage.Height - 1 - Row); end; finally FreeBufs;