Skip to content

Commit

Permalink
Merge pull request #134 from bgrabitmap/dev-lazpaint
Browse files Browse the repository at this point in the history
Dev lazpaint 7.0.9
  • Loading branch information
circular17 authored Apr 3, 2020
2 parents 74d9062 + 534a759 commit 8892e25
Show file tree
Hide file tree
Showing 88 changed files with 6,056 additions and 2,706 deletions.
1 change: 1 addition & 0 deletions lazpaint/dialog/filter/umotionblur.pas
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ procedure TFMotionBlur.FormCreate(Sender: TObject);
InPaintBoxMouseMove := false;
CheckOKCancelBtns(Button_OK{,Button_Cancel});
CheckFloatSpinEdit(SpinEdit_Distance);
SpinEdit_Distance.Constraints.MinWidth := DoScaleX(70, OriginalDPI);
end;

procedure TFMotionBlur.FormShow(Sender: TObject);
Expand Down
47 changes: 23 additions & 24 deletions lazpaint/dialog/filter/uradialblur.lfm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object FRadialBlur: TFRadialBlur
Left = 403
Height = 70
Height = 82
Top = 328
Width = 175
AutoSize = True
Expand All @@ -13,43 +13,42 @@ object FRadialBlur: TFRadialBlur
ChildSizing.VerticalSpacing = 8
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1
ClientHeight = 70
ClientHeight = 82
ClientWidth = 175
Font.Height = -12
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
OnShow = FormShow
Position = poOwnerFormCenter
LCLVersion = '1.6.0.4'
LCLVersion = '2.0.2.0'
object Panel1: TPanel
Left = 8
Height = 23
Height = 27
Top = 8
Width = 114
Width = 126
BevelOuter = bvNone
ChildSizing.HorizontalSpacing = 8
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 23
ClientWidth = 114
ClientHeight = 27
ClientWidth = 126
TabOrder = 0
object Label_Radius: TLabel
Left = 0
Height = 23
Height = 27
Top = 0
Width = 41
Width = 48
Caption = 'Radius :'
Layout = tlCenter
ParentColor = False
end
object SpinEdit_Radius: TFloatSpinEdit
Left = 49
Height = 23
Left = 56
Height = 27
Top = 0
Width = 65
Constraints.MinWidth = 65
Width = 70
Constraints.MinWidth = 70
DecimalPlaces = 1
Increment = 1
MaxValue = 1000
MinValue = 0.1
OnChange = SpinEdit_RadiusChange
Expand All @@ -59,32 +58,32 @@ object FRadialBlur: TFRadialBlur
end
object Panel2: TPanel
Left = 8
Height = 25
Top = 39
Width = 114
Height = 29
Top = 43
Width = 126
BevelOuter = bvNone
ChildSizing.HorizontalSpacing = 8
ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 2
ClientHeight = 25
ClientWidth = 114
ClientHeight = 29
ClientWidth = 126
TabOrder = 1
object Button_OK: TButton
Left = 0
Height = 25
Height = 29
Top = 0
Width = 42
Width = 31
AutoSize = True
Caption = 'OK'
Default = True
OnClick = Button_OKClick
TabOrder = 0
end
object Button_Cancel: TButton
Left = 50
Height = 25
Left = 39
Height = 29
Top = 0
Width = 62
Width = 54
AutoSize = True
Cancel = True
Caption = 'Cancel'
Expand Down
1 change: 1 addition & 0 deletions lazpaint/dialog/filter/uradialblur.pas
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ procedure TFRadialBlur.FormCreate(Sender: TObject);
blurType := rbNormal;
CheckOKCancelBtns(Button_OK{,Button_Cancel});
CheckFloatSpinEdit(SpinEdit_Radius);
SpinEdit_Radius.Constraints.MinWidth := DoScaleX(70, OriginalDPI);
end;

