2006-11-03 16:25:43 +00:00
|
|
|
{
|
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This source is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This code is distributed in the hope that it will be useful, but *
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
|
|
|
* General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* A copy of the GNU General Public License is available on the World *
|
|
|
|
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
|
|
|
|
* obtain it by writing to the Free Software Foundation, *
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
Author: Tom Gregorovic
|
|
|
|
|
|
|
|
Abstract:
|
|
|
|
Components to view and edit picture.
|
|
|
|
}
|
|
|
|
unit PictureCtrls;
|
|
|
|
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
Classes, SysUtils, LCLType, LCLIntf, Controls, Forms, ExtCtrls, Graphics, Math,
|
2011-07-04 17:14:17 +00:00
|
|
|
LMessages, BmpRGBGraph, BmpRGBUtils, BmpRGBTypes, DLBitmap;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
type
|
|
|
|
TPictureViewOption = (poShowGrid, poShowMask);
|
|
|
|
TPictureViewOptions = set of TPictureViewOption;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
TPictureBitmap = TRGB32Bitmap;
|
|
|
|
|
|
|
|
{ TCustomPictureView }
|
|
|
|
|
|
|
|
TCustomPictureView = class(TScrollBox)
|
|
|
|
private
|
|
|
|
FOnPictureMouseDown: TMouseEvent;
|
|
|
|
FOnPictureMouseMove: TMouseMoveEvent;
|
|
|
|
FOnPictureMouseUp: TMouseEvent;
|
|
|
|
FOptions: TPictureViewOptions;
|
2011-04-21 14:42:45 +00:00
|
|
|
FZoom: single;
|
2006-11-03 16:25:43 +00:00
|
|
|
FScrollStop: TPanel;
|
|
|
|
FPicture: TPictureBitmap;
|
|
|
|
FPictureRect: TRect;
|
|
|
|
FOldPos: TPoint;
|
|
|
|
FStartPos: TPoint;
|
|
|
|
FEndPos: TPoint;
|
2011-04-21 14:42:45 +00:00
|
|
|
FPaintIndex: integer;
|
2011-07-04 17:14:17 +00:00
|
|
|
HorzPos, VertPos: integer;
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure SetOptions(const AValue: TPictureViewOptions);
|
|
|
|
procedure SetPicture(const AValue: TPictureBitmap);
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure SetZoom(const AValue: single);
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure MaskDraw(Data: PtrInt);
|
|
|
|
protected
|
2011-07-04 17:14:17 +00:00
|
|
|
procedure WMHScroll(var Message : TLMHScroll); message LM_HScroll;
|
|
|
|
procedure WMVScroll(var Message : TLMVScroll); message LM_VScroll;
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure PictureMouseDown(Button: TMouseButton; Shift: TShiftState;
|
2011-04-21 14:42:45 +00:00
|
|
|
X, Y: integer); dynamic;
|
|
|
|
procedure PictureMouseMove(Shift: TShiftState; X, Y: integer); dynamic;
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure PictureMouseUp(Button: TMouseButton; Shift: TShiftState;
|
2011-04-21 14:42:45 +00:00
|
|
|
X, Y: integer); dynamic;
|
|
|
|
|
|
|
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: integer); override;
|
|
|
|
procedure MouseMove(Shift: TShiftState; X, Y: integer); override;
|
|
|
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer); override;
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure UpdatePictureRect;
|
|
|
|
public
|
2011-05-05 16:42:48 +00:00
|
|
|
SeleLeft, SeleTop, XX1, XX2, YY1, YY2: integer;
|
|
|
|
SelectedDLBMP: TDLBitmap;
|
|
|
|
IsSelection: Boolean;
|
2006-11-03 16:25:43 +00:00
|
|
|
constructor Create(TheOwner: TComponent); override;
|
2011-04-24 16:15:17 +00:00
|
|
|
destructor Destroy; override;
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure Paint; override;
|
|
|
|
procedure Resize; override;
|
|
|
|
procedure EraseBackground(DC: HDC); override;
|
|
|
|
procedure InvalidatePictureRect(R: TRect);
|
|
|
|
function ClientToPicture(const P: TPoint): TPoint;
|
|
|
|
function ClientToPicture(const R: TRect): TRect;
|
|
|
|
function PictureToClient(const P: TPoint): TPoint;
|
|
|
|
function PictureToClient(const R: TRect): TRect;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure LoadPicture(const FileName: string); virtual;
|
2008-06-28 14:25:53 +00:00
|
|
|
procedure LoadBitmap(ABitmap: TRasterImage); virtual;
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure SavePicture(const FileName: string); virtual;
|
|
|
|
procedure ExportPictureAsLazarusResource(const AFileName, AName: string); virtual;
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
property StartPos: TPoint read FStartPos;
|
|
|
|
property EndPos: TPoint read FEndPos;
|
|
|
|
public
|
|
|
|
property Options: TPictureViewOptions read FOptions write SetOptions;
|
|
|
|
property Picture: TPictureBitmap read FPicture write SetPicture;
|
2011-04-21 14:42:45 +00:00
|
|
|
property Zoom: single read FZoom write SetZoom;
|
|
|
|
|
|
|
|
property OnPictureMouseDown: TMouseEvent
|
|
|
|
read FOnPictureMouseDown write FOnPictureMouseDown;
|
|
|
|
property OnPictureMouseMove: TMouseMoveEvent
|
|
|
|
read FOnPictureMouseMove write FOnPictureMouseMove;
|
|
|
|
property OnPictureMouseUp: TMouseEvent read FOnPictureMouseUp
|
|
|
|
write FOnPictureMouseUp;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
TPictureView = class(TCustomPictureView)
|
|
|
|
end;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
TPictureEditShape = (psRect, psCircle);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
|
|
|
TPictureEditToolDrag = (tdNone, tdLine, tdRectangle, tdEllipse,
|
2011-05-19 04:32:37 +00:00
|
|
|
tdRoundRectangle, tdPolygon, tdRegularPolygon);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
TPictureEditTool = (ptLine, ptPen, ptRectangle, ptFloodFill, ptEllipse,
|
2011-05-19 04:32:37 +00:00
|
|
|
ptMask, ptColorPick, ptEraser, ptSpray, ptPolygon, ptBrush, ptText,
|
|
|
|
ptColorReplacer, ptRegularPolygon);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
TPicturePos = (ppTopLeft, ppTopCenter, ppTopRight, ppCenterLeft, ppCentered,
|
|
|
|
ppCenterRight, ppBottomLeft, ppBottomCenter, ppBottomRight);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
TMaskTool = (mtRectangle, mtEllipse, mtFloodFill);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
{ TCustomPictureEdit }
|
|
|
|
|
|
|
|
TCustomPictureEdit = class(TCustomPictureView)
|
|
|
|
private
|
|
|
|
FDrawMode: TDrawMode;
|
2011-04-21 14:42:45 +00:00
|
|
|
FFillAlpha: integer;
|
2006-11-03 16:25:43 +00:00
|
|
|
FFillAndOutline: TDrawMode;
|
|
|
|
FFillColor: TColor;
|
2011-04-21 14:42:45 +00:00
|
|
|
FFloodFillTolerance: single;
|
|
|
|
FFuzzy: boolean;
|
2006-11-03 16:25:43 +00:00
|
|
|
FMaskTool: TMaskTool;
|
2011-04-21 14:42:45 +00:00
|
|
|
FModified: boolean;
|
2006-11-03 16:25:43 +00:00
|
|
|
FOnChange: TNotifyEvent;
|
|
|
|
FOnColorChange: TNotifyEvent;
|
|
|
|
FOnPictureSizeChange: TNotifyEvent;
|
|
|
|
FOutlineColor: TColor;
|
|
|
|
FPaperColor: TColor;
|
2011-04-21 14:42:45 +00:00
|
|
|
FRandomDensity: single;
|
|
|
|
FRectangleRoundness: integer;
|
2006-11-03 16:25:43 +00:00
|
|
|
FShape: TPictureEditShape;
|
2011-04-21 14:42:45 +00:00
|
|
|
FSize: integer;
|
2006-11-03 16:25:43 +00:00
|
|
|
FTool: TPictureEditTool;
|
|
|
|
FToolDrag: TPictureEditToolDrag;
|
|
|
|
FTempPos: TPoint;
|
|
|
|
procedure SetFillColor(const AValue: TColor);
|
|
|
|
procedure SetOutlineColor(const AValue: TColor);
|
|
|
|
procedure SetPaperColor(const AValue: TColor);
|
|
|
|
procedure SetTool(const AValue: TPictureEditTool);
|
|
|
|
protected
|
2011-05-05 02:21:34 +00:00
|
|
|
FromColor, ToColor: TColor;
|
2011-05-19 03:37:23 +00:00
|
|
|
paddr: array of TPoint;
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure Change; dynamic;
|
|
|
|
procedure ColorChange; dynamic;
|
|
|
|
procedure PictureSizeChange; dynamic;
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure PictureMouseDown(Button: TMouseButton; Shift: TShiftState;
|
|
|
|
X, Y: integer); override;
|
|
|
|
procedure PictureMouseMove(Shift: TShiftState; X, Y: integer); override;
|
|
|
|
procedure PictureMouseUp(Button: TMouseButton; Shift: TShiftState;
|
|
|
|
X, Y: integer); override;
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
function GetToolDrag: TPictureEditToolDrag; virtual;
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure DrawToolDrag(X1, Y1, X2, Y2: integer); virtual;
|
2006-11-03 16:25:43 +00:00
|
|
|
public
|
2011-05-19 09:02:30 +00:00
|
|
|
pcount, RegularPolyNum: integer;
|
2006-11-03 16:25:43 +00:00
|
|
|
constructor Create(TheOwner: TComponent); override;
|
2011-05-05 16:42:48 +00:00
|
|
|
destructor Destroy; override;
|
2006-11-03 16:25:43 +00:00
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure NewPicture(AWidth, AHeight: integer; APaperColor: TColor);
|
|
|
|
procedure LoadPicture(const FileName: string); override;
|
2008-06-28 14:25:53 +00:00
|
|
|
procedure LoadBitmap(ABitmap: TRasterImage); override;
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure SavePicture(const FileName: string); override;
|
|
|
|
|
|
|
|
procedure ColorPick(X, Y: integer; Shift: TShiftState = [ssLeft]);
|
|
|
|
procedure FloodFill(X, Y: integer; Shift: TShiftState = [ssLeft]);
|
|
|
|
procedure MaskFloodFill(X, Y: integer; Shift: TShiftState = [ssLeft]);
|
|
|
|
procedure Eraser(X, Y: integer; Shift: TShiftState = [ssLeft]);
|
2011-05-05 02:21:34 +00:00
|
|
|
procedure ColorReplacer(X, Y: integer; Shift: TShiftState = [ssLeft]);
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure Spray(X, Y: integer; Shift: TShiftState = [ssLeft]);
|
|
|
|
procedure Brush(X, Y: integer; Shift: TShiftState = [ssLeft]);
|
|
|
|
procedure Line(X1, Y1, X2, Y2: integer; Shift: TShiftState = [ssLeft]);
|
|
|
|
procedure Rectangle(X1, Y1, X2, Y2: integer; Shift: TShiftState = [ssLeft]);
|
|
|
|
procedure Ellipse(X1, Y1, X2, Y2: integer; Shift: TShiftState = [ssLeft]);
|
2011-05-19 03:37:23 +00:00
|
|
|
procedure Polygon(polyaddr: array of TPoint);
|
2011-05-19 12:50:02 +00:00
|
|
|
procedure FinishPolygon;
|
|
|
|
procedure PolygonWithoutEdge(polyaddr: array of TPoint);
|
2011-05-19 04:32:37 +00:00
|
|
|
procedure RegularPolygon(X1, Y1, X2, Y2: integer; Shift: TShiftState = [ssLeft]);
|
2011-04-24 16:15:17 +00:00
|
|
|
procedure ProcessEditorText(X1, Y1, X2, Y2: integer);
|
2011-05-19 03:37:23 +00:00
|
|
|
procedure ProcessPointAddr;
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure Mask(X1, Y1, X2, Y2: integer; Shift: TShiftState = [ssLeft]);
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure FlipHorizontally;
|
|
|
|
procedure FlipVertically;
|
|
|
|
procedure Rotate90Clockwise;
|
|
|
|
procedure Rotate180Clockwise;
|
|
|
|
procedure Rotate270Clockwise;
|
2011-04-27 07:57:44 +00:00
|
|
|
procedure ColorReplace(ColorFrom, ColorTo: TColor);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
|
|
|
procedure StretchTruncate(AWidth, AHeight: integer);
|
|
|
|
procedure StretchSmooth(AWidth, AHeight: integer; Method: TSmoothMethod);
|
|
|
|
procedure ResizePaper(AWidth, AHeight: integer; PicturePos: TPicturePos);
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure ClipPaperToMask;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure RemoveMask;
|
|
|
|
procedure InvertMask;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure Cut;
|
|
|
|
procedure Copy;
|
|
|
|
procedure Paste;
|
|
|
|
procedure Delete;
|
|
|
|
procedure SelectAll;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure Invert;
|
|
|
|
procedure Grayscale;
|
|
|
|
procedure Disable;
|
|
|
|
|
|
|
|
procedure BeginDraw;
|
|
|
|
procedure EndDraw;
|
|
|
|
procedure UpdatePicture;
|
2011-05-05 02:21:34 +00:00
|
|
|
procedure ChangeColor(FrColor, taColor: TColor);
|
2006-11-03 16:25:43 +00:00
|
|
|
public
|
2011-04-24 16:15:17 +00:00
|
|
|
TextEditor: TTextEditor;
|
2006-11-03 16:25:43 +00:00
|
|
|
property DrawMode: TDrawMode read FDrawMode write FDrawMode;
|
|
|
|
property FillColor: TColor read FFillColor write SetFillColor;
|
|
|
|
property OutlineColor: TColor read FOutlineColor write SetOutlineColor;
|
|
|
|
property PaperColor: TColor read FPaperColor write SetPaperColor;
|
|
|
|
property Shape: TPictureEditShape read FShape write FShape;
|
|
|
|
property FillAndOutline: TDrawMode read FFillAndOutline write FFillAndOutline;
|
|
|
|
property MaskTool: TMaskTool read FMaskTool write FMaskTool;
|
2011-04-21 14:42:45 +00:00
|
|
|
property RandomDensity: single read FRandomDensity write FRandomDensity;
|
|
|
|
property RectangleRoundness: integer read FRectangleRoundness
|
|
|
|
write FRectangleRoundness;
|
|
|
|
property FloodFillTolerance: single read FFloodFillTolerance
|
|
|
|
write FFloodFillTolerance;
|
|
|
|
property Size: integer read FSize write FSize;
|
2006-11-03 16:25:43 +00:00
|
|
|
property Tool: TPictureEditTool read FTool write SetTool;
|
2011-04-21 14:42:45 +00:00
|
|
|
property FillAlpha: integer read FFillAlpha write FFillAlpha;
|
|
|
|
property Fuzzy: boolean read FFuzzy write FFuzzy;
|
2010-08-31 15:58:43 +00:00
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
property Modified: boolean read FModified;
|
2006-11-03 16:25:43 +00:00
|
|
|
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
|
|
|
property OnColorChange: TNotifyEvent read FOnColorChange write FOnColorChange;
|
2011-04-21 14:42:45 +00:00
|
|
|
property OnPictureSizeChange: TNotifyEvent
|
|
|
|
read FOnPictureSizeChange write FOnPictureSizeChange;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
{ TPictureEdit }
|
|
|
|
|
|
|
|
TPictureEdit = class(TCustomPictureEdit)
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{ TCustomPictureView }
|
|
|
|
|
|
|
|
procedure TCustomPictureView.SetPicture(const AValue: TPictureBitmap);
|
|
|
|
begin
|
|
|
|
FPicture := AValue;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
FZoom := 1;
|
|
|
|
UpdatePictureRect;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureView.SetOptions(const AValue: TPictureViewOptions);
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if FOptions = AValue then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
FOptions := AValue;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureView.SetZoom(const AValue: single);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if AValue = FZoom then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
FZoom := AValue;
|
2011-04-21 14:42:45 +00:00
|
|
|
if FZoom < 0.1 then
|
|
|
|
FZoom := 0.1;
|
|
|
|
if FZoom > 20 then
|
|
|
|
FZoom := 20;
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
UpdatePictureRect;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureView.MaskDraw(Data: PtrInt);
|
|
|
|
var
|
2011-04-21 14:42:45 +00:00
|
|
|
I, J, CI, CJ, X, Y: integer;
|
2006-11-03 16:25:43 +00:00
|
|
|
const
|
|
|
|
PORTION_SIZE = 128;
|
|
|
|
begin
|
|
|
|
Application.ProcessMessages;
|
2011-04-21 14:42:45 +00:00
|
|
|
if Application.Terminated then
|
|
|
|
Exit;
|
|
|
|
if FPaintIndex <> Data then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
|
|
|
|
CI := Ceil(Picture.Width / PORTION_SIZE);
|
|
|
|
CJ := Ceil(Picture.Height / PORTION_SIZE);
|
|
|
|
|
|
|
|
for J := 0 to Pred(CJ) do
|
2011-04-21 14:42:45 +00:00
|
|
|
for I := 0 to Pred(CI) do
|
|
|
|
with Canvas do
|
|
|
|
begin
|
|
|
|
X := FPictureRect.Left - GetClientScrollOffset.X;
|
|
|
|
Y := FPictureRect.Top - GetClientScrollOffset.Y;
|
|
|
|
|
|
|
|
FPicture.Mask.StretchDrawShapePortionTo(Canvas, X, Y,
|
|
|
|
FPictureRect.Right - FPictureRect.Left, FPictureRect.Bottom - FPictureRect.Top,
|
|
|
|
I * PORTION_SIZE, J * PORTION_SIZE, PORTION_SIZE, PORTION_SIZE);
|
|
|
|
|
|
|
|
Application.ProcessMessages;
|
|
|
|
if Application.Terminated then
|
|
|
|
Exit;
|
|
|
|
if FPaintIndex <> Data then
|
|
|
|
Exit;
|
|
|
|
end;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureView.UpdatePictureRect;
|
|
|
|
var
|
2011-04-21 14:42:45 +00:00
|
|
|
W, H, X, Y: integer;
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
if FPicture <> nil then
|
|
|
|
begin
|
|
|
|
W := Round(FPicture.Width * FZoom);
|
|
|
|
H := Round(FPicture.Height * FZoom);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
|
|
|
if W > ClientWidth then
|
|
|
|
X := 0
|
|
|
|
else
|
|
|
|
X := (ClientWidth - W) div 2;
|
|
|
|
|
|
|
|
if H > ClientHeight then
|
|
|
|
Y := 0
|
|
|
|
else
|
|
|
|
Y := (ClientHeight - H) div 2;
|
|
|
|
|
|
|
|
FPictureRect := Bounds(X, Y, W, H);
|
2006-11-03 16:25:43 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
FPictureRect := Rect(0, 0, 0, 0);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
//VertScrollBar.Range := FPictureRect.Bottom;
|
|
|
|
//HorzScrollBar.Range := FPictureRect.Right;
|
|
|
|
if Assigned(FScrollStop) then
|
|
|
|
begin
|
|
|
|
FScrollStop.SetBounds(FPictureRect.Right, FPictureRect.Bottom, 0, 0);
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureView.PictureMouseDown(Button: TMouseButton;
|
2011-04-21 14:42:45 +00:00
|
|
|
Shift: TShiftState; X, Y: integer);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
FStartPos := Point(X, Y);
|
|
|
|
FEndPos := FStartPos;
|
|
|
|
|
|
|
|
if Assigned(FOnPictureMouseDown) then
|
|
|
|
FOnPictureMouseDown(Self, Button, Shift, X, Y);
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureView.PictureMouseMove(Shift: TShiftState; X, Y: integer);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
FEndPos := Point(X, Y);
|
2011-04-21 14:42:45 +00:00
|
|
|
if Shift * [ssLeft, ssMiddle, ssRight] = [] then
|
|
|
|
FStartPos := FEndPos;
|
2006-11-03 16:25:43 +00:00
|
|
|
|
|
|
|
if Assigned(FOnPictureMouseMove) then
|
|
|
|
FOnPictureMouseMove(Self, Shift, X, Y);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureView.PictureMouseUp(Button: TMouseButton;
|
2011-04-21 14:42:45 +00:00
|
|
|
Shift: TShiftState; X, Y: integer);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
if Assigned(FOnPictureMouseUp) then
|
|
|
|
FOnPictureMouseUp(Self, Button, Shift, X, Y);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureView.MouseDown(Button: TMouseButton;
|
2011-04-21 14:42:45 +00:00
|
|
|
Shift: TShiftState; X, Y: integer);
|
2006-11-03 16:25:43 +00:00
|
|
|
var
|
|
|
|
C: TPoint;
|
|
|
|
begin
|
|
|
|
inherited MouseDown(Button, Shift, X, Y);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
C := ClientToPicture(Point(X, Y));
|
|
|
|
PictureMouseDown(Button, Shift, C.X, C.Y);
|
|
|
|
FOldPos := C;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureView.MouseMove(Shift: TShiftState; X, Y: integer);
|
2006-11-03 16:25:43 +00:00
|
|
|
var
|
|
|
|
C: TPoint;
|
|
|
|
begin
|
|
|
|
inherited MouseMove(Shift, X, Y);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
C := ClientToPicture(Point(X, Y));
|
|
|
|
if FOldPos <> C then
|
|
|
|
begin
|
|
|
|
PictureMouseMove(Shift, C.X, C.Y);
|
|
|
|
FOldPos := C;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureView.MouseUp(Button: TMouseButton; Shift: TShiftState;
|
2011-04-21 14:42:45 +00:00
|
|
|
X, Y: integer);
|
2006-11-03 16:25:43 +00:00
|
|
|
var
|
|
|
|
C: TPoint;
|
|
|
|
begin
|
|
|
|
inherited MouseUp(Button, Shift, X, Y);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
C := ClientToPicture(Point(X, Y));
|
|
|
|
PictureMouseUp(Button, Shift, C.X, C.Y);
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TCustomPictureView.Create(TheOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited Create(TheOwner);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
Color := clSilver;
|
|
|
|
FOptions := [poShowGrid, poShowMask];
|
|
|
|
DoubleBuffered := True;
|
|
|
|
FStartPos := Point(0, 0);
|
|
|
|
FEndPos := Point(0, 0);
|
|
|
|
AutoScroll := True;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
FScrollStop := TPanel.Create(Self);
|
|
|
|
FScrollStop.SetBounds(0, 0, 0, 0);
|
|
|
|
FScrollStop.Parent := Self;
|
2011-07-05 04:15:54 +00:00
|
|
|
Self.AutoScroll := True;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
|
2011-04-24 16:15:17 +00:00
|
|
|
destructor TCustomPictureView.Destroy;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
2011-07-04 17:14:17 +00:00
|
|
|
procedure TCustomPictureView.WMHScroll(var Message : TLMHScroll);
|
|
|
|
begin
|
|
|
|
inherited;
|
2011-07-05 04:15:54 +00:00
|
|
|
//HorzPos := Message.Pos;
|
2011-07-04 17:14:17 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureView.WMVScroll(var Message : TLMVScroll);
|
|
|
|
begin
|
|
|
|
inherited;
|
2011-07-05 04:15:54 +00:00
|
|
|
//VertPos := Message.Pos;
|
2011-07-04 17:14:17 +00:00
|
|
|
end;
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
procedure TCustomPictureView.Paint;
|
|
|
|
var
|
2011-04-21 14:42:45 +00:00
|
|
|
I: integer;
|
2006-11-03 16:25:43 +00:00
|
|
|
R: TRect;
|
|
|
|
begin
|
|
|
|
Inc(FPaintIndex);
|
|
|
|
inherited Paint;
|
|
|
|
|
|
|
|
with Canvas do
|
|
|
|
begin
|
|
|
|
Brush.Color := Self.Color;
|
|
|
|
FillRect(ClipRect);
|
|
|
|
|
|
|
|
if Assigned(FPicture) then
|
|
|
|
begin
|
2011-07-05 04:15:54 +00:00
|
|
|
HorzPos := HorzScrollbar.Position;
|
|
|
|
VertPos := VertScrollbar.Position;
|
2011-03-09 01:14:06 +00:00
|
|
|
FPicture.StretchDrawTo(Canvas, FPictureRect.Left, FPictureRect.Top,
|
2011-07-05 04:15:54 +00:00
|
|
|
FPictureRect.Right, FPictureRect.Bottom, HorzPos, VertPos, Width, Height);
|
2006-11-03 16:25:43 +00:00
|
|
|
if (poShowGrid in Options) and (Zoom > 2.0) then
|
|
|
|
begin
|
|
|
|
Pen.Color := clGray;
|
|
|
|
|
|
|
|
for I := 1 to FPicture.Width do
|
|
|
|
begin
|
|
|
|
MoveTo(FPictureRect.Left + Round(I * Zoom), FPictureRect.Top);
|
|
|
|
LineTo(FPictureRect.Left + Round(I * Zoom), FPictureRect.Bottom);
|
|
|
|
end;
|
|
|
|
|
|
|
|
for I := 1 to FPicture.Height do
|
|
|
|
begin
|
|
|
|
MoveTo(FPictureRect.Left, FPictureRect.Top + Round(I * Zoom));
|
|
|
|
LineTo(FPictureRect.Right, FPictureRect.Top + Round(I * Zoom));
|
|
|
|
end;
|
|
|
|
end;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
if (poShowMask in Options) and not FPicture.Mask.IsEmpty then
|
|
|
|
begin
|
|
|
|
Application.QueueAsyncCall(@MaskDraw, FPaintIndex);
|
|
|
|
end;
|
|
|
|
end;
|
2011-05-05 16:42:48 +00:00
|
|
|
{if IsSelection then
|
|
|
|
begin
|
|
|
|
Canvas.Pen.Mode:=pmNotXor;
|
|
|
|
if SeleLeft < FPictureRect.Left then
|
|
|
|
SeleLeft := FPictureRect.Left;
|
|
|
|
if SeleTop < FPictureRect.Top then
|
|
|
|
SeleTop := FPictureRect.Top;
|
|
|
|
if (Seleleft >= FPictureRect.Left) and (SeleTop >= FPictureRect.Top){ and
|
|
|
|
(SeleLeft + SelectedDLBMP.Width <= FPictureRect.Right) and
|
|
|
|
(SeleTop + SelectedDLBMP.Height <= FPictureRect.Bottom)} then
|
|
|
|
Canvas.Draw(SeleLeft, SeleTop, SelectedDLBMP);
|
|
|
|
end; }
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureView.Resize;
|
|
|
|
begin
|
|
|
|
inherited Resize;
|
|
|
|
UpdatePictureRect;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureView.EraseBackground(DC: HDC);
|
|
|
|
begin
|
|
|
|
//inherited EraseBackground(DC);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureView.InvalidatePictureRect(R: TRect);
|
|
|
|
var
|
|
|
|
P: TRect;
|
|
|
|
S: TPoint;
|
|
|
|
begin
|
|
|
|
if HandleAllocated then
|
|
|
|
begin
|
|
|
|
P := PictureToClient(R);
|
|
|
|
S := GetClientScrollOffset;
|
|
|
|
OffsetRect(P, -S.X, -S.Y);
|
|
|
|
InvalidateRect(Handle, @P, False);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCustomPictureView.ClientToPicture(const P: TPoint): TPoint;
|
|
|
|
var
|
|
|
|
S: TPoint;
|
|
|
|
begin
|
|
|
|
S := GetClientScrollOffset;
|
|
|
|
Result.X := Floor((P.X - FPictureRect.Left + S.X) / FZoom);
|
|
|
|
Result.Y := Floor((P.Y - FPictureRect.Top + S.Y) / FZoom);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCustomPictureView.ClientToPicture(const R: TRect): TRect;
|
|
|
|
var
|
|
|
|
S: TPoint;
|
|
|
|
begin
|
|
|
|
Result := R;
|
|
|
|
SortRect(Result);
|
|
|
|
S := GetClientScrollOffset;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
Result.Left := Floor((Result.Left - FPictureRect.Left + S.X) / FZoom);
|
|
|
|
Result.Top := Floor((Result.Top - FPictureRect.Top + S.Y) / FZoom);
|
|
|
|
Result.Right := Ceil((Result.Right - FPictureRect.Right + S.X) / FZoom);
|
|
|
|
Result.Bottom := Ceil((Result.Bottom - FPictureRect.Bottom + S.Y) / FZoom);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCustomPictureView.PictureToClient(const P: TPoint): TPoint;
|
|
|
|
var
|
|
|
|
S: TPoint;
|
|
|
|
begin
|
|
|
|
S := GetClientScrollOffset;
|
|
|
|
Result.X := Floor((P.X + 0.5) * FZoom) + FPictureRect.Left - S.X;
|
|
|
|
Result.Y := Floor((P.Y + 0.5) * FZoom) + FPictureRect.Top - S.Y;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCustomPictureView.PictureToClient(const R: TRect): TRect;
|
|
|
|
var
|
|
|
|
S: TPoint;
|
|
|
|
begin
|
|
|
|
Result := R;
|
|
|
|
SortRect(Result);
|
|
|
|
S := GetClientScrollOffset;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
Result.Left := Floor((Result.Left - 1) * FZoom) + FPictureRect.Left + S.X;
|
|
|
|
Result.Top := Floor((Result.Top - 1) * FZoom) + FPictureRect.Top + S.Y;
|
|
|
|
Result.Right := Ceil((Result.Right + 2) * FZoom) + FPictureRect.Left + S.X;
|
|
|
|
Result.Bottom := Ceil((Result.Bottom + 2) * FZoom) + FPictureRect.Top + S.Y;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureView.LoadPicture(const FileName: string);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
Picture.Free;
|
|
|
|
Picture := TPictureBitmap.CreateFromFile(FileName);
|
|
|
|
end;
|
|
|
|
|
2008-06-28 14:25:53 +00:00
|
|
|
procedure TCustomPictureView.LoadBitmap(ABitmap: TRasterImage);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
Picture.Free;
|
|
|
|
Picture := TPictureBitmap.CreateFromBitmap(ABitmap);
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureView.SavePicture(const FileName: string);
|
|
|
|
var
|
|
|
|
Pic: TPicture;
|
|
|
|
ExtName: string;
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
2011-03-18 15:37:47 +00:00
|
|
|
Pic := TPicture.Create;
|
|
|
|
//Picture.SaveToFile(UTF8Decode(FileName));
|
|
|
|
Pic.Bitmap.Width := Picture.Width;
|
|
|
|
Pic.Bitmap.Height := Picture.Height;
|
2011-04-21 14:42:45 +00:00
|
|
|
Pic.Bitmap.Canvas.Draw(0, 0, Picture);
|
2011-04-15 16:41:26 +00:00
|
|
|
ExtName := ExtractFileExt(FileName);
|
2011-04-21 14:42:45 +00:00
|
|
|
// if ExtName = 'PNG' then
|
|
|
|
// Pic.Graphic.;
|
2011-04-15 16:41:26 +00:00
|
|
|
Pic.SaveToFile(FileName, ExtName);
|
2011-03-18 15:37:47 +00:00
|
|
|
Pic.Free;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureView.ExportPictureAsLazarusResource(
|
|
|
|
const AFileName, AName: string);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
Picture.SaveToLazarusResource(AFileName, AName);
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ TCustomPictureEdit }
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.SetTool(const AValue: TPictureEditTool);
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if FTool = AValue then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
FTool := AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.Change;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Assigned(FOnChange) then
|
|
|
|
FOnChange(Self);
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.SetFillColor(const AValue: TColor);
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if AValue = FFillColor then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
FFillColor := AValue;
|
|
|
|
ColorChange;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.SetOutlineColor(const AValue: TColor);
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if AValue = FOutlineColor then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
FOutlineColor := AValue;
|
|
|
|
ColorChange;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.SetPaperColor(const AValue: TColor);
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if AValue = FPaperColor then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
FPaperColor := AValue;
|
|
|
|
ColorChange;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.ColorChange;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Assigned(FOnColorChange) then
|
|
|
|
FOnColorChange(Self);
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.PictureSizeChange;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Assigned(FOnPictureSizeChange) then
|
|
|
|
FOnPictureSizeChange(Self);
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.PictureMouseDown(Button: TMouseButton;
|
2011-04-21 14:42:45 +00:00
|
|
|
Shift: TShiftState; X, Y: integer);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
inherited PictureMouseDown(Button, Shift, X, Y);
|
|
|
|
|
|
|
|
FTempPos := Point(X, Y);
|
2011-05-05 16:42:48 +00:00
|
|
|
IsSelection := False;
|
2006-11-03 16:25:43 +00:00
|
|
|
case Tool of
|
2011-04-21 14:42:45 +00:00
|
|
|
ptPen: Line(X, Y, X, Y, Shift);
|
|
|
|
ptFloodFill: FloodFill(X, Y, Shift);
|
2011-05-05 16:42:48 +00:00
|
|
|
ptMask: begin if MaskTool = mtFloodFill then
|
2011-05-06 10:04:42 +00:00
|
|
|
MaskFloodFill(X, Y, Shift);
|
2011-05-05 16:42:48 +00:00
|
|
|
Canvas.Pen.Style := psDot;
|
|
|
|
Canvas.Pen.Mode := pmXor;
|
|
|
|
IsSelection := True;
|
|
|
|
SeleLeft := X;
|
|
|
|
SeleTop := Y;
|
2011-05-06 10:04:42 +00:00
|
|
|
if (XX1 <> 0) and (XX2 <> 0) and (YY1 <> 0) and (YY2 <> 0) then
|
|
|
|
Mask(XX1, YY1, XX2, YY2, Shift);
|
2011-05-05 16:42:48 +00:00
|
|
|
end;
|
2011-04-21 14:42:45 +00:00
|
|
|
ptColorPick: ColorPick(X, Y, Shift);
|
|
|
|
ptEraser: Eraser(X, Y, Shift);
|
2011-05-05 02:21:34 +00:00
|
|
|
ptColorReplacer: ColorReplacer(X, Y, Shift);
|
2011-04-21 14:42:45 +00:00
|
|
|
ptSpray: Spray(X, Y, Shift);
|
2011-04-24 16:15:17 +00:00
|
|
|
ptText: ProcessEditorText(X, Y, X, Y);
|
2011-04-21 14:42:45 +00:00
|
|
|
ptBrush: Brush(X, Y, Shift);
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
FToolDrag := GetToolDrag;
|
|
|
|
DrawToolDrag(StartPos.X, StartPos.Y, FTempPos.X, FTempPos.Y);
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.PictureMouseMove(Shift: TShiftState; X, Y: integer);
|
2011-05-19 12:50:02 +00:00
|
|
|
var S, E, P: TPoint;
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
inherited PictureMouseMove(Shift, X, Y);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
if Shift * [ssLeft, ssRight] <> [] then
|
|
|
|
begin
|
|
|
|
case Tool of
|
2011-04-21 14:42:45 +00:00
|
|
|
ptPen:
|
|
|
|
begin
|
|
|
|
Line(FTempPos.X, FTempPos.Y, X, Y, Shift);
|
|
|
|
end;
|
|
|
|
ptEraser: Eraser(X, Y, Shift);
|
2011-05-05 02:21:34 +00:00
|
|
|
ptColorReplacer: ColorReplacer(X, Y, Shift);
|
2011-04-21 14:42:45 +00:00
|
|
|
ptSpray: Spray(X, Y, Shift);
|
|
|
|
ptBrush: Brush(X, Y, Shift);
|
|
|
|
ptColorPick: ColorPick(X, Y, Shift);
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
end;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2011-05-19 12:50:02 +00:00
|
|
|
if Tool = ptPolygon then
|
|
|
|
begin
|
|
|
|
if pcount > 0 then
|
|
|
|
begin
|
|
|
|
Canvas.Pen.Mode := pmNotXor;
|
|
|
|
Canvas.Brush.Style := bsSolid;
|
|
|
|
S := PictureToClient(FTempPos);
|
|
|
|
E := PictureToClient(Point(X, Y));
|
|
|
|
P := PictureToClient(paddr[pcount - 1]);
|
|
|
|
Canvas.Line(P.x, P.y, S.X, S.Y);
|
|
|
|
Canvas.Line(P.x, P.y, E.X, E.Y);
|
|
|
|
Canvas.Pen.Mode := pmCopy;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
DrawToolDrag(StartPos.X, StartPos.Y, FTempPos.X, FTempPos.Y);
|
|
|
|
FTempPos := Point(X, Y);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
DrawToolDrag(StartPos.X, StartPos.Y, X, Y);
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.PictureMouseUp(Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: integer);
|
2011-05-19 03:37:23 +00:00
|
|
|
var S, E: TPoint;
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
inherited PictureMouseUp(Button, Shift, X, Y);
|
2011-04-21 14:42:45 +00:00
|
|
|
if Button = mbLeft then
|
|
|
|
Shift := Shift + [ssLeft];
|
|
|
|
if Button = mbRight then
|
|
|
|
Shift := Shift + [ssRight];
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
case Tool of
|
2011-04-21 14:42:45 +00:00
|
|
|
ptLine: Line(StartPos.X, StartPos.Y, X, Y, Shift);
|
|
|
|
ptRectangle: Rectangle(StartPos.X, StartPos.Y, X, Y, Shift);
|
|
|
|
ptEllipse: Ellipse(StartPos.X, StartPos.Y, X, Y, Shift);
|
2011-05-19 04:32:37 +00:00
|
|
|
ptRegularPolygon: RegularPolygon(StartPos.X, StartPos.Y, X, Y, Shift);
|
2011-04-21 14:42:45 +00:00
|
|
|
ptPolygon:
|
|
|
|
begin
|
2011-05-19 03:37:23 +00:00
|
|
|
pcount := pcount + 1;
|
|
|
|
SetLength(paddr, pcount);
|
|
|
|
paddr[pcount - 1].x := X;
|
|
|
|
paddr[pcount - 1].y := Y;
|
|
|
|
S := PictureToClient(Point(StartPos.X, StartPos.Y));
|
|
|
|
E := PictureToClient(Point(X, Y));
|
|
|
|
//Canvas.Pen.Color := OutLineColor;
|
|
|
|
//Canvas.Line(S.X, S.Y, E.X, E.Y);
|
2011-05-19 12:50:02 +00:00
|
|
|
if Shift * [ssLeft] <> [] then
|
|
|
|
PolygonWithoutEdge(paddr);
|
|
|
|
if Shift * [ssRight] <> [] then
|
|
|
|
//Picture.Canvas.Polygon(paddr);
|
|
|
|
FinishPolygon;
|
2011-04-21 14:42:45 +00:00
|
|
|
end;
|
2011-05-05 16:42:48 +00:00
|
|
|
ptMask: begin if MaskTool <> mtFloodFill then
|
2011-04-21 14:42:45 +00:00
|
|
|
Mask(StartPos.X, StartPos.Y, X, Y, Shift);
|
2011-05-05 16:42:48 +00:00
|
|
|
IsSelection := True;
|
|
|
|
end;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
FToolDrag := tdNone;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCustomPictureEdit.GetToolDrag: TPictureEditToolDrag;
|
|
|
|
begin
|
|
|
|
case Tool of
|
|
|
|
ptLine: Result := tdLine;
|
|
|
|
ptRectangle: Result := tdRoundRectangle;
|
|
|
|
ptEllipse: Result := tdEllipse;
|
2011-04-21 14:42:45 +00:00
|
|
|
ptPolygon: Result := tdPolygon;
|
2011-05-19 04:32:37 +00:00
|
|
|
ptRegularPolygon: Result := tdRegularPolygon;
|
2006-11-03 16:25:43 +00:00
|
|
|
ptMask:
|
|
|
|
begin
|
|
|
|
case MaskTool of
|
2011-04-21 14:42:45 +00:00
|
|
|
mtEllipse: Result := tdEllipse;
|
|
|
|
mtRectangle: Result := tdRectangle;
|
|
|
|
mtFloodFill: Result := tdNone;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
end;
|
2011-04-21 14:42:45 +00:00
|
|
|
else
|
|
|
|
Result := tdNone;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.DrawToolDrag(X1, Y1, X2, Y2: integer);
|
2006-11-03 16:25:43 +00:00
|
|
|
var
|
|
|
|
S, E: TPoint;
|
2011-04-21 14:42:45 +00:00
|
|
|
R: integer;
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if FToolDrag = tdNone then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
// Canvas.Pen.Mode := pmNot;
|
2011-04-21 01:22:12 +00:00
|
|
|
Canvas.Pen.Mode := pmNotXor;
|
2011-05-06 10:04:42 +00:00
|
|
|
Canvas.Brush.Style := bsSolid;
|
2011-04-20 16:42:01 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
S := PictureToClient(Point(X1, Y1));
|
|
|
|
E := PictureToClient(Point(X2, Y2));
|
|
|
|
R := Round(RectangleRoundness * Zoom);
|
2011-04-21 14:42:45 +00:00
|
|
|
|
|
|
|
if FToolDrag = tdLine then
|
|
|
|
Canvas.Line(S.X, S.Y, E.X, E.Y);
|
|
|
|
if FToolDrag = tdRectangle then
|
|
|
|
Canvas.Rectangle(S.X, S.Y, E.X, E.Y);
|
|
|
|
if FToolDrag = tdRoundRectangle then
|
|
|
|
Canvas.RoundRect(S.X, S.Y, E.X, E.Y, R, R);
|
|
|
|
if FToolDrag = tdEllipse then
|
|
|
|
Canvas.Ellipse(S.X, S.Y, E.X, E.Y);
|
2011-05-19 04:32:37 +00:00
|
|
|
if FToolDrag = tdRegularPolygon then
|
2011-05-19 09:02:30 +00:00
|
|
|
DrawRegularPolygon(Canvas, Point(S.X, S.Y), Point(E.X, E.Y), RegularPolyNum);
|
2011-04-21 14:42:45 +00:00
|
|
|
if FToolDrag = tdPolygon then
|
2011-05-19 03:37:23 +00:00
|
|
|
begin
|
|
|
|
Canvas.Pen.Color := OutLineColor;
|
|
|
|
//Picture.Canvas.Line(paddr[pcount - 1].x, paddr[pcount - 1].y, X, Y);
|
|
|
|
Canvas.Line(S.X, S.Y, E.X, E.Y);
|
|
|
|
end;
|
2006-11-03 16:25:43 +00:00
|
|
|
Canvas.Pen.Mode := pmCopy;
|
|
|
|
Canvas.Brush.Style := bsSolid;
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TCustomPictureEdit.Create(TheOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
ControlStyle := ControlStyle + [csCaptureMouse];
|
|
|
|
CaptureMouseButtons := [mbLeft, mbMiddle, mbRight];
|
2010-08-31 15:46:01 +00:00
|
|
|
|
|
|
|
FFillAlpha := 100;
|
2006-11-03 16:25:43 +00:00
|
|
|
FFillColor := clGray;
|
|
|
|
FOutlineColor := clBlack;
|
|
|
|
FPaperColor := clWhite;
|
|
|
|
RandomDensity := 1.0;
|
|
|
|
RectangleRoundness := 0;
|
|
|
|
Size := 10;
|
|
|
|
FloodFillTolerance := 0;
|
2011-04-21 14:42:45 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
Cursor := crCross;
|
2011-05-05 16:42:48 +00:00
|
|
|
|
|
|
|
SelectedDLBMP := TDLBitmap.Create;
|
2011-05-19 09:02:30 +00:00
|
|
|
RegularPolyNum := 5;
|
2011-05-05 16:42:48 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TCustomPictureEdit.Destroy;
|
|
|
|
begin
|
|
|
|
SelectedDLBMP.Free;
|
|
|
|
inherited;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.NewPicture(AWidth, AHeight: integer; APaperColor: TColor);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
Picture.Free;
|
|
|
|
Picture := TPictureBitmap.Create(AWidth, AHeight);
|
|
|
|
PaperColor := APaperColor;
|
2011-03-09 01:14:06 +00:00
|
|
|
Picture.Fill(PaperColor);
|
2006-11-03 16:25:43 +00:00
|
|
|
FModified := False;
|
|
|
|
Change;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.LoadPicture(const FileName: string);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
inherited LoadPicture(FileName);
|
|
|
|
FModified := False;
|
|
|
|
Change;
|
|
|
|
end;
|
|
|
|
|
2008-06-28 14:25:53 +00:00
|
|
|
procedure TCustomPictureEdit.LoadBitmap(ABitmap: TRasterImage);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
inherited LoadBitmap(ABitmap);
|
|
|
|
FModified := False;
|
|
|
|
Change;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.SavePicture(const FileName: string);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
|
|
|
inherited SavePicture(FileName);
|
|
|
|
FModified := False;
|
|
|
|
Change;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.ColorPick(X, Y: integer; Shift: TShiftState);
|
2006-11-03 16:25:43 +00:00
|
|
|
var
|
|
|
|
C: TColor;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
2011-03-09 01:14:06 +00:00
|
|
|
C := Picture.GetColor(X, Y);
|
2006-11-03 16:25:43 +00:00
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
if C <> clNone then
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if ssLeft in Shift then
|
|
|
|
OutlineColor := C;
|
|
|
|
if ssRight in Shift then
|
|
|
|
FillColor := C;
|
|
|
|
if ssMiddle in Shift then
|
|
|
|
PaperColor := C;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.FloodFill(X, Y: integer; Shift: TShiftState);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
2011-04-21 14:42:45 +00:00
|
|
|
if not (ssLeft in Shift) then
|
|
|
|
Picture.EraseMode := ermErase;
|
2006-11-03 16:25:43 +00:00
|
|
|
try
|
2011-04-21 02:04:35 +00:00
|
|
|
//Picture.Canvas.FloodFill(X, Y, FFillColor, fsSurface); //Picture.Canvas.Brush.Color, fsSurface);
|
|
|
|
Picture.Canvas.Brush.Color := FFillColor;
|
2011-04-21 14:42:45 +00:00
|
|
|
Picture.Canvas.FloodFill(x, y, Picture.Canvas.Pixels[x, y], fsSurface);
|
2006-11-03 16:25:43 +00:00
|
|
|
finally
|
2011-03-09 01:14:06 +00:00
|
|
|
Picture.EraseMode := ermNone;
|
2006-11-03 16:25:43 +00:00
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.MaskFloodFill(X, Y: integer; Shift: TShiftState);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
|
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Mask.FillMode := mfXOR;
|
2011-04-21 14:42:45 +00:00
|
|
|
if ssLeft in Shift then
|
|
|
|
Picture.Mask.FillMode := mfAdd;
|
|
|
|
if ssRight in Shift then
|
|
|
|
Picture.Mask.FillMode := mfRemove;
|
2006-11-03 16:25:43 +00:00
|
|
|
|
2011-03-09 01:14:06 +00:00
|
|
|
Picture.MaskFloodFill(X, Y);
|
2006-11-03 16:25:43 +00:00
|
|
|
finally
|
|
|
|
Picture.Mask.FillMode := mfAdd;
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.Eraser(X, Y: integer; Shift: TShiftState);
|
2006-11-03 16:25:43 +00:00
|
|
|
var
|
|
|
|
R: TRect;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2011-04-15 16:41:26 +00:00
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
2011-04-21 14:42:45 +00:00
|
|
|
if ssLeft in Shift then
|
|
|
|
Picture.EraseMode := ermErase;
|
|
|
|
if ssRight in Shift then
|
|
|
|
Picture.EraseMode := ermReplace;
|
2006-11-03 16:25:43 +00:00
|
|
|
try
|
|
|
|
R := Bounds(X - FSize div 2, Y - FSize div 2, FSize, FSize);
|
2011-04-21 14:42:45 +00:00
|
|
|
Picture.Canvas.Pen.Color := FPaperColor;
|
|
|
|
Picture.Canvas.Brush.Color := FpaperColor;
|
2006-11-03 16:25:43 +00:00
|
|
|
case Shape of
|
2011-04-21 14:42:45 +00:00
|
|
|
psRect: Picture.Canvas.FillRect(R.Left, R.Top, R.Right, R.Bottom);
|
|
|
|
psCircle: Picture.FillEllipse(R.Left, R.Top, R.Right, R.Bottom);
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
Picture.EraseMode := ermNone;
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
InvalidatePictureRect(R);
|
|
|
|
end;
|
|
|
|
|
2011-05-05 02:21:34 +00:00
|
|
|
procedure TCustomPictureEdit.ChangeColor(FrColor, TaColor: TColor);
|
|
|
|
begin
|
|
|
|
FromColor := FrColor;
|
|
|
|
ToColor := TaColor;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.ColorReplacer(X, Y: integer; Shift: TShiftState = [ssLeft]);
|
|
|
|
var
|
|
|
|
R: TRect;
|
|
|
|
begin
|
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
BeginDraw;
|
|
|
|
if ssLeft in Shift then
|
|
|
|
Picture.EraseMode := ermErase;
|
|
|
|
if ssRight in Shift then
|
|
|
|
Picture.EraseMode := ermReplace;
|
|
|
|
try
|
|
|
|
R := Bounds(X - FSize div 2, Y - FSize div 2, FSize, FSize);
|
|
|
|
Picture.Canvas.Pen.Color := FPaperColor;
|
|
|
|
Picture.Canvas.Brush.Color := FpaperColor;
|
|
|
|
case Shape of
|
|
|
|
psRect: Picture.ReplaceRectColor(FromColor, ToColor, R, 6, stRoundRect);
|
|
|
|
psCircle: Picture.ReplaceRectColor(FromColor, ToColor, R, 6, stEllipse);
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
Picture.EraseMode := ermNone;
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
InvalidatePictureRect(R);
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.Spray(X, Y: integer; Shift: TShiftState);
|
|
|
|
var
|
|
|
|
R: TRect;
|
|
|
|
begin
|
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
R := Bounds(X - FSize div 2, Y - FSize div 2, FSize, FSize);
|
|
|
|
Picture.Spray(X, Y, 11, FFillColor);
|
2006-11-03 16:25:43 +00:00
|
|
|
finally
|
2011-03-09 01:14:06 +00:00
|
|
|
Picture.EraseMode := ermNone;
|
2011-04-21 14:42:45 +00:00
|
|
|
Picture.RandomEnabled := False;
|
2006-11-03 16:25:43 +00:00
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
InvalidatePictureRect(R);
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.Brush(X, Y: integer; Shift: TShiftState);
|
2006-11-03 16:25:43 +00:00
|
|
|
var
|
|
|
|
R: TRect;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
2011-04-21 14:42:45 +00:00
|
|
|
if not (ssLeft in Shift) then
|
|
|
|
Picture.EraseMode := ermErase;
|
2011-03-09 01:14:06 +00:00
|
|
|
Picture.RandomEnabled := True;
|
2006-11-03 16:25:43 +00:00
|
|
|
try
|
2011-04-21 14:42:45 +00:00
|
|
|
Picture.Canvas.Pen.Color := FFillColor;
|
|
|
|
Picture.Canvas.Brush.Color := FFillColor;
|
2006-11-03 16:25:43 +00:00
|
|
|
R := Bounds(X - FSize div 2, Y - FSize div 2, FSize, FSize);
|
|
|
|
case Shape of
|
2011-04-21 14:42:45 +00:00
|
|
|
psRect: Picture.Canvas.FillRect(R.Left, R.Top, R.Right, R.Bottom);
|
|
|
|
psCircle: Picture.FillEllipse(R.Left, R.Top, R.Right, R.Bottom);
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
finally
|
2011-03-09 01:14:06 +00:00
|
|
|
Picture.EraseMode := ermNone;
|
|
|
|
Picture.RandomEnabled := False;
|
2006-11-03 16:25:43 +00:00
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
InvalidatePictureRect(R);
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.Line(X1, Y1, X2, Y2: integer; Shift: TShiftState);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2011-04-15 16:41:26 +00:00
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
Picture.Canvas.Pen.Color := FOutLineColor;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
2011-04-21 14:42:45 +00:00
|
|
|
if not (ssLeft in Shift) then
|
|
|
|
Picture.EraseMode := ermErase;
|
2006-11-03 16:25:43 +00:00
|
|
|
try
|
2011-04-17 14:34:12 +00:00
|
|
|
if (X1 = X2) and (Y1 = Y2) and (Tool = ptPen) then
|
2011-04-17 13:11:31 +00:00
|
|
|
Picture.Canvas.Pixels[X1, Y1] := FOutLineColor
|
|
|
|
else
|
|
|
|
Picture.Canvas.Line(X1, Y1, X2, Y2);
|
2006-11-03 16:25:43 +00:00
|
|
|
finally
|
2011-03-09 01:14:06 +00:00
|
|
|
Picture.EraseMode := ermNone;
|
2006-11-03 16:25:43 +00:00
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
InvalidatePictureRect(Rect(X1, Y1, X2, Y2));
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.Rectangle(X1, Y1, X2, Y2: integer; Shift: TShiftState);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
2011-04-21 14:42:45 +00:00
|
|
|
if not (ssLeft in Shift) then
|
|
|
|
Picture.EraseMode := ermErase;
|
2006-11-03 16:25:43 +00:00
|
|
|
try
|
2011-04-21 14:42:45 +00:00
|
|
|
Picture.Canvas.Brush.Color := FFillColor;
|
|
|
|
Picture.Canvas.Pen.Color := FOutlineColor;
|
2010-08-31 15:58:43 +00:00
|
|
|
if FFuzzy then
|
|
|
|
begin
|
2011-03-09 01:14:06 +00:00
|
|
|
Picture.FuzzyRectangle(X1, Y1, X2, Y2);
|
2010-08-31 15:58:43 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
if FFillAlpha = 100 then
|
2011-04-21 14:42:45 +00:00
|
|
|
Picture.Canvas.RoundRect(X1, Y1, X2, Y2, FRectangleRoundness,
|
|
|
|
FRectangleRoundness)
|
2010-08-31 15:58:43 +00:00
|
|
|
else
|
2011-03-09 01:14:06 +00:00
|
|
|
Picture.AlphaRectangle(X1, Y1, X2, Y2, FFillAlpha);
|
2010-08-31 15:58:43 +00:00
|
|
|
end;
|
2006-11-03 16:25:43 +00:00
|
|
|
finally
|
2011-03-09 01:14:06 +00:00
|
|
|
Picture.EraseMode := ermNone;
|
2006-11-03 16:25:43 +00:00
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
InvalidatePictureRect(Rect(X1, Y1, X2, Y2));
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.Ellipse(X1, Y1, X2, Y2: integer; Shift: TShiftState);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
2011-04-21 14:42:45 +00:00
|
|
|
if not (ssLeft in Shift) then
|
|
|
|
Picture.EraseMode := ermErase;
|
2006-11-03 16:25:43 +00:00
|
|
|
try
|
2011-04-21 14:42:45 +00:00
|
|
|
Picture.Canvas.Brush.Color := FFillColor;
|
|
|
|
Picture.Canvas.Pen.Color := FOutlineColor;
|
2006-11-03 16:25:43 +00:00
|
|
|
Picture.Canvas.Ellipse(X1, Y1, X2, Y2);
|
|
|
|
finally
|
2011-03-09 01:14:06 +00:00
|
|
|
Picture.EraseMode := ermNone;
|
2006-11-03 16:25:43 +00:00
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
InvalidatePictureRect(Rect(X1, Y1, X2, Y2));
|
|
|
|
end;
|
|
|
|
|
2011-05-19 04:32:37 +00:00
|
|
|
procedure TCustomPictureEdit.RegularPolygon(X1, Y1, X2, Y2: integer; Shift: TShiftState = [ssLeft]);
|
|
|
|
begin
|
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
BeginDraw;
|
|
|
|
if not (ssLeft in Shift) then
|
|
|
|
Picture.EraseMode := ermErase;
|
|
|
|
try
|
|
|
|
Picture.Canvas.Brush.Color := FFillColor;
|
|
|
|
Picture.Canvas.Pen.Color := FOutlineColor;
|
2011-05-19 09:02:30 +00:00
|
|
|
Picture.RegularPolygon(Point(X1, Y1), Point(X2, Y2), RegularPolyNum);
|
2011-05-19 04:32:37 +00:00
|
|
|
finally
|
|
|
|
Picture.EraseMode := ermNone;
|
|
|
|
EndDraw;
|
|
|
|
end;
|
2011-05-19 09:02:30 +00:00
|
|
|
//InvalidatePictureRect(Rect(X1, Y1, X2, Y2));
|
|
|
|
InvalidatePictureRect(Rect(0, 0, Width, Height));
|
2011-05-19 04:32:37 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-19 03:37:23 +00:00
|
|
|
procedure TCustomPictureEdit.ProcessPointAddr;
|
|
|
|
var i: integer; E, F: TPoint;
|
2011-04-21 14:42:45 +00:00
|
|
|
begin
|
2011-05-19 03:37:23 +00:00
|
|
|
if pcount > 2 then
|
2011-04-21 14:42:45 +00:00
|
|
|
begin
|
2011-05-19 03:37:23 +00:00
|
|
|
E := PictureToClient(paddr[i]);
|
|
|
|
F := PictureToClient(paddr[i + 1]);
|
|
|
|
for i := 0 to pcount - 2 do
|
|
|
|
Canvas.Line(E.x, E.y, F.x, F.y);
|
|
|
|
end;
|
2011-04-21 14:42:45 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-19 03:37:23 +00:00
|
|
|
procedure TCustomPictureEdit.Polygon(polyaddr: array of TPoint);
|
2011-04-21 14:42:45 +00:00
|
|
|
var
|
2011-05-19 03:37:23 +00:00
|
|
|
i: integer; tempaddr: array of TPoint;
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
BeginDraw;
|
|
|
|
try
|
2011-05-19 03:37:23 +00:00
|
|
|
SetLength(tempaddr, pcount);
|
2011-04-21 14:42:45 +00:00
|
|
|
Picture.Canvas.Brush.Color := FFillColor;
|
|
|
|
Picture.Canvas.Pen.Color := FOutlineColor;
|
2011-05-19 03:37:23 +00:00
|
|
|
for i := 0 to pcount - 1 do
|
|
|
|
tempaddr[i] := polyaddr[i]; //PictureToClient(polyaddr[i]);
|
|
|
|
Picture.Canvas.Polygon(tempaddr);
|
2011-04-21 14:42:45 +00:00
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
2011-05-19 03:37:23 +00:00
|
|
|
InvalidatePictureRect(Rect(0, 0, Width, Height));
|
2011-04-21 14:42:45 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-19 12:50:02 +00:00
|
|
|
procedure TCustomPictureEdit.FinishPolygon;
|
|
|
|
begin
|
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Canvas.Brush.Color := FFillColor;
|
|
|
|
Picture.Canvas.Pen.Color := FOutlineColor;
|
|
|
|
Picture.Canvas.Polygon(paddr);
|
|
|
|
pcount := 0;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
InvalidatePictureRect(Rect(0, 0, Width, Height));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.PolygonWithoutEdge(polyaddr: array of TPoint);
|
|
|
|
var
|
|
|
|
i: integer;
|
|
|
|
begin
|
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Canvas.Brush.Color := FFillColor;
|
|
|
|
Picture.Canvas.Pen.Color := FOutlineColor;
|
|
|
|
for i := 1 to pcount - 1 do
|
|
|
|
Picture.Canvas.Line(polyaddr[i - 1].x, polyaddr[i - 1].y, polyaddr[i].x, polyaddr[i].y);
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
InvalidatePictureRect(Rect(0, 0, Width, Height));
|
|
|
|
end;
|
|
|
|
|
2011-04-24 16:15:17 +00:00
|
|
|
procedure TCustomPictureEdit.ProcessEditorText(X1, Y1, X2, Y2: integer);
|
|
|
|
var P: TRect;
|
|
|
|
begin
|
|
|
|
TextEditor.IMGCanvas := Picture.Canvas;
|
|
|
|
TextEditor.Parent := Self;
|
|
|
|
P := PictureToClient(Rect(X1, X2, X1, X2));
|
|
|
|
TextEditor.StartEdit(FPictureRect.Left +X1, FPictureRect.Top + Y1, X1, Y1);
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.Mask(X1, Y1, X2, Y2: integer; Shift: TShiftState);
|
|
|
|
begin
|
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
|
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Mask.FillMode := mfXOR;
|
2011-04-21 14:42:45 +00:00
|
|
|
if ssLeft in Shift then
|
|
|
|
Picture.Mask.FillMode := mfAdd;
|
|
|
|
if ssRight in Shift then
|
|
|
|
Picture.Mask.FillMode := mfRemove;
|
2006-11-03 16:25:43 +00:00
|
|
|
|
|
|
|
case MaskTool of
|
2011-04-21 14:42:45 +00:00
|
|
|
mtEllipse: Picture.Mask.Ellipse(X1, Y1, X2, Y2);
|
|
|
|
mtRectangle: Picture.Mask.Rectangle(X1, Y1, X2, Y2);
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
2011-05-05 16:42:48 +00:00
|
|
|
|
|
|
|
Picture.Canvas.Pen.Style := psSolid; //psDot;
|
|
|
|
Picture.Canvas.Pen.Color := clGray;
|
|
|
|
Picture.Canvas.Pen.Mode := pmNotXor;
|
|
|
|
Picture.Canvas.Brush.Color := $00EACAB6;
|
|
|
|
//Canvas.Brush.Style := bsClear;
|
|
|
|
SelectedDLBMP.Width := Abs(X2 - X1);
|
|
|
|
SelectedDLBMP.Height := Abs(Y2 - Y1);
|
|
|
|
SelectedDLBMP.Canvas.CopyRect(Rect(0, 0, SelectedDLBMP.Width, SelectedDLBMP.Height),
|
|
|
|
Picture.Canvas, Rect(X1, Y1, X2, Y2));
|
|
|
|
// if SelectedDLBMP <> nil then
|
2011-05-06 10:04:42 +00:00
|
|
|
// SelectedDLBMP.CopyToClipboard;
|
|
|
|
//SelectedDLBMP.Canvas.Rectangle(2,2,Width-2,Height-2);
|
|
|
|
// Canvas.Draw(0,0,SelectedDLBMP);
|
|
|
|
Picture.Canvas.Rectangle(X1, Y1, X2, Y2);
|
2011-05-05 16:42:48 +00:00
|
|
|
Picture.Canvas.Pen.Mode := pmCopy;
|
|
|
|
Picture.Canvas.Pen.Style := psSolid;
|
|
|
|
SeleLeft := X1;
|
|
|
|
SeleTop := Y1;
|
|
|
|
XX1 := X1;
|
|
|
|
XX2 := X2;
|
|
|
|
YY1 := Y1;
|
|
|
|
YY2 := Y2;
|
2006-11-03 16:25:43 +00:00
|
|
|
finally
|
|
|
|
Picture.Mask.FillMode := mfAdd;
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
InvalidatePictureRect(Rect(X1, Y1, X2, Y2));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.FlipHorizontally;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.FlipHorz;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.FlipVertically;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.FlipVert;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.Rotate90Clockwise;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Rotate90;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.Rotate180Clockwise;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Rotate180;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.Rotate270Clockwise;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Rotate270;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
2011-04-27 07:57:44 +00:00
|
|
|
procedure TCustomPictureEdit.ColorReplace(ColorFrom, ColorTo: TColor);
|
|
|
|
begin
|
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.ColorReplace(ColorFrom, ColorTo);
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.StretchTruncate(AWidth, AHeight: integer);
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.StretchTrunc(AWidth, AHeight);
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.StretchSmooth(AWidth, AHeight: integer;
|
2006-11-03 16:25:43 +00:00
|
|
|
Method: TSmoothMethod);
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.StretchSmooth(AWidth, AHeight, Method);
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
2011-04-21 14:42:45 +00:00
|
|
|
procedure TCustomPictureEdit.ResizePaper(AWidth, AHeight: integer;
|
2006-11-03 16:25:43 +00:00
|
|
|
PicturePos: TPicturePos);
|
|
|
|
var
|
|
|
|
New: TPictureBitmap;
|
2011-04-21 14:42:45 +00:00
|
|
|
X, Y: integer;
|
2006-11-03 16:25:43 +00:00
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
New := TPictureBitmap.Create(AWidth, AHeight);
|
|
|
|
try
|
2011-03-09 01:14:06 +00:00
|
|
|
New.PaperColor := PaperColor;
|
|
|
|
New.Fill(PaperColor);
|
2006-11-03 16:25:43 +00:00
|
|
|
|
|
|
|
case PicturePos of
|
2011-04-21 14:42:45 +00:00
|
|
|
ppTopLeft, ppCenterLeft, ppBottomLeft: X := 0;
|
|
|
|
ppTopCenter, ppCentered, ppBottomCenter: X :=
|
|
|
|
Round((AWidth - Picture.Width) * 0.5);
|
|
|
|
ppTopRight, ppCenterRight, ppBottomRight: X := AWidth - Picture.Width;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
case PicturePos of
|
2011-04-21 14:42:45 +00:00
|
|
|
ppTopLeft, ppTopCenter, ppTopRight: Y := 0;
|
|
|
|
ppCenterLeft, ppCentered, ppCenterRight: Y :=
|
|
|
|
Round((AHeight - Picture.Height) * 0.5);
|
|
|
|
ppBottomLeft, ppBottomCenter, ppBottomRight: Y := AHeight - Picture.Height;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
New.Draw(X, Y, Picture);
|
|
|
|
New.Mask.Draw(X, Y, Picture.Mask);
|
|
|
|
|
|
|
|
Picture.SwapWith(New);
|
|
|
|
finally
|
|
|
|
New.Free;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.ClipPaperToMask;
|
|
|
|
var
|
|
|
|
New: TPictureBitmap;
|
|
|
|
R: TRect;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
// R := Picture.Mask.GetMaskedRect;
|
|
|
|
if (Picture.Width = (R.Right - R.Left)) and (Picture.Height =
|
|
|
|
(R.Bottom - R.Top)) then
|
|
|
|
Exit;
|
|
|
|
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
New := TPictureBitmap.Create(R.Right - R.Left, R.Bottom - R.Top);
|
|
|
|
try
|
|
|
|
New.Draw(-R.Left, -R.Top, Picture);
|
|
|
|
New.Mask.Draw(-R.Left, -R.Top, Picture.Mask);
|
|
|
|
|
|
|
|
Picture.SwapWith(New);
|
|
|
|
finally
|
|
|
|
New.Free;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.RemoveMask;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Mask.Clear;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.InvertMask;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Mask.Invert;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.Cut;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.CutToClipboard;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.Copy;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2011-05-06 10:04:42 +00:00
|
|
|
if Tool <> ptMask then
|
|
|
|
Picture.CopyToClipboard
|
|
|
|
else
|
|
|
|
SelectedDLBMP.CopyToClipboard;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.Paste;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
2011-03-18 12:22:13 +00:00
|
|
|
//Assert(True, 'Implement Paste');
|
2011-05-06 10:04:42 +00:00
|
|
|
SelectedDLBMP.PasteFromClipboard;
|
|
|
|
Picture.Canvas.Draw(0, 0, SelectedDLBMP);
|
2006-11-03 16:25:43 +00:00
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.Delete;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Delete;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.SelectAll;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Mask.ClearWhite;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.Invert;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Invert;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.Grayscale;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Grayscale;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.Disable;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
BeginDraw;
|
|
|
|
try
|
|
|
|
Picture.Disable;
|
|
|
|
finally
|
|
|
|
EndDraw;
|
|
|
|
end;
|
|
|
|
UpdatePicture;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.BeginDraw;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
|
|
|
|
2011-03-09 01:14:06 +00:00
|
|
|
Picture.OutlineColor := OutlineColor;
|
|
|
|
Picture.FillColor := FillColor;
|
|
|
|
Picture.PaperColor := PaperColor;
|
|
|
|
Picture.RandomDensity := Round(RandomDensity * MAXRANDOMDENSITY);
|
|
|
|
Picture.RectangleRoundness := RectangleRoundness;
|
|
|
|
Picture.FloodFillTolerance := Round(FloodFillTolerance * MAXDIFFERENCE);
|
|
|
|
Picture.DrawMode := FillAndOutline;
|
2006-11-03 16:25:43 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.EndDraw;
|
|
|
|
begin
|
2011-04-21 14:42:45 +00:00
|
|
|
if Picture = nil then
|
|
|
|
Exit;
|
2006-11-03 16:25:43 +00:00
|
|
|
FModified := True;
|
|
|
|
Change;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCustomPictureEdit.UpdatePicture;
|
|
|
|
begin
|
|
|
|
UpdatePictureRect;
|
|
|
|
PictureSizeChange;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|
|
|
|
|