From 2c08ce8b53fd66bf783d7687d0ec013f57b4e49f Mon Sep 17 00:00:00 2001 From: yangjixian Date: Mon, 18 Apr 2011 16:36:18 +0000 Subject: [PATCH] Fixed the bugs of DLBitmap.pas on Linux. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1577 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/lazimageeditor/DLBitmap.pas | 30 +++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/applications/lazimageeditor/DLBitmap.pas b/applications/lazimageeditor/DLBitmap.pas index c0ab794ca..c6602dc4b 100644 --- a/applications/lazimageeditor/DLBitmap.pas +++ b/applications/lazimageeditor/DLBitmap.pas @@ -10,10 +10,10 @@ uses type tagRGBATRIPLE = record - rgbtBlue: Byte; - rgbtGreen: Byte; - rgbtRed: Byte; - rgbtAlpha: Byte; + rgbtBlue: byte; + rgbtGreen: byte; + rgbtRed: byte; + rgbtAlpha: byte; end; PRGBATriple = ^TRGBATriple; TRGBATriple = tagRGBATRIPLE; @@ -68,8 +68,7 @@ procedure BMPRotate90(const Bitmap: TDLBitmap); procedure DrawSamePixel(ABitmap: TDLBitmap; Value: integer); procedure BMPRotate180(const Bitmap: TDLBitmap); procedure BMPRotate270(const Bitmap: TDLBitmap); -function RotateBitmap(Bitmap: TDLBitmap; Angle: integer; - BackColor: TColor): TDLBitmap; +function RotateBitmap(Bitmap: TDLBitmap; Angle: integer; BackColor: TColor): TDLBitmap; function BitmapFlip(const Vertical: boolean; const Horizontal: boolean; var BitmapIn: TDLBitmap; out BitmapOut: TDLBitmap): boolean; procedure InvertBitmap(aBitmap: TDLBitmap); @@ -88,7 +87,11 @@ begin Bmp := TDLBitmap.Create; Bmp.Width := aBitmap.Height; Bmp.Height := aBitmap.Width; + {$ifdef MSWINDOWS} Bmp.PixelFormat := pf32bit; + {$else} + Bmp.PixelFormat := pf24bit; + {$endif} IntfImg1 := TLazIntfImage.Create(0, 0); IntfImg1.LoadFromBitmap(Bmp.Handle, Bmp.MaskHandle); IntfImg2 := TLazIntfImage.Create(0, 0); @@ -196,8 +199,7 @@ begin Bitmap.Assign(Bmp); end; -function RotateBitmap(Bitmap: TDLBitmap; Angle: integer; - BackColor: TColor): TDLBitmap; +function RotateBitmap(Bitmap: TDLBitmap; Angle: integer; BackColor: TColor): TDLBitmap; var i, j, iOriginal, jOriginal, CosPoint, SinPoint: integer; RowOriginal, RowRotated: pRGBATriple; @@ -331,9 +333,9 @@ begin for j := 0 to ABitmap.Width - 1 do begin LNew := LScan[j]; - LScan[j].rgbtBlue := LScan[j].rgbtBlue * Value div 100; - LScan[j].rgbtGreen := LScan[j].rgbtGreen * Value div 100; - LScan[j].rgbtRed := LScan[j].rgbtRed * Value div 100; + LScan[j].rgbtBlue := LScan[j].rgbtBlue * Value div 100; //Value; //LNew.rgbtBlue; + LScan[j].rgbtGreen := LScan[j].rgbtGreen * Value div 100; //LNew.rgbtGreen; + LScan[j].rgbtRed := LScan[j].rgbtRed * Value div 100; //LNew.rgbtRed; end; end; ABitmap.InvalidateScanLine; @@ -349,6 +351,8 @@ var begin Result := False; try + if BitmapIn.PixelFormat <> pf24bit then + Exit; with BitmapOut do begin Width := BitmapIn.Width; @@ -429,7 +433,11 @@ end; constructor TDLBitmap.Create; begin inherited; + {$ifdef MSWINDOWS} PixelFormat := pf32bit; + {$else} + PixelFormat := pf24bit; + {$endif} FIntfImgA := TLazIntfImage.Create(0, 0); end;