procedure TFRadialBlur.FormShow(Sender: TObject);
Expand Down
39 changes: 29 additions & 10 deletions lazpaint/dialog/ubrowseimages.pas
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ TFBrowseImages = class(TForm)
function GetInitialFilename: string;
function GetOpenLayerIcon: boolean;
function GetRememberStartDirectory: boolean;
procedure SetDefaultExtensions(AValue: string);
procedure SetFileExtensionFilter(AValue: string);
procedure SetFilterIndex(AValue: integer);
procedure SetInitialFilename(AValue: string);
Expand Down Expand Up @@ -134,6 +135,7 @@ TFBrowseImages = class(TForm)
procedure SetShellMask;
procedure DeleteSelectedFiles;
procedure SelectFile(AName: string);
procedure SelectDefaultExtensions;
procedure PreviewValidate({%H-}ASender: TObject);
property CurrentFullname: string read GetCurrentFullname;
property CurrentDirectory: string read GetCurrentDirectory write SetCurrentDirectory;
Expand All @@ -151,7 +153,7 @@ TFBrowseImages = class(TForm)
property IsSaveDialog: boolean read FIsSaveDialog write SetIsSaveDialog;
property OverwritePrompt: boolean read FOverwritePrompt write FOverwritePrompt;
property DefaultExtension: string read FDefaultExtension write FDefaultExtension;
property DefaultExtensions: string read FDefaultExtensions write FDefaultExtensions;
property DefaultExtensions: string read FDefaultExtensions write SetDefaultExtensions;
property InitialFilename: string read GetInitialFilename write SetInitialFilename;
property CurrentExtensionFilter: string read GetCurrentExtensionFilter;
property Filter: string read FFileExtensionFilter write SetFileExtensionFilter;
Expand Down Expand Up @@ -427,15 +429,6 @@ procedure TFBrowseImages.FormShow(Sender: TObject);
FreeAndNil(FChosenImage.bmp);
UpdatePreview;
UpdateToolButtonOpen;
if (FDefaultExtensions<>'') and (ComboBox_FileExtension.ItemIndex = -1) then
begin
for i := 0 to high(FFileExtensions) do
if FFileExtensions[i] = FDefaultExtensions then
begin
ComboBox_FileExtension.ItemIndex := i;
break;
end;
end;
if IsSaveDialog then
begin
If not AdaptExtension then
Expand Down Expand Up @@ -761,6 +754,13 @@ function TFBrowseImages.GetRememberStartDirectory: boolean;
result := CheckBox_UseDirectoryOnStartup.Checked;
end;

procedure TFBrowseImages.SetDefaultExtensions(AValue: string);
begin
if FDefaultExtensions=AValue then Exit;
FDefaultExtensions:=AValue;
SelectDefaultExtensions;
end;

procedure TFBrowseImages.SetFileExtensionFilter(AValue: string);
begin
if FFileExtensionFilter=AValue then Exit;
Expand Down Expand Up @@ -1129,8 +1129,12 @@ procedure TFBrowseImages.InitComboExt;
ComboBox_FileExtension.Items.Add(parsedExt[i*2]);
end;
parsedExt.Free;

if ComboBox_FileExtension.Items.Count > 0 then
begin
ComboBox_FileExtension.ItemIndex := 0;
SelectDefaultExtensions;
end;
end;

procedure TFBrowseImages.SetShellMask;
Expand Down Expand Up @@ -1212,6 +1216,21 @@ procedure TFBrowseImages.SelectFile(AName: string);
end;
end;

procedure TFBrowseImages.SelectDefaultExtensions;
var
i: Integer;
begin
if FDefaultExtensions <> '' then
begin
for i := 0 to high(FFileExtensions) do
if FFileExtensions[i] = FDefaultExtensions then
begin
ComboBox_FileExtension.ItemIndex := i;
break;
end;
end;
end;

