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
This commit is contained in:
yangjixian
2011-04-18 16:36:18 +00:00
parent 71399e7d4d
commit 2c08ce8b53

View File

@ -10,10 +10,10 @@ uses
type type
tagRGBATRIPLE = record tagRGBATRIPLE = record
rgbtBlue: Byte; rgbtBlue: byte;
rgbtGreen: Byte; rgbtGreen: byte;
rgbtRed: Byte; rgbtRed: byte;
rgbtAlpha: Byte; rgbtAlpha: byte;
end; end;
PRGBATriple = ^TRGBATriple; PRGBATriple = ^TRGBATriple;
TRGBATriple = tagRGBATRIPLE; TRGBATriple = tagRGBATRIPLE;
@ -68,8 +68,7 @@ procedure BMPRotate90(const Bitmap: TDLBitmap);
procedure DrawSamePixel(ABitmap: TDLBitmap; Value: integer); procedure DrawSamePixel(ABitmap: TDLBitmap; Value: integer);
procedure BMPRotate180(const Bitmap: TDLBitmap); procedure BMPRotate180(const Bitmap: TDLBitmap);
procedure BMPRotate270(const Bitmap: TDLBitmap); procedure BMPRotate270(const Bitmap: TDLBitmap);
function RotateBitmap(Bitmap: TDLBitmap; Angle: integer; function RotateBitmap(Bitmap: TDLBitmap; Angle: integer; BackColor: TColor): TDLBitmap;
BackColor: TColor): TDLBitmap;
function BitmapFlip(const Vertical: boolean; const Horizontal: boolean; function BitmapFlip(const Vertical: boolean; const Horizontal: boolean;
var BitmapIn: TDLBitmap; out BitmapOut: TDLBitmap): boolean; var BitmapIn: TDLBitmap; out BitmapOut: TDLBitmap): boolean;
procedure InvertBitmap(aBitmap: TDLBitmap); procedure InvertBitmap(aBitmap: TDLBitmap);
@ -88,7 +87,11 @@ begin
Bmp := TDLBitmap.Create; Bmp := TDLBitmap.Create;
Bmp.Width := aBitmap.Height; Bmp.Width := aBitmap.Height;
Bmp.Height := aBitmap.Width; Bmp.Height := aBitmap.Width;
{$ifdef MSWINDOWS}
Bmp.PixelFormat := pf32bit; Bmp.PixelFormat := pf32bit;
{$else}
Bmp.PixelFormat := pf24bit;
{$endif}
IntfImg1 := TLazIntfImage.Create(0, 0); IntfImg1 := TLazIntfImage.Create(0, 0);
IntfImg1.LoadFromBitmap(Bmp.Handle, Bmp.MaskHandle); IntfImg1.LoadFromBitmap(Bmp.Handle, Bmp.MaskHandle);
IntfImg2 := TLazIntfImage.Create(0, 0); IntfImg2 := TLazIntfImage.Create(0, 0);
@ -196,8 +199,7 @@ begin
Bitmap.Assign(Bmp); Bitmap.Assign(Bmp);
end; end;
function RotateBitmap(Bitmap: TDLBitmap; Angle: integer; function RotateBitmap(Bitmap: TDLBitmap; Angle: integer; BackColor: TColor): TDLBitmap;
BackColor: TColor): TDLBitmap;
var var
i, j, iOriginal, jOriginal, CosPoint, SinPoint: integer; i, j, iOriginal, jOriginal, CosPoint, SinPoint: integer;
RowOriginal, RowRotated: pRGBATriple; RowOriginal, RowRotated: pRGBATriple;
@ -331,9 +333,9 @@ begin
for j := 0 to ABitmap.Width - 1 do for j := 0 to ABitmap.Width - 1 do
begin begin
LNew := LScan[j]; LNew := LScan[j];
LScan[j].rgbtBlue := LScan[j].rgbtBlue * Value div 100; LScan[j].rgbtBlue := LScan[j].rgbtBlue * Value div 100; //Value; //LNew.rgbtBlue;
LScan[j].rgbtGreen := LScan[j].rgbtGreen * Value div 100; LScan[j].rgbtGreen := LScan[j].rgbtGreen * Value div 100; //LNew.rgbtGreen;
LScan[j].rgbtRed := LScan[j].rgbtRed * Value div 100; LScan[j].rgbtRed := LScan[j].rgbtRed * Value div 100; //LNew.rgbtRed;
end; end;
end; end;
ABitmap.InvalidateScanLine; ABitmap.InvalidateScanLine;
@ -349,6 +351,8 @@ var
begin begin
Result := False; Result := False;
try try
if BitmapIn.PixelFormat <> pf24bit then
Exit;
with BitmapOut do with BitmapOut do
begin begin
Width := BitmapIn.Width; Width := BitmapIn.Width;
@ -429,7 +433,11 @@ end;
constructor TDLBitmap.Create; constructor TDLBitmap.Create;
begin begin
inherited; inherited;
{$ifdef MSWINDOWS}
PixelFormat := pf32bit; PixelFormat := pf32bit;
{$else}
PixelFormat := pf24bit;
{$endif}
FIntfImgA := TLazIntfImage.Create(0, 0); FIntfImgA := TLazIntfImage.Create(0, 0);
end; end;