Skip to content

Commit

Permalink
Merge pull request #522 from bgrabitmap/dev-lazpaint
Browse files Browse the repository at this point in the history
Dev lazpaint v7.2.1
  • Loading branch information
circular17 authored Aug 21, 2022
2 parents dcc4a67 + b6567bc commit 4db0e86
Show file tree
Hide file tree
Showing 32 changed files with 683 additions and 373 deletions.
25 changes: 13 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
*.bak
*.dbg
lazpaint/release/bin/*.exe
*.lps
backup/*
lib
debug
__pycache__
.DS_Store
*.res
*.lrt
lazpaint/backup/
vectoredit/vectoredit
vectoredit/backup/
lazpaint/dialog/backup/
lazpaint/dialog/color/backup
lazpaint/dialog/filter/backup/
lazpaint/image/backup/
lazpaint/test_embedded/backup/
lazpaint/test_embedded/project1
lazpaint/dialog/filter/backup/
lazpaint/release/bin/lazpaint
lazpaint/tablet/backup/
lazpaint/tools/backup/
lazpaint/image/backup/
lazpaint/dialog/backup/
.DS_Store
lazpaint/units/
lazpaint/release/bin/*.exe
lazpaint/release/bin/lazpaint.app
lazpaint/release/macOS/*.dmg
lazpaint/release/windows/lazpaint32
lazpaint/release/windows/lazpaint64
lazpaint/release/bin/i18n/lazpaint32.*
lazpaint/release/bin/i18n/lazpaint_x64.*
/lazpaint/dialog/color/backup
resources/createresource/backup/
lazpaint/units/
vectoredit/vectoredit
vectoredit/backup/
/bgracontrols
/bgrabitmap

*.deb
lazpaint/release/debian/lazpaint*_no_install.tar.gz
lazpaint/release/windows/lazpaint*_no_install.zip
/web/public/*

lazpaint/tablet/backup/
lazpaint/release/bin/i18n/lazpaint64.pot
lazpaint/release/windows/libavif/
2 changes: 1 addition & 1 deletion lazpaint.logic
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ bundle release/macOS/LazPaint.app
copy ../resources/icon/lazpaint.icns release/macOS/LazPaint.app/Contents/Resources/lazpaint.icns
text ../web/config.toml " version = ""$(Version)"""
echo ">> DON'T FORGET TO UPDATE WEBSITE"
echo ">> DON'T FORGET TO ADD VERSION IN release/debian/changelog <<"
echo ">> DON'T FORGET TO ADD VERSION IN lazpaint/release/debian/debian/changelog <<"
4 changes: 2 additions & 2 deletions lazpaint/dialog/uabout.pas
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ TFAbout = class(TForm)
{ public declarations }
end;

procedure ShowAboutDlg(AInstance: TLazPaintCustomInstance; {%H-}AText: string);
procedure ShowAboutDlg(AInstance: TLazPaintCustomInstance);

implementation

uses LCLIntf, BGRABitmap, BGRABitmapTypes;

procedure ShowAboutDlg(AInstance: TLazPaintCustomInstance; {%H-}AText: string);
procedure ShowAboutDlg(AInstance: TLazPaintCustomInstance);
var
About: TFAbout;
begin
Expand Down
30 changes: 28 additions & 2 deletions lazpaint/image/uimageaction.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface
uses
Classes, SysUtils, FPimage, LazPaintType, BGRABitmap, UImage, UTool,
UScripting, ULayerAction, UImageType, BGRABitmapTypes, BGRALayerOriginal,
BGRASVGOriginal;
BGRASVGOriginal, BGRALayers;

type

Expand Down Expand Up @@ -59,9 +59,11 @@ TImageActions = class
function DoEnd: boolean;
procedure SetCurrentBitmap(bmp: TBGRABitmap; AUndoable: boolean;
ACaption: string = ''; AOpacity: byte = 255);
procedure SetCurrentBitmap(bmp: TBGRACustomLayeredBitmap; AUndoable: boolean);
procedure CropToSelectionAndLayer;
procedure CropToSelection;
procedure Flatten;
procedure TakeScreenshot(ARect: TRect);
procedure HorizontalFlip(AOption: TFlipOption);
procedure VerticalFlip(AOption: TFlipOption);
procedure RotateCW;
Expand Down Expand Up @@ -109,7 +111,7 @@ implementation
uses Controls, Dialogs, UResourceStrings, UObject3D,
ULoadImage, UGraph, UClipboard, Types, BGRAGradientOriginal,
BGRATransform, ULoading, math, LCVectorClipboard, LCVectorOriginal, LCVectorRectShapes,
BGRALayers, BGRAUTF8, UFileSystem, Forms, UTranslation;
BGRAUTF8, UFileSystem, Forms, UTranslation;

{ TImageActions }

Expand Down Expand Up @@ -1113,6 +1115,19 @@ procedure TImageActions.Flatten;
image.Flatten;
end;

procedure TImageActions.TakeScreenshot(ARect: TRect);
var
bmp: TBGRABitmap;
begin
bmp := TBGRABitmap.Create;
try
bmp.TakeScreenshot(ARect);
SetCurrentBitmap(bmp, false, 'Screenshot');
except on ex:Exception do
FInstance.ShowError('TakeScreenshot',ex.Message);
end;
end;

procedure TImageActions.SetCurrentBitmap(bmp: TBGRABitmap; AUndoable : boolean;
ACaption: string; AOpacity: byte);
begin
Expand All @@ -1124,6 +1139,17 @@ procedure TImageActions.SetCurrentBitmap(bmp: TBGRABitmap; AUndoable : boolean;
end;
end;

procedure TImageActions.SetCurrentBitmap(bmp: TBGRACustomLayeredBitmap;
AUndoable: boolean);
begin
ToolManager.ToolCloseDontReopen;
try
image.Assign(bmp,True,AUndoable);
finally
ToolManager.ToolOpen;
end;
end;

function TImageActions.TryAddLayerFromFile(AFilenameUTF8: string; ALoadedImage: TBGRABitmap = nil): ArrayOfLayerId;

function ComputeStretchMatrix(ASourceWidth, ASourceHeight: single): TAffineMatrix;
Expand Down
5 changes: 3 additions & 2 deletions lazpaint/lazpaint.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<MinorVersionNr Value="2"/>
<CharSet Value="04B0"/>
<StringTable CompanyName="http://sourceforge.net/projects/lazpaint/" FileDescription="LazPaint" InternalName="lazpaint" OriginalFilename="lazpaint.exe" ProductName="LazPaint"/>
<RevisionNr Value="1"/>
</VersionInfo>
<BuildModes Count="10">
<Item1 Name="Debug" Default="True"/>
Expand Down Expand Up @@ -412,15 +413,15 @@
<RequiredPackages Count="5">
<Item1>
<PackageName Value="BGRABitmapPack"/>
<MinVersion Major="11" Minor="5" Valid="True"/>
<MinVersion Major="11" Minor="5" Release="2" Valid="True"/>
</Item1>
<Item2>
<PackageName Value="bgracontrols"/>
<MinVersion Major="7" Minor="5" Valid="True"/>
</Item2>
<Item3>
<PackageName Value="lazpaintcontrols"/>
<MinVersion Minor="2" Valid="True"/>
<MinVersion Minor="2" Release="1" Valid="True"/>
</Item3>
<Item4>
<PackageName Value="Printer4Lazarus"/>
Expand Down
6 changes: 0 additions & 6 deletions lazpaint/lazpaint.lpr
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,6 @@ procedure TMyLazPaintInstance.ApplicationException(Sender: TObject; E: Exception
LazpaintApplication.UseConfig(ActualConfig);
FillLanguageList(LazpaintApplication.Config);

{$IFDEF WINDOWS}
LazpaintApplication.AboutText := ReadFileToString(SysToUTF8(ExtractFilePath(Application.ExeName))+'readme.txt');
{$ELSE}
LazpaintApplication.AboutText := ReadFileToString('readme.txt');
{$ENDIF}

if not LazpaintApplication.ProcessCommandLine then
begin
LazpaintApplication.Show;
Expand Down
2 changes: 1 addition & 1 deletion lazpaint/lazpaintembeddedpack.lpk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</Debugging>
</Linking>
</CompilerOptions>
<Version Major="7" Minor="2"/>
<Version Major="7" Minor="2" Release="1"/>
<Files Count="94">
<Item1>
<Filename Value="lazpaintinstance.pas"/>
Expand Down
87 changes: 77 additions & 10 deletions lazpaint/lazpaintinstance.pas
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,20 @@ TLazPaintInstance = class(TLazPaintCustomInstance)
procedure RestoreMainWindowPosition; override;
procedure UseConfig(ini: TInifile); override;
procedure AssignBitmap(bmp: TBGRABitmap); override;
procedure EditBitmap(var bmp: TBGRABitmap; ConfigStream: TStream = nil; ATitle: String = ''; AOnRun: TLazPaintInstanceEvent = nil; AOnExit: TLazPaintInstanceEvent = nil; ABlackAndWhite: boolean = false); override;
procedure AssignBitmap(bmp: TBGRALayeredBitmap); override;
function InternalEditBitmap(var bmp: TObject; ConfigStream: TStream = nil;
ATitle: String = ''; AOnRun: TLazPaintInstanceEvent = nil;
AOnExit: TLazPaintInstanceEvent = nil;
ABlackAndWhite: boolean = false): boolean;
function EditBitmap(var bmp: TBGRABitmap; ConfigStream: TStream = nil;
ATitle: String = ''; AOnRun: TLazPaintInstanceEvent = nil;
AOnExit: TLazPaintInstanceEvent = nil;
ABlackAndWhite: boolean = false): boolean; override;
function EditBitmap(var bmp: TBGRALayeredBitmap;
ConfigStream: TStream = nil; ATitle: String = '';
AOnRun: TLazPaintInstanceEvent = nil;
AOnExit: TLazPaintInstanceEvent = nil;
ABlackAndWhite : boolean = false): boolean; override;
procedure EditSelection; override;
function EditTexture(ASource: TBGRABitmap): TBGRABitmap; override;
function ProcessCommandLine: boolean; override;
Expand Down Expand Up @@ -518,6 +531,7 @@ procedure TLazPaintInstance.FormsNeeded;
procedure TLazPaintInstance.UseConfig(ini: TInifile);
begin
FreeAndNil(FConfig);
BlackAndWhite := ini.ReadBool('General','BlackAndWhite',BlackAndWhite);
FConfig := TLazPaintConfig.Create(ini,LazPaintVersionStr);
ToolManager.LoadFromConfig;
FGridVisible := Config.DefaultGridVisible;
Expand Down Expand Up @@ -1228,16 +1242,25 @@ procedure TLazPaintInstance.SetChooseColorWidth(AValue: integer);
procedure TLazPaintInstance.AssignBitmap(bmp: TBGRABitmap);
begin
if Assigned(FImageAction) then
FImageAction.SetCurrentBitmap(bmp.Duplicate as TBGRABitmap, False);
FImageAction.SetCurrentBitmap(bmp.Duplicate, False);
end;

procedure TLazPaintInstance.EditBitmap(var bmp: TBGRABitmap; ConfigStream: TStream; ATitle: String; AOnRun: TLazPaintInstanceEvent; AOnExit: TLazPaintInstanceEvent; ABlackAndWhite: boolean);
procedure TLazPaintInstance.AssignBitmap(bmp: TBGRALayeredBitmap);
begin
if Assigned(FImageAction) then
FImageAction.SetCurrentBitmap(bmp.Duplicate, False);
end;

function TLazPaintInstance.InternalEditBitmap(var bmp: TObject;
ConfigStream: TStream; ATitle: String; AOnRun: TLazPaintInstanceEvent;
AOnExit: TLazPaintInstanceEvent; ABlackAndWhite: boolean): boolean;
var
subLaz: TLazPaintInstance;
ini : TIniFile;
topmostInfo: TTopMostInfo;

embeddedImageToBeFreed: boolean;
begin
result := false;
try
subLaz := TLazPaintInstance.Create(True);
except
Expand All @@ -1251,6 +1274,7 @@ procedure TLazPaintInstance.EditBitmap(var bmp: TBGRABitmap; ConfigStream: TStre
if ATitle <> '' then subLaz.Title := ATitle;
if FMain <> nil then FMain.Enabled := false;
topmostInfo:= HideTopmost;
embeddedImageToBeFreed := false;
try
if ConfigStream <> nil then
begin
Expand All @@ -1260,9 +1284,20 @@ procedure TLazPaintInstance.EditBitmap(var bmp: TBGRABitmap; ConfigStream: TStre
subLaz.UseConfig(ini);
end;
subLaz.FormsNeeded;
if bmp <> nil then subLaz.AssignBitmap(bmp);
subLaz.AboutText := AboutText;
subLaz.EmbeddedImageBackup := bmp;
if bmp <> nil then
begin
if bmp is TBGRABitmap then
begin
subLaz.AssignBitmap(TBGRABitmap(bmp));
subLaz.EmbeddedImageBackup := TBGRABitmap(bmp);
end else
if bmp is TBGRALayeredBitmap then
begin
subLaz.AssignBitmap(TBGRALayeredBitmap(bmp));
subLaz.EmbeddedImageBackup := TBGRALayeredBitmap(bmp).ComputeFlatImage;
embeddedImageToBeFreed := true;
end;
end;
subLaz.FMain.BorderIcons := subLaz.FMain.BorderIcons - [biMinimize];
if AOnRun <> nil then
AOnRun(subLaz);
Expand All @@ -1271,8 +1306,17 @@ procedure TLazPaintInstance.EditBitmap(var bmp: TBGRABitmap; ConfigStream: TStre
AOnExit(subLaz);
if subLaz.EmbeddedResult = mrOk then
begin
FreeAndNil(bmp);
bmp := subLaz.Image.RenderedImage.Duplicate as TBGRABitmap;
if bmp is TBGRALayeredBitmap then
begin
FreeAndNil(bmp);
bmp := subLaz.Image.CurrentState.GetLayeredBitmapCopy;
end
else if bmp is TBGRABitmap then
begin
FreeAndNil(bmp);
bmp := subLaz.Image.RenderedImage.Duplicate;
end;
result := true;
end;
if ConfigStream <> nil then
begin
Expand All @@ -1289,9 +1333,32 @@ procedure TLazPaintInstance.EditBitmap(var bmp: TBGRABitmap; ConfigStream: TStre
FMain.Enabled := true;
FMain.BringToFront;
end;
if embeddedImageToBeFreed then
subLaz.EmbeddedImageBackup.Free
else subLaz.EmbeddedImageBackup := nil;
subLaz.Free;
end;

function TLazPaintInstance.EditBitmap(var bmp: TBGRABitmap;
ConfigStream: TStream; ATitle: String; AOnRun: TLazPaintInstanceEvent;
AOnExit: TLazPaintInstanceEvent; ABlackAndWhite: boolean): boolean;
var bmpObj: TObject;
begin
bmpObj := bmp;
result := InternalEditBitmap(bmpObj, ConfigStream, ATitle, AOnRun, AOnExit, ABlackAndWhite);
bmp := bmpObj as TBGRABitmap;
end;

function TLazPaintInstance.EditBitmap(var bmp: TBGRALayeredBitmap;
ConfigStream: TStream; ATitle: String; AOnRun: TLazPaintInstanceEvent;
AOnExit: TLazPaintInstanceEvent; ABlackAndWhite: boolean): boolean;
var bmpObj: TObject;
begin
bmpObj := bmp;
result := InternalEditBitmap(bmpObj, ConfigStream, ATitle, AOnRun, AOnExit, ABlackAndWhite);
bmp := bmpObj as TBGRALayeredBitmap;
end;

procedure TLazPaintInstance.EditSelection;
begin
try
Expand Down Expand Up @@ -1969,7 +2036,7 @@ procedure TLazPaintInstance.ShowAboutDlg;
var tmi: TTopMostInfo;
begin
tmi := HideTopmost;
uabout.ShowAboutDlg(self,AboutText);
uabout.ShowAboutDlg(self);
ShowTopmost(tmi);
end;

Expand Down
1 change: 1 addition & 0 deletions lazpaint/lazpaintmainform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,7 @@ procedure TFMain.Init;

{$IFDEF DARWIN}
ImageHorizontalFlip.ShortCut := ShortCut(VK_H, [ssMeta, ssCtrl]);
FileQuickSave.ShortCut:= ShortCut(VK_Q, [ssMeta, ssAlt]);
{$ENDIF}

if not LazPaintInstance.Embedded then
Expand Down
17 changes: 13 additions & 4 deletions lazpaint/lazpainttype.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface
{$IFDEF LINUX}, InterfaceBase{$ENDIF};

const
LazPaintVersion = 7020000;
LazPaintVersion = 7020100;

function LazPaintVersionStr: string;

Expand Down Expand Up @@ -218,7 +218,7 @@ TLazPaintCustomInstance = class(TInterfacedObject,IConfigProvider)

function GetMainFormBounds: TRect; virtual; abstract;
public
Title,AboutText: string;
Title: string;
EmbeddedResult: TModalResult;
EmbeddedImageBackup: TBGRABitmap;

Expand All @@ -235,8 +235,17 @@ TLazPaintCustomInstance = class(TInterfacedObject,IConfigProvider)
procedure RestoreMainWindowPosition; virtual; abstract;
procedure Donate; virtual; abstract;
procedure UseConfig(ini: TInifile); virtual; abstract;
procedure AssignBitmap(bmp: TBGRABitmap); virtual; abstract;
procedure EditBitmap(var bmp: TBGRABitmap; ConfigStream: TStream = nil; ATitle: String = ''; AOnRun: TLazPaintInstanceEvent = nil; AOnExit: TLazPaintInstanceEvent = nil; ABlackAndWhite : boolean = false); virtual; abstract;
procedure AssignBitmap(bmp: TBGRABitmap); virtual; abstract; overload;
procedure AssignBitmap(bmp: TBGRALayeredBitmap); virtual; abstract; overload;
function EditBitmap(var bmp: TBGRABitmap; ConfigStream: TStream = nil;
ATitle: String = ''; AOnRun: TLazPaintInstanceEvent = nil;
AOnExit: TLazPaintInstanceEvent = nil;
ABlackAndWhite : boolean = false): boolean; virtual; abstract;
function EditBitmap(var bmp: TBGRALayeredBitmap;
ConfigStream: TStream = nil; ATitle: String = '';
AOnRun: TLazPaintInstanceEvent = nil;
AOnExit: TLazPaintInstanceEvent = nil;
ABlackAndWhite : boolean = false): boolean; virtual; abstract;
function EditTexture(ASource: TBGRABitmap): TBGRABitmap; virtual; abstract;
procedure EditSelection; virtual; abstract;
function ProcessCommandLine: boolean; virtual; abstract;
Expand Down
Loading

0 comments on commit 4db0e86

Please sign in to comment.