You've already forked lazarus-ccr
Rename the bitmap process unit to DLBitmap.pas and the PixelFormat changed to pf32bit.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1571 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
672
applications/lazimageeditor/DLBitmap.pas
Normal file
672
applications/lazimageeditor/DLBitmap.pas
Normal file
@ -0,0 +1,672 @@
|
||||
unit DLBitmap;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLType, LCLIntf, LMessages, LCLProc, Controls, Graphics,
|
||||
Forms, Types, IntfGraphics, FPImage, Math, FPImgCanv, FPCanvas, ClipBrd;
|
||||
|
||||
type
|
||||
tagRGBATRIPLE = record
|
||||
rgbtBlue: Byte;
|
||||
rgbtGreen: Byte;
|
||||
rgbtRed: Byte;
|
||||
rgbtAlpha: Byte;
|
||||
end;
|
||||
PRGBATriple = ^TRGBATriple;
|
||||
TRGBATriple = tagRGBATRIPLE;
|
||||
PRGBATripleArray = ^TRGBATripleArray;
|
||||
TRGBATripleArray = array[word] of TRGBATriple;
|
||||
|
||||
TDLBitmap = class(TBitmap)
|
||||
private
|
||||
FIntfImgA: TLazIntfImage;
|
||||
FFillColor: TColor;
|
||||
FOutlineColor: TColor;
|
||||
FPaperColor: TColor;
|
||||
function GetScanline(Row: integer): pRGBATriple;
|
||||
function GetFillColor: TColor;
|
||||
function GetOutlineColor: TColor;
|
||||
function GetPaperColor: TColor;
|
||||
procedure SetFillColor(const AValue: TColor);
|
||||
procedure SetOutlineColor(const AValue: TColor);
|
||||
procedure SetPaperColor(const AValue: TColor);
|
||||
protected
|
||||
procedure SetWidth(Value: integer); override;
|
||||
procedure SetHeight(Value: integer); override;
|
||||
procedure Changed(Sender: TObject); override;
|
||||
public
|
||||
constructor Create; override;
|
||||
destructor Destroy; override;
|
||||
procedure ResetScanLine;
|
||||
procedure InvalidateScanLine;
|
||||
procedure Assign(Source: TPersistent); override;
|
||||
procedure Clear; virtual;
|
||||
procedure ClearWhite; virtual;
|
||||
procedure Invert; virtual;
|
||||
procedure Grayscale; virtual;
|
||||
procedure FlipHorz; virtual;
|
||||
procedure FlipVert; virtual;
|
||||
procedure Rotate90; virtual;
|
||||
procedure Rotate180; virtual;
|
||||
procedure Rotate270; virtual;
|
||||
property ScanLine[Row: integer]: pRGBATriple read GetScanLine;
|
||||
procedure FillEllipse(X1, Y1, X2, Y2: integer); virtual;
|
||||
procedure CutToClipboard; virtual;
|
||||
procedure CopyToClipboard; virtual;
|
||||
procedure PasteFromClipboard; virtual;
|
||||
procedure Delete; virtual;
|
||||
property FillColor: TColor read GetFillColor write SetFillColor;
|
||||
property OutlineColor: TColor read GetOutlineColor write SetOutlineColor;
|
||||
property PaperColor: TColor read GetPaperColor write SetPaperColor;
|
||||
end;
|
||||
|
||||
procedure LazBMPRotate90(const aBitmap: TDLBitmap; IsTurnRight: boolean);
|
||||
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 BitmapFlip(const Vertical: boolean; const Horizontal: boolean;
|
||||
var BitmapIn: TDLBitmap; out BitmapOut: TDLBitmap): boolean;
|
||||
procedure InvertBitmap(aBitmap: TDLBitmap);
|
||||
|
||||
implementation
|
||||
|
||||
procedure LazBMPRotate90(const aBitmap: TDLBitmap; IsTurnRight: boolean);
|
||||
var
|
||||
i, j: integer;
|
||||
rowIn, rowOut: PRGBATripleArray;
|
||||
Bmp: TDLBitmap;
|
||||
Width, Height: integer;
|
||||
IntfImg1, IntfImg2: TLazIntfImage;
|
||||
ImgHandle, ImgMaskHandle: HBitmap;
|
||||
begin
|
||||
Bmp := TDLBitmap.Create;
|
||||
Bmp.Width := aBitmap.Height;
|
||||
Bmp.Height := aBitmap.Width;
|
||||
Bmp.PixelFormat := pf32bit;
|
||||
IntfImg1 := TLazIntfImage.Create(0, 0);
|
||||
IntfImg1.LoadFromBitmap(Bmp.Handle, Bmp.MaskHandle);
|
||||
IntfImg2 := TLazIntfImage.Create(0, 0);
|
||||
IntfImg2.LoadFromBitmap(aBitmap.Handle, aBitmap.MaskHandle);
|
||||
Width := aBitmap.Width - 1;
|
||||
Height := aBitmap.Height - 1;
|
||||
for j := 0 to Height do
|
||||
begin
|
||||
rowIn := IntfImg2.GetDataLineStart(j);
|
||||
for i := 0 to Width do
|
||||
begin
|
||||
rowOut := IntfImg1.GetDataLineStart(i);
|
||||
if IsTurnRight then
|
||||
rowOut^[Height - j] := rowIn^[i]
|
||||
else
|
||||
rowOut^[j] := rowIn^[Width - i];
|
||||
end;
|
||||
end;
|
||||
IntfImg1.CreateBitmaps(ImgHandle, ImgMaskHandle, False);
|
||||
Bmp.Handle := ImgHandle;
|
||||
Bmp.MaskHandle := ImgMaskHandle;
|
||||
IntfImg1.Free;
|
||||
IntfImg2.Free;
|
||||
aBitmap.Assign(Bmp);
|
||||
Bmp.Free;
|
||||
end;
|
||||
|
||||
procedure BMPRotate90(const Bitmap: TDLBitmap);
|
||||
var
|
||||
i, j: integer;
|
||||
rowIn, rowOut: pRGBATriple;
|
||||
Bmp: TDLBitmap;
|
||||
Width, Height: integer;
|
||||
begin
|
||||
Bmp := TDLBitmap.Create;
|
||||
Bmp.Width := Bitmap.Height;
|
||||
Bmp.Height := Bitmap.Width;
|
||||
Width := Bitmap.Width - 1;
|
||||
Height := Bitmap.Height - 1;
|
||||
for j := 0 to Height do
|
||||
begin
|
||||
rowIn := Bitmap.ScanLine[j];
|
||||
for i := 0 to Width do
|
||||
begin
|
||||
rowOut := Bmp.ScanLine[i];
|
||||
rowOut[Height - j] := rowIn[i];
|
||||
end;
|
||||
end;
|
||||
Bmp.InvalidateScanLine;
|
||||
Bitmap.Assign(Bmp);
|
||||
end;
|
||||
|
||||
procedure BMPRotate180(const Bitmap: TDLBitmap);
|
||||
var
|
||||
i, j: integer;
|
||||
rowIn, rowOut: pRGBATriple;
|
||||
Bmp: TDLBitmap;
|
||||
Width, Height: integer;
|
||||
begin
|
||||
Bmp := TDLBitmap.Create;
|
||||
Bmp.Width := Bitmap.Width;
|
||||
Bmp.Height := Bitmap.Height;
|
||||
Width := Bitmap.Width - 1;
|
||||
Height := Bitmap.Height - 1;
|
||||
for j := 0 to Height do
|
||||
begin
|
||||
rowIn := Bitmap.ScanLine[j];
|
||||
for i := 0 to Width do
|
||||
begin
|
||||
rowOut := Bmp.ScanLine[Height - j];
|
||||
Inc(rowOut, Width - i);
|
||||
rowOut^ := rowIn^;
|
||||
Inc(rowIn);
|
||||
end;
|
||||
end;
|
||||
Bmp.InvalidateScanLine;
|
||||
Bitmap.InvalidateScanLine;
|
||||
Bitmap.Assign(Bmp);
|
||||
end;
|
||||
|
||||
procedure BMPRotate270(const Bitmap: TDLBitmap);
|
||||
var
|
||||
i, j: integer;
|
||||
rowIn, rowOut: pRGBATriple;
|
||||
Bmp: TDLBitmap;
|
||||
Width, Height: integer;
|
||||
begin
|
||||
Bmp := TDLBitmap.Create;
|
||||
Bmp.Width := Bitmap.Height;
|
||||
Bmp.Height := Bitmap.Width;
|
||||
Width := Bitmap.Width - 1;
|
||||
Height := Bitmap.Height - 1;
|
||||
for j := 0 to Height do
|
||||
begin
|
||||
rowIn := Bitmap.ScanLine[j];
|
||||
for i := 0 to Width do
|
||||
begin
|
||||
rowOut := Bmp.ScanLine[Width - i];
|
||||
Inc(rowOut, j);
|
||||
rowOut^ := rowIn^;
|
||||
Inc(rowIn);
|
||||
end;
|
||||
end;
|
||||
Bmp.InvalidateScanLine;
|
||||
Bitmap.Assign(Bmp);
|
||||
end;
|
||||
|
||||
function RotateBitmap(Bitmap: TDLBitmap; Angle: integer;
|
||||
BackColor: TColor): TDLBitmap;
|
||||
var
|
||||
i, j, iOriginal, jOriginal, CosPoint, SinPoint: integer;
|
||||
RowOriginal, RowRotated: pRGBATriple;
|
||||
SinTheta, CosTheta: extended;
|
||||
AngleAdd: integer;
|
||||
begin
|
||||
Result := TDLBitmap.Create;
|
||||
Result.Canvas.Brush.Color := BackColor;
|
||||
Angle := Angle mod 360;
|
||||
if Angle < 0 then
|
||||
Angle := 360 - Abs(Angle);
|
||||
if Angle = 0 then
|
||||
Result.Assign(Bitmap)
|
||||
else if Angle = 90 then
|
||||
begin
|
||||
Result.Assign(Bitmap);
|
||||
BMPRotate90(Result);
|
||||
end
|
||||
else if (Angle > 90) and (Angle < 180) then
|
||||
begin
|
||||
AngleAdd := 90;
|
||||
Angle := Angle - AngleAdd;
|
||||
end
|
||||
else if Angle = 180 then
|
||||
begin
|
||||
Result.Assign(Bitmap);
|
||||
BMPRotate180(Result);
|
||||
end
|
||||
else if (Angle > 180) and (Angle < 270) then
|
||||
begin
|
||||
AngleAdd := 180;
|
||||
Angle := Angle - AngleAdd;
|
||||
end
|
||||
else if Angle = 270 then
|
||||
begin
|
||||
Result.Assign(Bitmap);
|
||||
BMPRotate270(Result);
|
||||
end
|
||||
else if (Angle > 270) and (Angle < 360) then
|
||||
begin
|
||||
AngleAdd := 270;
|
||||
Angle := Angle - AngleAdd;
|
||||
end
|
||||
else
|
||||
AngleAdd := 0;
|
||||
if (Angle > 0) and (Angle < 90) then
|
||||
begin
|
||||
SinCos((Angle + AngleAdd) * Pi / 180, SinTheta, CosTheta);
|
||||
if (SinTheta * CosTheta) < 0 then
|
||||
begin
|
||||
Result.Width := Round(Abs(Bitmap.Width * CosTheta - Bitmap.Height * SinTheta));
|
||||
Result.Height := Round(Abs(Bitmap.Width * SinTheta - Bitmap.Height * CosTheta));
|
||||
end
|
||||
else
|
||||
begin
|
||||
Result.Width := Round(Abs(Bitmap.Width * CosTheta + Bitmap.Height * SinTheta));
|
||||
Result.Height := Round(Abs(Bitmap.Width * SinTheta + Bitmap.Height * CosTheta));
|
||||
end;
|
||||
CosTheta := Abs(CosTheta);
|
||||
SinTheta := Abs(SinTheta);
|
||||
if (AngleAdd = 0) or (AngleAdd = 180) then
|
||||
begin
|
||||
CosPoint := Round(Bitmap.Height * CosTheta);
|
||||
SinPoint := Round(Bitmap.Height * SinTheta);
|
||||
end
|
||||
else
|
||||
begin
|
||||
SinPoint := Round(Bitmap.Width * CosTheta);
|
||||
CosPoint := Round(Bitmap.Width * SinTheta);
|
||||
end;
|
||||
for j := 0 to Result.Height - 1 do
|
||||
begin
|
||||
RowRotated := Result.Scanline[j];
|
||||
for i := 0 to Result.Width - 1 do
|
||||
begin
|
||||
case AngleAdd of
|
||||
0:
|
||||
begin
|
||||
jOriginal := Round((j + 1) * CosTheta - (i + 1 - SinPoint) * SinTheta) - 1;
|
||||
iOriginal := Round((i + 1) * CosTheta - (CosPoint - j - 1) * SinTheta) - 1;
|
||||
end;
|
||||
90:
|
||||
begin
|
||||
iOriginal := Round((j + 1) * SinTheta - (i + 1 - SinPoint) * CosTheta) - 1;
|
||||
jOriginal := Bitmap.Height - Round((i + 1) * SinTheta -
|
||||
(CosPoint - j - 1) * CosTheta);
|
||||
end;
|
||||
180:
|
||||
begin
|
||||
jOriginal := Bitmap.Height - Round((j + 1) * CosTheta -
|
||||
(i + 1 - SinPoint) * SinTheta);
|
||||
iOriginal := Bitmap.Width - Round((i + 1) * CosTheta -
|
||||
(CosPoint - j - 1) * SinTheta);
|
||||
end;
|
||||
270:
|
||||
begin
|
||||
iOriginal := Bitmap.Width - Round((j + 1) * SinTheta -
|
||||
(i + 1 - SinPoint) * CosTheta);
|
||||
jOriginal := Round((i + 1) * SinTheta - (CosPoint - j - 1) * CosTheta) - 1;
|
||||
end;
|
||||
end;
|
||||
if (iOriginal >= 0) and (iOriginal <= Bitmap.Width - 1) and
|
||||
(jOriginal >= 0) and (jOriginal <= Bitmap.Height - 1) then
|
||||
begin
|
||||
RowOriginal := Bitmap.Scanline[jOriginal];
|
||||
Inc(RowOriginal, iOriginal);
|
||||
RowRotated^ := RowOriginal^;
|
||||
Inc(RowRotated);
|
||||
end
|
||||
else
|
||||
begin
|
||||
Inc(RowRotated);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
Result.InvalidateScanLine;
|
||||
Bitmap.InvalidateScanLine;
|
||||
end;
|
||||
|
||||
procedure DrawSamePixel(ABitmap: TDLBitmap; Value: integer);
|
||||
var
|
||||
LNew: TRGBATriple;
|
||||
LMinusRatio: real;
|
||||
LScan: pRGBATriple;
|
||||
i, j: integer;
|
||||
begin
|
||||
for i := 0 to ABitmap.Height - 1 do
|
||||
begin
|
||||
LScan := ABitmap.Scanline[i];
|
||||
for j := 0 to ABitmap.Width - 1 do
|
||||
begin
|
||||
LNew := LScan[j];
|
||||
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;
|
||||
end;
|
||||
|
||||
function BitmapFlip(const Vertical: boolean; const Horizontal: boolean;
|
||||
var BitmapIn: TDLBitmap; out BitmapOut: TDLBitmap): boolean;
|
||||
var
|
||||
DataIn: pRGBATriple;
|
||||
DataOut: pRGBATriple;
|
||||
inRow: integer;
|
||||
inCol: integer;
|
||||
begin
|
||||
Result := False;
|
||||
try
|
||||
with BitmapOut do
|
||||
begin
|
||||
Width := BitmapIn.Width;
|
||||
Height := BitmapIn.Height;
|
||||
PixelFormat := BitmapIn.PixelFormat;
|
||||
end;
|
||||
for inRow := 0 to BitmapIn.Height - 1 do
|
||||
begin
|
||||
DataIn := BitmapIn.Scanline[inRow];
|
||||
if Vertical then
|
||||
begin
|
||||
DataOut := BitmapOut.ScanLine[BitmapIn.Height - 1 - inRow];
|
||||
end
|
||||
else
|
||||
begin
|
||||
DataOut := BitmapOut.ScanLine[inRow];
|
||||
end;
|
||||
if Horizontal then
|
||||
begin
|
||||
for inCol := 0 to BitmapIn.Width - 1 do
|
||||
DataOut[inCol] := DataIn[BitmapIn.Width - 1 - inCol];
|
||||
end
|
||||
else
|
||||
begin
|
||||
for inCol := 0 to BitmapIn.Width - 1 do
|
||||
DataOut[inCol] := DataIn[inCol];
|
||||
end;
|
||||
end;
|
||||
Result := True;
|
||||
BitmapOut.InvalidateScanLine;
|
||||
except
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure InvertBitmap(aBitmap: TDLBitmap);
|
||||
var
|
||||
LNew: TRGBATriple;
|
||||
LMinusRatio: real;
|
||||
LScan: pRGBATriple;
|
||||
i, j: integer;
|
||||
begin
|
||||
for i := 0 to ABitmap.Height - 1 do
|
||||
begin
|
||||
LScan := ABitmap.Scanline[i];
|
||||
for j := 0 to ABitmap.Width - 1 do
|
||||
begin
|
||||
LNew := LScan[j];
|
||||
LScan[j].rgbtBlue := not LScan[j].rgbtBlue;
|
||||
LScan[j].rgbtGreen := not LScan[j].rgbtGreen;
|
||||
LScan[j].rgbtRed := not LScan[j].rgbtRed;
|
||||
end;
|
||||
end;
|
||||
ABitmap.InvalidateScanLine;
|
||||
end;
|
||||
|
||||
procedure ConvertBitmapToGrayScale(const Bitmap: TDLBitmap);
|
||||
var
|
||||
X: integer;
|
||||
Y: integer;
|
||||
P: pRGBATriple;
|
||||
Gray: byte;
|
||||
begin
|
||||
for Y := 0 to (Bitmap.Height - 1) do
|
||||
begin
|
||||
P := Bitmap.ScanLine[Y];
|
||||
for X := 0 to (Bitmap.Width - 1) do
|
||||
begin
|
||||
Gray := Round(0.30 * P[X].rgbtBlue + 0.59 * P[X].rgbtGreen +
|
||||
0.11 * P[X].rgbtRed);
|
||||
P[X].rgbtRed := Gray;
|
||||
P[X].rgbtGreen := Gray;
|
||||
P[X].rgbtBlue := Gray;
|
||||
end;
|
||||
end;
|
||||
Bitmap.InvalidateScanLine;
|
||||
end;
|
||||
|
||||
constructor TDLBitmap.Create;
|
||||
begin
|
||||
inherited;
|
||||
PixelFormat := pf32bit;
|
||||
FIntfImgA := TLazIntfImage.Create(0, 0);
|
||||
end;
|
||||
|
||||
destructor TDLBitmap.Destroy;
|
||||
begin
|
||||
FIntfImgA.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TDLBitmap.GetScanLine(Row: integer): pRGBATriple;
|
||||
begin
|
||||
if FIntfImgA <> nil then
|
||||
Result := FIntfImgA.GetDataLineStart(Row);
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.ResetScanLine;
|
||||
begin
|
||||
FIntfImgA.LoadFromBitmap(Handle, MaskHandle);
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.InvalidateScanLine;
|
||||
var
|
||||
TmpBmp: TDLBitmap;
|
||||
ImgHandle, ImgMaskHandle: HBitmap;
|
||||
begin
|
||||
TmpBmp := TDLBitmap.Create;
|
||||
FIntfImgA.CreateBitmaps(ImgHandle, ImgMaskHandle, True);
|
||||
TmpBmp.Handle := ImgHandle;
|
||||
TmpBmp.MaskHandle := ImgMaskHandle;
|
||||
Empty;
|
||||
Width := TmpBmp.Width;
|
||||
Height := TmpBmp.Height;
|
||||
Canvas.Draw(0, 0, TmpBmp);
|
||||
TmpBmp.Free;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.CutToClipboard;
|
||||
begin
|
||||
CopyToClipboard;
|
||||
Delete;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.CopyToClipboard;
|
||||
begin
|
||||
ClipBoard.Assign(Self);
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.PasteFromClipboard;
|
||||
var
|
||||
oBmp: TBitmap;
|
||||
begin
|
||||
oBmp := TBitmap.Create;
|
||||
try
|
||||
oBmp.LoadFromClipboardFormat(PredefinedClipboardFormat(pcfDelphiBitmap));
|
||||
Canvas.Draw(0, 0, oBmp);
|
||||
finally
|
||||
oBmp.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.Delete;
|
||||
begin
|
||||
Canvas.Brush.Style := bsSolid;
|
||||
Canvas.Brush.Color := PaperColor;
|
||||
Canvas.FillRect(0, 0, Width, Height);
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.Assign(Source: TPersistent);
|
||||
begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TDLBitmap.GetFillColor: TColor;
|
||||
begin
|
||||
Result := FFillColor;
|
||||
end;
|
||||
|
||||
function TDLBitmap.GetOutlineColor: TColor;
|
||||
begin
|
||||
Result := FOutlineColor;
|
||||
end;
|
||||
|
||||
function TDLBitmap.GetPaperColor: TColor;
|
||||
begin
|
||||
Result := FPaperColor;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.SetFillColor(const AValue: TColor);
|
||||
begin
|
||||
FFillColor := AValue;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.SetOutlineColor(const AValue: TColor);
|
||||
begin
|
||||
FOutlineColor := AValue;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.SetPaperColor(const AValue: TColor);
|
||||
begin
|
||||
FPaperColor := AValue;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.SetWidth(Value: integer);
|
||||
begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.SetHeight(Value: integer);
|
||||
begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.Changed(Sender: TObject);
|
||||
begin
|
||||
inherited;
|
||||
ResetScanLine;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.Clear;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.ClearWhite;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.Invert;
|
||||
var
|
||||
tmp: TDLBitmap;
|
||||
begin
|
||||
tmp := TDLBitmap.Create;
|
||||
tmp.Width := Width;
|
||||
tmp.Height := Height;
|
||||
tmp.Canvas.Draw(0, 0, Self);
|
||||
InvertBitmap(Tmp);
|
||||
Canvas.Draw(0, 0, tmp);
|
||||
tmp.Free;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.Grayscale;
|
||||
var
|
||||
tmp: TDLBitmap;
|
||||
begin
|
||||
tmp := TDLBitmap.Create;
|
||||
tmp.Width := Width;
|
||||
tmp.Height := Height;
|
||||
tmp.Canvas.Draw(0, 0, Self);
|
||||
ConvertBitmapToGrayScale(Tmp);
|
||||
Canvas.Draw(0, 0, tmp);
|
||||
tmp.Free;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.FlipHorz;
|
||||
var
|
||||
tmp, tmp2: TDLBitmap;
|
||||
begin
|
||||
tmp := TDLBitmap.Create;
|
||||
tmp.Width := Width;
|
||||
tmp.Height := Height;
|
||||
tmp2 := TDLBitmap.Create;
|
||||
tmp2.Width := Width;
|
||||
tmp2.Height := Height;
|
||||
tmp.Canvas.Draw(0, 0, Self);
|
||||
BitmapFlip(False, True, tmp, tmp2);
|
||||
Canvas.Draw(0, 0, tmp2);
|
||||
tmp.Free;
|
||||
tmp2.Free;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.FlipVert;
|
||||
var
|
||||
tmp, tmp2: TDLBitmap;
|
||||
begin
|
||||
tmp := TDLBitmap.Create;
|
||||
tmp.Width := Width;
|
||||
tmp.Height := Height;
|
||||
tmp2 := TDLBitmap.Create;
|
||||
tmp2.Width := Width;
|
||||
tmp2.Height := Height;
|
||||
tmp.Canvas.Draw(0, 0, Self);
|
||||
BitmapFlip(True, False, tmp, tmp2);
|
||||
Canvas.Draw(0, 0, tmp2);
|
||||
tmp.Free;
|
||||
tmp2.Free;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.Rotate90;
|
||||
var
|
||||
tmp: TDLBitmap;
|
||||
begin
|
||||
tmp := TDLBitmap.Create;
|
||||
tmp.Width := Width;
|
||||
tmp.Height := Height;
|
||||
tmp.Canvas.Draw(0, 0, Self);
|
||||
BMPRotate90(Tmp);
|
||||
Self.Width := tmp.Width;
|
||||
Self.Height := tmp.Height;
|
||||
Canvas.Draw(0, 0, tmp);
|
||||
tmp.Free;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.Rotate180;
|
||||
var
|
||||
tmp: TDLBitmap;
|
||||
begin
|
||||
tmp := TDLBitmap.Create;
|
||||
tmp.Width := Width;
|
||||
tmp.Height := Height;
|
||||
tmp.Canvas.Draw(0, 0, Self);
|
||||
BMPRotate180(Tmp);
|
||||
Self.Width := tmp.Width;
|
||||
Self.Height := tmp.Height;
|
||||
Canvas.Draw(0, 0, tmp);
|
||||
tmp.Free;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.Rotate270;
|
||||
var
|
||||
tmp: TDLBitmap;
|
||||
begin
|
||||
tmp := TDLBitmap.Create;
|
||||
tmp.Width := Width;
|
||||
tmp.Height := Height;
|
||||
tmp.Canvas.Draw(0, 0, Self);
|
||||
BMPRotate270(Tmp);
|
||||
Self.Width := tmp.Width;
|
||||
Self.Height := tmp.Height;
|
||||
Canvas.Draw(0, 0, tmp);
|
||||
tmp.Free;
|
||||
end;
|
||||
|
||||
procedure TDLBitmap.FillEllipse(X1, Y1, X2, Y2: integer);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -41,7 +41,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FPImage, IntfGraphics, Graphics, Math, LCLProc,
|
||||
BmpRGBUtils, rgbdrawutils;
|
||||
BmpRGBUtils, DLBitmap;
|
||||
|
||||
const
|
||||
MAXRANDOMDENSITY = $FFFF;
|
||||
|
@ -69,11 +69,10 @@
|
||||
<Unit2>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<UnitName Value="PictureCtrls"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="896"/>
|
||||
<CursorPos X="46" Y="886"/>
|
||||
<CursorPos X="86" Y="924"/>
|
||||
<UsageCount Value="27"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit2>
|
||||
@ -177,10 +176,11 @@
|
||||
<Unit13>
|
||||
<Filename Value="picturemanager.pas"/>
|
||||
<UnitName Value="PictureManager"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="21" Y="268"/>
|
||||
<TopLine Value="14"/>
|
||||
<CursorPos X="32" Y="34"/>
|
||||
<UsageCount Value="28"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit13>
|
||||
@ -243,10 +243,10 @@
|
||||
<Unit21>
|
||||
<Filename Value="bmprgbtypes.pas"/>
|
||||
<UnitName Value="BmpRGBTypes"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="559"/>
|
||||
<CursorPos X="40" Y="567"/>
|
||||
<TopLine Value="23"/>
|
||||
<CursorPos X="24" Y="44"/>
|
||||
<UsageCount Value="25"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit21>
|
||||
@ -276,7 +276,7 @@
|
||||
<Unit25>
|
||||
<Filename Value="bmprgbutils.pas"/>
|
||||
<UnitName Value="BmpRGBUtils"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="34"/>
|
||||
<CursorPos X="72" Y="5"/>
|
||||
@ -302,7 +302,7 @@
|
||||
<Unit28>
|
||||
<Filename Value="bmprgbgraph.pas"/>
|
||||
<UnitName Value="BmpRGBGraph"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="47"/>
|
||||
<CursorPos X="59" Y="66"/>
|
||||
@ -312,12 +312,10 @@
|
||||
<Unit29>
|
||||
<Filename Value="rgbdrawutils.pas"/>
|
||||
<UnitName Value="RGBDrawUtils"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="636"/>
|
||||
<CursorPos X="20" Y="669"/>
|
||||
<UsageCount Value="18"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit29>
|
||||
<Unit30>
|
||||
<Filename Value="T:\fpclaz\laz\lcl\intfgraphics.pas"/>
|
||||
@ -365,123 +363,123 @@
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="3" Column="98" TopLine="1"/>
|
||||
<Caret Line="117" Column="51" TopLine="85"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="111" Column="62" TopLine="79"/>
|
||||
<Caret Line="124" Column="10" TopLine="92"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="117" Column="51" TopLine="85"/>
|
||||
<Caret Line="125" Column="10" TopLine="93"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="124" Column="10" TopLine="92"/>
|
||||
<Caret Line="126" Column="10" TopLine="94"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="125" Column="10" TopLine="93"/>
|
||||
<Caret Line="127" Column="15" TopLine="95"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="126" Column="10" TopLine="94"/>
|
||||
<Caret Line="143" Column="22" TopLine="111"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="127" Column="15" TopLine="95"/>
|
||||
<Caret Line="166" Column="24" TopLine="134"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="143" Column="22" TopLine="111"/>
|
||||
<Caret Line="167" Column="28" TopLine="135"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="166" Column="24" TopLine="134"/>
|
||||
<Caret Line="205" Column="61" TopLine="173"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="167" Column="28" TopLine="135"/>
|
||||
<Caret Line="209" Column="72" TopLine="177"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="205" Column="61" TopLine="173"/>
|
||||
<Caret Line="213" Column="82" TopLine="181"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="209" Column="72" TopLine="177"/>
|
||||
<Caret Line="216" Column="60" TopLine="184"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="213" Column="82" TopLine="181"/>
|
||||
<Caret Line="408" Column="9" TopLine="376"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="216" Column="60" TopLine="184"/>
|
||||
<Caret Line="557" Column="37" TopLine="525"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="408" Column="9" TopLine="376"/>
|
||||
<Caret Line="559" Column="20" TopLine="527"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="557" Column="37" TopLine="525"/>
|
||||
<Caret Line="560" Column="8" TopLine="528"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="559" Column="20" TopLine="527"/>
|
||||
<Caret Line="596" Column="20" TopLine="573"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="560" Column="8" TopLine="528"/>
|
||||
<Caret Line="166" Column="24" TopLine="146"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="596" Column="20" TopLine="573"/>
|
||||
<Caret Line="167" Column="28" TopLine="146"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="166" Column="24" TopLine="146"/>
|
||||
<Caret Line="213" Column="82" TopLine="181"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="167" Column="28" TopLine="146"/>
|
||||
<Caret Line="596" Column="25" TopLine="564"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="213" Column="82" TopLine="181"/>
|
||||
<Caret Line="597" Column="55" TopLine="565"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="596" Column="25" TopLine="564"/>
|
||||
<Caret Line="641" Column="37" TopLine="609"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="597" Column="55" TopLine="565"/>
|
||||
<Caret Line="658" Column="18" TopLine="626"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="641" Column="37" TopLine="609"/>
|
||||
<Caret Line="703" Column="12" TopLine="671"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="658" Column="18" TopLine="626"/>
|
||||
<Caret Line="766" Column="41" TopLine="743"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="703" Column="12" TopLine="671"/>
|
||||
<Caret Line="862" Column="23" TopLine="842"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="766" Column="41" TopLine="743"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="862" Column="23" TopLine="842"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="bmprgbtypes.pas"/>
|
||||
<Caret Line="128" Column="29" TopLine="108"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="bmprgbtypes.pas"/>
|
||||
<Caret Line="567" Column="40" TopLine="559"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="picturemanager.pas"/>
|
||||
<Caret Line="268" Column="21" TopLine="1"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
|
@ -31,7 +31,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LResources, Controls, Graphics, ExtCtrls, ComCtrls,
|
||||
Forms, PictureCtrls, RGBDrawUtils;
|
||||
Forms, PictureCtrls, DLBitmap;
|
||||
|
||||
type
|
||||
|
||||
|
Reference in New Issue
Block a user