procedure TFBrowseImages.PreviewValidate(ASender: TObject);
begin
ValidateFileOrDir;
Expand Down
16 changes: 10 additions & 6 deletions lazpaint/dialog/uchoosecolorinterface.pas
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ function TChooseColorInterface.DrawTriangleCursor(dest: TBGRABitmap;
end;

procedure TChooseColorInterface.DoSelect(X, Y: integer);
var pix: TBGRAPixel;
var pix, newColor: TBGRAPixel;
newLight: Word;
begin
case FSelectZone of
Expand All @@ -518,10 +518,14 @@ procedure TChooseColorInterface.DoSelect(X, Y: integer);
pix := FColorCircle.bmpMaxlight.GetPixel(x-FColorCircle.Bounds.Left,y-FColorCircle.Bounds.top);
if pix.alpha <> 0 then
begin
FCurrentColor := BGRA(pix.Red,pix.Green,pix.Blue,FCurrentColor.Alpha);
ColorX := x-FColorCircle.Bounds.Left;
ColorY := y-FColorCircle.Bounds.top;
UpdateColorview(False, True, True);
newColor := BGRA(pix.Red,pix.Green,pix.Blue,FCurrentColor.Alpha);
if not FCurrentColor.EqualsExactly(newColor) then
begin
FCurrentColor := newColor;
ColorX := x-FColorCircle.Bounds.Left;
ColorY := y-FColorCircle.Bounds.top;
UpdateColorview(False, True, True);
end;
end;
end;
szLightScale:
Expand Down Expand Up @@ -980,7 +984,7 @@ procedure TChooseColorInterface.SetCurrentColor(value: TBGRAPixel; AFromEdit: bo
begin
newcolorlight := ColorLightOf(value);
newcurrentColor := ColorWithLight(value,$FFFF);
if (newcolorlight<>FColorLight) or (newcurrentcolor <> FCurrentColor) then
if (newcolorlight<>FColorLight) or not newcurrentcolor.EqualsExactly(FCurrentColor) then
begin
FColorLight := newcolorlight;
FCurrentColor := newcurrentcolor;
Expand Down
13 changes: 9 additions & 4 deletions lazpaint/image/uimage.pas
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ TLazPaintImage = class
FRenderedImage: TBGRABitmap;
FRenderedImageInvalidated: TRect;
FOnImageChanged, FOnImageSaving, FOnImageExport: TLazPaintImageObservable;
FOnImageRenderChanged: TNotifyEvent;
FUndoList: TComposedImageDifference;
FUndoPos: integer;
FRenderUpdateRectInPicCoord, FRenderUpdateRectInVSCoord: TRect;
Expand Down Expand Up @@ -160,7 +161,7 @@ TLazPaintImage = class
procedure LayerMayChangeCompletely(ALayer: TBGRABitmap);
procedure SelectionMaskMayChange(ARect: TRect);
procedure SelectionMaskMayChangeCompletely;
procedure RenderMayChange(ARect: TRect; APicCoords: boolean = false);
procedure RenderMayChange(ARect: TRect; APicCoords: boolean = false; ANotify: boolean = true);
procedure ResetRenderUpdateRect;

// selection mask
Expand Down Expand Up @@ -257,6 +258,7 @@ TLazPaintImage = class
property OnSelectedLayerIndexChanged: TOnCurrentLayerIndexChanged read FOnSelectedLayerIndexChanged write FOnSelectedLayerIndexChanged;
property OnStackChanged: TOnStackChanged read FOnStackChanged write FOnStackChanged;
property OnImageChanged: TLazPaintImageObservable read FOnImageChanged;
property OnImageRenderChanged: TNotifyEvent read FOnImageRenderChanged write FOnImageRenderChanged;
property OnImageSaving: TLazPaintImageObservable read FOnImageSaving;
property OnImageExport: TLazPaintImageObservable read FOnImageExport;
property OnActionProgress: TLayeredActionProgressEvent read FOnActionProgress write SetOnActionProgress;
Expand Down Expand Up @@ -1076,7 +1078,8 @@ procedure TLazPaintImage.OriginalChange(ASender: TObject;
r: TRect;
begin
r := FCurrentState.LayeredBitmap.RenderOriginalIfNecessary(AOriginal.Guid, FDraftOriginal);
ImageMayChange(r, false);
if r.IsEmpty then OnImageChanged.NotifyObservers
else ImageMayChange(r, false);
if Assigned(ADiff) then
begin
AddUndo(TVectorOriginalEmbeddedDifference.Create(CurrentState,AOriginal.Guid,ADiff,r));
Expand Down Expand Up @@ -1280,12 +1283,14 @@ procedure TLazPaintImage.SelectionMaskMayChangeCompletely;
OnImageChanged.NotifyObservers;
end;

procedure TLazPaintImage.RenderMayChange(ARect: TRect; APicCoords: boolean = false);
procedure TLazPaintImage.RenderMayChange(ARect: TRect; APicCoords: boolean; ANotify: boolean);
begin
if APicCoords then
FRenderUpdateRectInPicCoord := RectUnion(FRenderUpdateRectInPicCoord,ARect)
else
FRenderUpdateRectInVSCoord := RectUnion(FRenderUpdateRectInVSCoord,ARect);
FRenderUpdateRectInVSCoord := RectUnion(FRenderUpdateRectInVSCoord,ARect);
if ANotify and Assigned(OnImageRenderChanged) then
OnImageRenderChanged(self);
end;

procedure TLazPaintImage.LayerBlendMayChange(AIndex: integer);
Expand Down
42 changes: 32 additions & 10 deletions lazpaint/image/uimageaction.pas
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ implementation

uses Controls, Dialogs, UResourceStrings, UObject3D,
ULoadImage, UGraph, UClipboard, Types, BGRAGradientOriginal,
BGRATransform, ULoading, math, LCVectorClipboard, LCVectorOriginal,
BGRATransform, ULoading, math, LCVectorClipboard, LCVectorOriginal, LCVectorRectShapes,
BGRALayers, BGRAUTF8, UFileSystem;

{ TImageActions }
Expand Down Expand Up @@ -702,21 +702,43 @@ procedure TImageActions.FillBackground(AColor: TBGRAPixel);
var tempBmp: TBGRABitmap;
LayerAction: TLayerAction;
y: Integer;
orig: TVectorOriginal;
ab: TAffineBox;
backRect: TRectShape;
begin
if not Image.CheckNoAction then exit;
LayerAction := nil;
try
LayerAction := Image.CreateAction(True);
tempBmp := TBGRABitmap.Create(LayerAction.SelectedImageLayer.Width,1);
for y := 0 to LayerAction.SelectedImageLayer.Height-1 do
if Image.LayerOriginalClass[Image.CurrentLayerIndex] = TVectorOriginal then
begin
tempBmp.Fill(AColor);
tempBmp.PutImage(0,-y,LayerAction.SelectedImageLayer,dmDrawWithTransparency);
LayerAction.SelectedImageLayer.PutImage(0,y,tempBmp,dmSet);
Image.CurrentState.DiscardOriginalDiff := false;
try
orig := Image.LayerOriginal[Image.CurrentLayerIndex] as TVectorOriginal;
backRect := TRectShape.Create(nil);
ab := AffineMatrixInverse(Image.LayerOriginalMatrix[Image.CurrentLayerIndex]) *
TAffineBox.AffineBox(rectF(-0.5, -0.5, Image.Width-0.5, Image.Height-0.5));
backRect.Origin := ab.Center;
backRect.XAxis := backRect.Origin + (ab.TopRight - ab.TopLeft)*0.5;
backRect.YAxis := backRect.Origin + (ab.BottomLeft - ab.TopLeft)*0.5;
backRect.BackFill.SolidColor := AColor;
orig.InsertShape(backRect, 0);
finally
Image.CurrentState.DiscardOriginalDiff := true;
end;
end else
begin
LayerAction := Image.CreateAction(True);
tempBmp := TBGRABitmap.Create(LayerAction.SelectedImageLayer.Width,1);
for y := 0 to LayerAction.SelectedImageLayer.Height-1 do
begin
tempBmp.Fill(AColor);
tempBmp.PutImage(0,-y,LayerAction.SelectedImageLayer,dmDrawWithTransparency);
LayerAction.SelectedImageLayer.PutImage(0,y,tempBmp,dmSet);
end;
tempBmp.Free;
image.LayerMayChangeCompletely(LayerAction.SelectedImageLayer);
LayerAction.Validate;
end;
tempBmp.Free;
image.LayerMayChangeCompletely(LayerAction.SelectedImageLayer);
LayerAction.Validate;
except
on ex:Exception do
FInstance.ShowError('FillBackground',ex.Message);
Expand Down
Loading

0 comments on commit 8892e25

Please sign in to comment.