You've already forked lazarus-ccr
Add text to image.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1598 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
unit DLBitmap;
|
||||
unit DLBitmap;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
@ -6,7 +6,8 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLType, LCLIntf, LMessages, LCLProc, Controls, Graphics,
|
||||
Forms, Types, IntfGraphics, FPImage, Math, FPImgCanv, FPCanvas, ClipBrd;
|
||||
Forms, Types, IntfGraphics, FPImage, Math, FPImgCanv, FPCanvas, StdCtrls,
|
||||
ClipBrd, ExtCtrls;
|
||||
|
||||
type
|
||||
tagRGBATRIPLE = record
|
||||
@ -72,6 +73,41 @@ type
|
||||
property PaperColor: TColor read GetPaperColor write SetPaperColor;
|
||||
end;
|
||||
|
||||
TTextEditor = class;
|
||||
|
||||
TTextEdit = class(TCustomEdit)
|
||||
private
|
||||
FCanvas: TCanvas;
|
||||
protected
|
||||
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
||||
public
|
||||
Editor: TTextEditor;
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure EraseBackground(DC: HDC); override;
|
||||
property Canvas: TCanvas read FCanvas write FCanvas;
|
||||
end;
|
||||
|
||||
TTextEditor = class(TCustomControl)
|
||||
private
|
||||
FEdit: TTextEdit;
|
||||
FTimer: TIdleTimer;
|
||||
flashnum: integer;
|
||||
protected
|
||||
procedure Paint; override;
|
||||
procedure DrawFlashLine(Sender: TObject);
|
||||
procedure Changing(Sender: TObject);
|
||||
public
|
||||
IMGCanvas: TCanvas;
|
||||
PositionIndex, StartX, StartY, TextX, TextY: integer;
|
||||
procedure StartEdit(ContainerX, ContainerY, IMGX, IMGY: integer);
|
||||
procedure StopEdit;
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
procedure EraseBackground(DC: HDC); override;
|
||||
property Editor: TTextEdit read FEdit write FEdit;
|
||||
end;
|
||||
|
||||
procedure LazBMPRotate90(const aBitmap: TDLBitmap; IsTurnRight: boolean);
|
||||
procedure BMPRotate90(const Bitmap: TDLBitmap);
|
||||
procedure DrawSamePixel(ABitmap: TDLBitmap; Value: integer);
|
||||
@ -85,10 +121,10 @@ procedure ChangeRGB(SrcBmp: TDLBitmap; RedChange, GreenChange, BlueChange: integ
|
||||
procedure ChangeBrightness(SrcBmp: TDLBitmap; ValueChange: integer);
|
||||
procedure ChangeContrast(SrcBmp: TDLBitmap; ValueChange: integer);
|
||||
procedure SprayPoints(DLBmp: TDLBitmap; X, Y: integer; Radians: integer; PColor: TColor);
|
||||
function GetRColor(const Color: TColor): Byte;
|
||||
function GetGColor(const Color: TColor): Byte;
|
||||
function GetBColor(const Color: TColor): Byte;
|
||||
procedure SprayPoints(aCanvas: TCanvas; X, Y: integer; Radians: Integer; PColor: TColor);
|
||||
function GetRColor(const Color: TColor): byte;
|
||||
function GetGColor(const Color: TColor): byte;
|
||||
function GetBColor(const Color: TColor): byte;
|
||||
procedure SprayPoints(aCanvas: TCanvas; X, Y: integer; Radians: integer; PColor: TColor);
|
||||
|
||||
implementation
|
||||
|
||||
@ -386,5 +422,132 @@ begin
|
||||
|
||||
end;
|
||||
|
||||
constructor TTextEdit.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
BorderStyle := bsNone;
|
||||
Width := 1;
|
||||
Parent := TWinControl(AOwner);
|
||||
FCanvas := TCanvas.Create;
|
||||
FCanvas.Handle := GetDC(Self.Handle);
|
||||
FCanvas.Brush.Style := bsClear;
|
||||
end;
|
||||
|
||||
destructor TTextEdit.Destroy;
|
||||
begin
|
||||
inherited;
|
||||
FCanvas.Free;
|
||||
end;
|
||||
|
||||
procedure TTextEdit.EraseBackground(DC: HDC);
|
||||
begin
|
||||
inherited EraseBackground(DC);
|
||||
|
||||
end;
|
||||
|
||||
procedure TTextEdit.KeyDown(var Key: Word; Shift: TShiftState);
|
||||
begin
|
||||
inherited;
|
||||
if Editor.PositionIndex <> SelStart then
|
||||
begin
|
||||
Editor.PositionIndex := Length(Text); //SelStart;
|
||||
Editor.DrawFlashLine(nil);
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TTextEditor.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
BorderStyle := bsNone;
|
||||
Width := 1;
|
||||
Height := 16;
|
||||
Parent := TWinControl(AOwner);
|
||||
FEdit := TTextEdit.Create(AOwner);
|
||||
FEdit.Parent := Self;
|
||||
FEdit.Left := 3;
|
||||
FEdit.Top := 0;
|
||||
FEdit.Editor := Self;
|
||||
FEdit.Show;
|
||||
FTimer := TIdleTimer.Create(AOwner);
|
||||
FTimer.OnTimer := @DrawFlashLine;
|
||||
FTimer.Interval := 500;
|
||||
FTimer.Enabled := False;
|
||||
FEdit.OnChange := @Changing;
|
||||
Visible := False;
|
||||
end;
|
||||
|
||||
destructor TTextEditor.Destroy;
|
||||
begin
|
||||
inherited;
|
||||
FEdit.Free;
|
||||
FTimer.Free;
|
||||
end;
|
||||
|
||||
procedure TTextEditor.EraseBackground(DC: HDC);
|
||||
begin
|
||||
inherited EraseBackground(DC);
|
||||
|
||||
end;
|
||||
|
||||
procedure TTextEditor.Paint;
|
||||
begin
|
||||
inherited Paint;
|
||||
end;
|
||||
|
||||
procedure TTextEditor.DrawFlashLine(Sender: TObject);
|
||||
var FlashLeft: integer; LeftText: string;
|
||||
begin
|
||||
FEdit.SetFocus;
|
||||
flashnum := flashnum + 1;
|
||||
if flashnum > 1000 then
|
||||
flashnum := 0;
|
||||
if flashnum mod 2 = 0 then
|
||||
Canvas.Pen.Color := clWhite
|
||||
else
|
||||
Canvas.Pen.Color := clBlack;
|
||||
LeftText := Copy(FEdit.Text, 1, PositionIndex);
|
||||
FlashLeft := StartX + Canvas.TextWidth(LeftText);
|
||||
Left := FlashLeft;
|
||||
Top := StartY;
|
||||
Canvas.Line(0, 0, 0, Height);
|
||||
end;
|
||||
|
||||
procedure TTextEditor.StartEdit(ContainerX, ContainerY, IMGX, IMGY: integer);
|
||||
begin
|
||||
if IMGCanvas = nil then
|
||||
Exit;
|
||||
Left := ContainerX;
|
||||
Top := ContainerY;
|
||||
StartX := ContainerX;
|
||||
StartY := ContainerY;
|
||||
TextX := IMGX;
|
||||
TextY := IMGY;
|
||||
FEdit.Text := '';
|
||||
Show;
|
||||
FTimer.Enabled := True;
|
||||
end;
|
||||
|
||||
procedure TTextEditor.StopEdit;
|
||||
begin
|
||||
FTimer.Enabled := False;
|
||||
Hide;
|
||||
end;
|
||||
|
||||
procedure TTextEditor.Changing(Sender: TObject);
|
||||
var TextLeft: integer; LeftText, RightText: string;
|
||||
begin
|
||||
LeftText := Copy(FEdit.Text, 1, PositionIndex);
|
||||
RightText := Copy(FEdit.Text, PositionIndex + 1, Length(FEdit.text));
|
||||
TextLeft := TextX + Canvas.TextWidth(LeftText);
|
||||
if IMGCanvas = nil then
|
||||
Exit;
|
||||
//IMGCanvas.TextOut(22, 22, FEdit.Text);
|
||||
IMGCanvas.Brush.Style := bsClear;
|
||||
IMGCanvas.TextOut(TextLeft, TextY, RightText);
|
||||
//if PositionIndex <> FEdit.SelStart then
|
||||
// PositionIndex := FEdit.SelStart;
|
||||
PositionIndex := Length(FEdit.Text);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -560,7 +560,7 @@ end;
|
||||
|
||||
procedure SprayPoints(aCanvas: TCanvas; X, Y: integer; Radians: Integer; PColor: TColor);
|
||||
var
|
||||
i, a, b, temp, ci, center: Integer;
|
||||
i, a, b, temp, ci, center, Radian2, Radian3: Integer;
|
||||
begin
|
||||
if aCanvas = nil then
|
||||
Exit;
|
||||
@ -574,35 +574,25 @@ begin
|
||||
b := Random(Round(Radians * 0.65));
|
||||
if (temp < 50) then b := 0 - b;
|
||||
if (a * a + b * b < Sqr(Round(Radians * 0.65))) then
|
||||
begin
|
||||
aCanvas.Pixels[X + a, Y + b] := PColor;
|
||||
end;
|
||||
end;
|
||||
for i := 0 to Radians div 3 do
|
||||
begin
|
||||
Radian2 := Radians div 3;
|
||||
temp := Random(100);
|
||||
a := Random(Round(Radians * 0.65));
|
||||
a := Random(Round(Radian2 * 0.65));
|
||||
if (temp < 50) then a := 0 - a;
|
||||
temp := Random(100);
|
||||
b := Random(Round(Radians * 0.65));
|
||||
b := Random(Round(Radian2 * 0.65));
|
||||
if (temp < 50) then b := 0 - b;
|
||||
if (a * a + b * b < Sqr(Round(Radians * 0.65))) then
|
||||
begin
|
||||
if (a * a + b * b < Sqr(Round(Radian2 * 0.65))) then
|
||||
aCanvas.Pixels[X + a, Y + b] := PColor;
|
||||
end;
|
||||
end;
|
||||
for i := 0 to Radians * 2 div 3 do
|
||||
begin
|
||||
Radian3 := Radians * 2 div 3;
|
||||
temp := Random(100);
|
||||
a := Random(Round(Radians * 0.65));
|
||||
a := Random(Round(Radian3 * 0.65));
|
||||
if (temp < 50) then a := 0 - a;
|
||||
temp := Random(100);
|
||||
b := Random(Round(Radians * 0.65));
|
||||
b := Random(Round(Radian3 * 0.65));
|
||||
if (temp < 50) then b := 0 - b;
|
||||
if (a * a + b * b < Sqr(Round(Radians * 0.65))) then
|
||||
begin
|
||||
if (a * a + b * b < Sqr(Round(Radian3 * 0.65))) then
|
||||
aCanvas.Pixels[X + a, Y + b] := PColor;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<CursorPos X="14" Y="4"/>
|
||||
<UsageCount Value="68"/>
|
||||
<UsageCount Value="72"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
@ -60,23 +60,23 @@
|
||||
<HasResources Value="True"/>
|
||||
<ResourceBaseClass Value="Form"/>
|
||||
<UnitName Value="Main"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="224"/>
|
||||
<CursorPos X="29" Y="251"/>
|
||||
<UsageCount Value="68"/>
|
||||
<TopLine Value="823"/>
|
||||
<CursorPos X="25" Y="842"/>
|
||||
<UsageCount Value="72"/>
|
||||
<Loaded Value="True"/>
|
||||
<LoadedDesigner Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<UnitName Value="PictureCtrls"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1031"/>
|
||||
<CursorPos X="39" Y="1047"/>
|
||||
<UsageCount Value="30"/>
|
||||
<TopLine Value="667"/>
|
||||
<CursorPos X="12" Y="684"/>
|
||||
<UsageCount Value="31"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
@ -172,8 +172,8 @@
|
||||
<Filename Value="T:\fpclaz\laz\lcl\graphics.pp"/>
|
||||
<UnitName Value="Graphics"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1086"/>
|
||||
<CursorPos X="15" Y="1102"/>
|
||||
<TopLine Value="1133"/>
|
||||
<CursorPos X="81" Y="1149"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit12>
|
||||
<Unit13>
|
||||
@ -181,9 +181,9 @@
|
||||
<UnitName Value="PictureManager"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="1"/>
|
||||
<TopLine Value="268"/>
|
||||
<CursorPos X="100" Y="4"/>
|
||||
<UsageCount Value="31"/>
|
||||
<UsageCount Value="32"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit13>
|
||||
<Unit14>
|
||||
@ -336,8 +336,8 @@
|
||||
<Filename Value="T:\fpclaz\laz\lcl\forms.pp"/>
|
||||
<UnitName Value="Forms"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="597"/>
|
||||
<CursorPos X="14" Y="607"/>
|
||||
<TopLine Value="176"/>
|
||||
<CursorPos X="3" Y="195"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit32>
|
||||
<Unit33>
|
||||
@ -360,9 +360,9 @@
|
||||
<UnitName Value="DLBitmap"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="351"/>
|
||||
<CursorPos X="19" Y="380"/>
|
||||
<UsageCount Value="13"/>
|
||||
<TopLine Value="514"/>
|
||||
<CursorPos X="54" Y="541"/>
|
||||
<UsageCount Value="14"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit35>
|
||||
<Unit36>
|
||||
@ -385,17 +385,17 @@
|
||||
<Filename Value="T:\fpclaz\laz\lcl\controls.pp"/>
|
||||
<UnitName Value="Controls"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="48"/>
|
||||
<CursorPos X="29" Y="64"/>
|
||||
<TopLine Value="956"/>
|
||||
<CursorPos X="14" Y="975"/>
|
||||
<UsageCount Value="10"/>
|
||||
</Unit38>
|
||||
<Unit39>
|
||||
<Filename Value="DLBmpUtils.inc"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<WindowIndex Value="0"/>
|
||||
<TopLine Value="509"/>
|
||||
<CursorPos X="28" Y="543"/>
|
||||
<UsageCount Value="11"/>
|
||||
<TopLine Value="561"/>
|
||||
<CursorPos X="32" Y="562"/>
|
||||
<UsageCount Value="12"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit39>
|
||||
<Unit40>
|
||||
@ -409,124 +409,124 @@
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="683" Column="54" TopLine="667"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="818" Column="22" TopLine="786"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="1015" Column="36" TopLine="994"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="819" Column="16" TopLine="787"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="1038" Column="20" TopLine="1022"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="820" Column="19" TopLine="788"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="DLBitmap.pas"/>
|
||||
<Caret Line="375" Column="24" TopLine="354"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="821" Column="22" TopLine="789"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="DLBmpUtils.inc"/>
|
||||
<Caret Line="490" Column="41" TopLine="480"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="822" Column="18" TopLine="790"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="DLBmpUtils.inc"/>
|
||||
<Caret Line="507" Column="29" TopLine="497"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="823" Column="17" TopLine="791"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="DLBitmap.pas"/>
|
||||
<Caret Line="87" Column="54" TopLine="65"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="824" Column="20" TopLine="792"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="DLBitmap.pas"/>
|
||||
<Caret Line="375" Column="24" TopLine="347"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="825" Column="22" TopLine="793"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="DLBmpUtils.inc"/>
|
||||
<Caret Line="497" Column="22" TopLine="487"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="826" Column="20" TopLine="794"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="DLBmpUtils.inc"/>
|
||||
<Caret Line="499" Column="41" TopLine="478"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="828" Column="18" TopLine="796"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="DLBitmap.pas"/>
|
||||
<Caret Line="91" Column="1" TopLine="65"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="831" Column="36" TopLine="799"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="8" Column="97" TopLine="3"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="833" Column="20" TopLine="857"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="111" Column="32" TopLine="79"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="1194" Column="3" TopLine="1175"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="114" Column="54" TopLine="85"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="367" Column="23" TopLine="344"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="178" Column="22" TopLine="146"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="487" Column="13" TopLine="455"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="668" Column="55" TopLine="822"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="494" Column="13" TopLine="462"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="680" Column="14" TopLine="661"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="553" Column="13" TopLine="521"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="684" Column="21" TopLine="661"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="560" Column="13" TopLine="528"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="699" Column="35" TopLine="682"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="581" Column="13" TopLine="549"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="737" Column="27" TopLine="708"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="588" Column="13" TopLine="556"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="738" Column="12" TopLine="708"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="595" Column="13" TopLine="563"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="3" Column="103" TopLine="1"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="630" Column="13" TopLine="598"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="111" Column="32" TopLine="79"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="637" Column="13" TopLine="605"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="114" Column="54" TopLine="82"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="644" Column="13" TopLine="612"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="178" Column="22" TopLine="146"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="658" Column="13" TopLine="626"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="690" Column="12" TopLine="657"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="665" Column="13" TopLine="633"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="689" Column="30" TopLine="665"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="835" Column="13" TopLine="803"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="684" Column="40" TopLine="665"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="842" Column="29" TopLine="806"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="686" Column="20" TopLine="667"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="480" Column="28" TopLine="462"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="picturectrls.pas"/>
|
||||
<Caret Line="1049" Column="31" TopLine="1029"/>
|
||||
<Filename Value="main.pas"/>
|
||||
<Caret Line="842" Column="24" TopLine="823"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
|
@ -1,7 +1,7 @@
|
||||
object MainForm: TMainForm
|
||||
Left = 135
|
||||
Left = 260
|
||||
Height = 681
|
||||
Top = 90
|
||||
Top = 147
|
||||
Width = 935
|
||||
Caption = 'Lazarus Image Editor'
|
||||
ClientHeight = 659
|
||||
@ -40,6 +40,7 @@
|
||||
Images = ImageListTools
|
||||
Indent = 0
|
||||
TabOrder = 0
|
||||
OnClick = ToolBarToolsClick
|
||||
object ToolSpray: TToolButton
|
||||
Left = 0
|
||||
Hint = 'Spray'
|
||||
@ -153,11 +154,22 @@
|
||||
end
|
||||
object ToolBrush: TToolButton
|
||||
Left = 0
|
||||
Hint = 'Brush'
|
||||
Top = 402
|
||||
Caption = 'ToolBrush'
|
||||
Grouped = True
|
||||
ImageIndex = 5
|
||||
OnClick = ToolBrushClick
|
||||
end
|
||||
object ToolText: TToolButton
|
||||
Left = 0
|
||||
Hint = 'Text'
|
||||
Top = 442
|
||||
Caption = 'ToolBrush'
|
||||
Grouped = True
|
||||
ImageIndex = 5
|
||||
OnClick = ToolTextClick
|
||||
end
|
||||
end
|
||||
end
|
||||
object StatusBar: TStatusBar
|
||||
@ -387,7 +399,7 @@
|
||||
object ComboBoxZoom: TComboBox
|
||||
Left = 0
|
||||
Height = 27
|
||||
Top = 2
|
||||
Top = 3
|
||||
Width = 76
|
||||
Anchors = [akLeft]
|
||||
ItemHeight = 19
|
||||
@ -422,6 +434,43 @@
|
||||
ImageIndex = 11
|
||||
OnClick = ZoomOutBtnClick
|
||||
end
|
||||
object ToolButton1: TToolButton
|
||||
Left = 534
|
||||
Top = 0
|
||||
Width = 8
|
||||
Caption = 'ToolButton1'
|
||||
Style = tbsSeparator
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 542
|
||||
Height = 32
|
||||
Top = 0
|
||||
Width = 168
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 32
|
||||
ClientWidth = 168
|
||||
TabOrder = 1
|
||||
object FontListBox: TComboBox
|
||||
Left = 2
|
||||
Height = 27
|
||||
Top = 3
|
||||
Width = 112
|
||||
ItemHeight = 19
|
||||
OnChange = FontListBoxChange
|
||||
OnClick = FontListBoxClick
|
||||
Style = csDropDownList
|
||||
TabOrder = 0
|
||||
end
|
||||
object FontSize: TSpinEdit
|
||||
Left = 117
|
||||
Height = 27
|
||||
Top = 3
|
||||
Width = 50
|
||||
OnChange = FontSizeChange
|
||||
TabOrder = 1
|
||||
Value = 10
|
||||
end
|
||||
end
|
||||
end
|
||||
object PanelOptions: TPanel
|
||||
Left = 0
|
||||
@ -1299,9 +1348,9 @@
|
||||
TabOrder = 5
|
||||
object checkFuzzy: TCheckBox
|
||||
Left = 4
|
||||
Height = 23
|
||||
Height = 19
|
||||
Top = 9
|
||||
Width = 24
|
||||
Width = 20
|
||||
OnChange = checkFuzzyChange
|
||||
TabOrder = 0
|
||||
end
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Menus,
|
||||
ExtCtrls, ComCtrls, ActnList, StdActns, ExtDlgs, Buttons, StdCtrls, Spin,
|
||||
NewDialog, ResizeDialog, ResizePaperDialog, AboutDialog,
|
||||
NewDialog, ResizeDialog, ResizePaperDialog, AboutDialog, DLBitmap,
|
||||
PictureManager, PictureCtrls, ColorPalette;
|
||||
|
||||
type
|
||||
@ -45,6 +45,7 @@ type
|
||||
ColorsDisable: TAction;
|
||||
ColorsGrayscale: TAction;
|
||||
ColorsInvert: TAction;
|
||||
FontListBox: TComboBox;
|
||||
EditCopy: TEditCopy;
|
||||
EditCut: TEditCut;
|
||||
EditDelete: TEditDelete;
|
||||
@ -66,6 +67,7 @@ type
|
||||
MaskRemove: TAction;
|
||||
Palette: TColorPalette;
|
||||
MenuItemShowGrid: TMenuItem;
|
||||
Panel1: TPanel;
|
||||
PanelTolerance1: TPanel;
|
||||
PanelTolerance2: TPanel;
|
||||
PictureClipPaperToMask: TAction;
|
||||
@ -75,6 +77,7 @@ type
|
||||
Rotate270: TAction;
|
||||
Rotate90: TAction;
|
||||
RotateCustom: TAction;
|
||||
FontSize: TSpinEdit;
|
||||
spinFillAlpha: TSpinEdit;
|
||||
MenuItemShowMask: TMenuItem;
|
||||
MenuItemView: TMenuItem;
|
||||
@ -164,6 +167,8 @@ type
|
||||
ExportResourceDialog: TSaveDialog;
|
||||
SavePictureDialog: TSavePictureDialog;
|
||||
ToolBrush: TToolButton;
|
||||
ToolButton1: TToolButton;
|
||||
ToolText: TToolButton;
|
||||
ZoomInBtn: TToolButton;
|
||||
ZoomOutBtn: TToolButton;
|
||||
ToolCircleShape: TSpeedButton;
|
||||
@ -232,6 +237,9 @@ type
|
||||
procedure FileSaveExecute(Sender: TObject);
|
||||
procedure FlipHorizontallyExecute(Sender: TObject);
|
||||
procedure FlipVerticallyExecute(Sender: TObject);
|
||||
procedure FontListBoxChange(Sender: TObject);
|
||||
procedure FontListBoxClick(Sender: TObject);
|
||||
procedure FontSizeChange(Sender: TObject);
|
||||
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormShow(Sender: TObject);
|
||||
@ -258,7 +266,9 @@ type
|
||||
procedure Rotate270Execute(Sender: TObject);
|
||||
procedure Rotate90Execute(Sender: TObject);
|
||||
procedure spinFillAlphaChange(Sender: TObject);
|
||||
procedure ToolBarToolsClick(Sender: TObject);
|
||||
procedure ToolBrushClick(Sender: TObject);
|
||||
procedure ToolTextClick(Sender: TObject);
|
||||
procedure ZoomInBtnClick(Sender: TObject);
|
||||
procedure ZoomOutBtnClick(Sender: TObject);
|
||||
procedure ToolCircleShapeClick(Sender: TObject);
|
||||
@ -298,6 +308,7 @@ type
|
||||
procedure UpdatePictureToolsEnabled;
|
||||
procedure UpdateAll;
|
||||
public
|
||||
TextEditor: TTextEditor;
|
||||
procedure FileNewOnStart;
|
||||
procedure OpenImageFile(FileName: string);
|
||||
property ActivePicture: TPictureBitmap read GetActivePicture;
|
||||
@ -463,6 +474,12 @@ begin
|
||||
ActivePictureEdit.FillAlpha := spinFillAlpha.Value;
|
||||
end;
|
||||
|
||||
procedure TMainForm.ToolBarToolsClick(Sender: TObject);
|
||||
begin
|
||||
if ActivePictureEdit.Tool <> ptText then
|
||||
TextEditor.StopEdit;
|
||||
end;
|
||||
|
||||
procedure TMainForm.ToolBrushClick(Sender: TObject);
|
||||
begin
|
||||
if not Pictures.CanEdit then
|
||||
@ -470,6 +487,14 @@ begin
|
||||
ChangeTool(ptBrush);
|
||||
end;
|
||||
|
||||
procedure TMainForm.ToolTextClick(Sender: TObject);
|
||||
begin
|
||||
if not Pictures.CanEdit then
|
||||
Exit;
|
||||
ChangeTool(ptText);
|
||||
ActivePictureEdit.TextEditor := TextEditor;
|
||||
end;
|
||||
|
||||
procedure TMainForm.ZoomInBtnClick(Sender: TObject);
|
||||
var
|
||||
V, E: integer;
|
||||
@ -814,6 +839,7 @@ procedure TMainForm.ChangeTool(Tool: TPictureEditTool);
|
||||
begin
|
||||
ActivePictureEdit.Tool := Tool;
|
||||
UpdateToolSettings;
|
||||
ToolBarToolsClick(nil);
|
||||
end;
|
||||
|
||||
procedure TMainForm.UpdatePictureToolsEnabled;
|
||||
@ -1046,6 +1072,10 @@ begin
|
||||
OpenPictureDialog.Title := lieOpenPictureDialog;
|
||||
SavePictureDialog.Title := lieSavePictureDialog;
|
||||
ExportResourceDialog.Title := lieExportResourceDialog;
|
||||
TextEditor := TTextEditor.Create(Self);
|
||||
TextEditor.Parent := Self;
|
||||
FontListBox.Items := Screen.Fonts;
|
||||
FontListBox.ItemIndex := FontListBox.Items.IndexOf(UTF8Encode(Screen.MenuFont.Name));
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormShow(Sender: TObject);
|
||||
@ -1160,6 +1190,23 @@ begin
|
||||
ActivePictureEdit.FlipVertically;
|
||||
end;
|
||||
|
||||
procedure TMainForm.FontListBoxChange(Sender: TObject);
|
||||
begin
|
||||
ActivePictureEdit.Canvas.Font.Name := FontListBox.Text;
|
||||
if ActivePictureEdit.Tool <> ptText then
|
||||
TextEditor.StopEdit;
|
||||
end;
|
||||
|
||||
procedure TMainForm.FontListBoxClick(Sender: TObject);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure TMainForm.FontSizeChange(Sender: TObject);
|
||||
begin
|
||||
ActivePictureEdit.Canvas.Font.Size := FontSize.Value;
|
||||
end;
|
||||
|
||||
procedure TMainForm.FormCloseQuery(Sender: TObject; var CanClose: boolean);
|
||||
begin
|
||||
Pictures.CloseAll;
|
||||
|
@ -31,7 +31,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLType, LCLIntf, Controls, Forms, ExtCtrls, Graphics, Math,
|
||||
BmpRGBGraph, BmpRGBUtils, BmpRGBTypes;
|
||||
BmpRGBGraph, BmpRGBUtils, BmpRGBTypes, DLBitmap;
|
||||
|
||||
type
|
||||
TPictureViewOption = (poShowGrid, poShowMask);
|
||||
@ -72,7 +72,7 @@ type
|
||||
procedure UpdatePictureRect;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
|
||||
destructor Destroy; override;
|
||||
procedure Paint; override;
|
||||
procedure Resize; override;
|
||||
procedure EraseBackground(DC: HDC); override;
|
||||
@ -111,7 +111,7 @@ type
|
||||
tdRoundRectangle, tdPolygon);
|
||||
|
||||
TPictureEditTool = (ptLine, ptPen, ptRectangle, ptFloodFill, ptEllipse,
|
||||
ptMask, ptColorPick, ptEraser, ptSpray, ptPolygon, ptBrush);
|
||||
ptMask, ptColorPick, ptEraser, ptSpray, ptPolygon, ptBrush, ptText);
|
||||
|
||||
TPicturePos = (ppTopLeft, ppTopCenter, ppTopRight, ppCenterLeft, ppCentered,
|
||||
ppCenterRight, ppBottomLeft, ppBottomCenter, ppBottomRight);
|
||||
@ -176,6 +176,7 @@ type
|
||||
procedure Rectangle(X1, Y1, X2, Y2: integer; Shift: TShiftState = [ssLeft]);
|
||||
procedure Ellipse(X1, Y1, X2, Y2: integer; Shift: TShiftState = [ssLeft]);
|
||||
procedure Polygon(X1, Y1, X2, Y2: integer; Shift: TShiftState);
|
||||
procedure ProcessEditorText(X1, Y1, X2, Y2: integer);
|
||||
procedure ProcessPointAddr(X1, Y1, X2, Y2: integer; Points: array of TPoint; PCount: integer);
|
||||
procedure Mask(X1, Y1, X2, Y2: integer; Shift: TShiftState = [ssLeft]);
|
||||
|
||||
@ -208,6 +209,7 @@ type
|
||||
procedure EndDraw;
|
||||
procedure UpdatePicture;
|
||||
public
|
||||
TextEditor: TTextEditor;
|
||||
property DrawMode: TDrawMode read FDrawMode write FDrawMode;
|
||||
property FillColor: TColor read FFillColor write SetFillColor;
|
||||
property OutlineColor: TColor read FOutlineColor write SetOutlineColor;
|
||||
@ -417,6 +419,11 @@ begin
|
||||
FScrollStop.Parent := Self;
|
||||
end;
|
||||
|
||||
destructor TCustomPictureView.Destroy;
|
||||
begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TCustomPictureView.Paint;
|
||||
var
|
||||
I: integer;
|
||||
@ -631,6 +638,7 @@ begin
|
||||
ptColorPick: ColorPick(X, Y, Shift);
|
||||
ptEraser: Eraser(X, Y, Shift);
|
||||
ptSpray: Spray(X, Y, Shift);
|
||||
ptText: ProcessEditorText(X, Y, X, Y);
|
||||
ptBrush: Brush(X, Y, Shift);
|
||||
end;
|
||||
|
||||
@ -1066,6 +1074,15 @@ begin
|
||||
InvalidatePictureRect(Rect(X1, Y1, X2, Y2));
|
||||
end;
|
||||
|
||||
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;
|
||||
|
||||
procedure TCustomPictureEdit.Mask(X1, Y1, X2, Y2: integer; Shift: TShiftState);
|
||||
begin
|
||||
if Picture = nil then
|
||||
|
Reference in New Issue
Block a user