Sfoglia il codice sorgente

Merge pull request #137 from bgrabitmap/dev-lazpaint

Dev lazpaint 7.1
circular17 5 anni fa
parent
commit
2feccdfa47

+ 0 - 1
lazpaint/dialog/ublendop.pas

@@ -82,7 +82,6 @@ var lColor: TBGRAPixel;
   idx: integer;
   fullPatternName, attr: string;
   i: integer;
-  ratio: single;
 begin
   fullPatternName:= APattern;
   for i := 0 to high(FPatterns) do

+ 1 - 0
lazpaint/dialog/ubrowseimages.pas

@@ -830,6 +830,7 @@ begin
       ShellListView1.Reload
     else
       ShellListView1.Root := newDir;
+    SetShellMask;
     StartThumbnails;
     if AFocus then ShellListView1.SetFocus;
     if ShellListView1.ItemCount <> 0 then

+ 4 - 2
lazpaint/dialog/ucanvassize.pas

@@ -127,7 +127,7 @@ begin
    end;
 end;
 
-function ChangeLayeredImageCanvasSize(layeredBmp: TLazPaintImage; newWidth,
+function ChangeLayeredImageCanvasSize(AInstance: TLazPaintCustomInstance; layeredBmp: TLazPaintImage; newWidth,
   newHeight: integer; anchor: string; background: TBGRAPixel;
   repeatImage: boolean; flipMode: boolean): TBGRALayeredBitmap;
 var i,idx: integer;
@@ -138,6 +138,7 @@ begin
   result := TBGRALayeredBitmap.Create;
   for i := 0 to layeredbmp.NbLayers-1 do
   begin
+    AInstance.ReportActionProgress(i*100 div layeredbmp.NbLayers);
     newBmp := ChangeCanvasSize(layeredbmp.LayerBitmap[i],layeredbmp.LayerOffset[i],layeredBmp.Width,layeredBmp.Height, newwidth,newHeight,anchor,background,repeatImage,flipMode);
     idx := result.AddOwnedLayer(newBmp,layeredBmp.BlendOperation[i],layeredbmp.LayerOpacity[i]);
     result.LayerName[idx] := layeredbmp.LayerName[i];
@@ -155,12 +156,13 @@ begin
       end;
     end;
   end;
+  AInstance.ReportActionProgress(100);
 end;
 
 function ComputeNewCanvasSize(AInstance: TLazPaintCustomInstance; AWidth,AHeight: integer;
   AAnchor: string; ARepeatImage, AFlipMode: boolean): TLayeredBitmapAndSelection;
 begin
-  result.layeredBitmap := ChangeLayeredImageCanvasSize(AInstance.Image,
+  result.layeredBitmap := ChangeLayeredImageCanvasSize(AInstance, AInstance.Image,
      AWidth,AHeight,AAnchor,BGRAPixelTransparent, ARepeatImage, AFlipMode);
   if AInstance.Image.SelectionMaskReadonly <> nil then
     result.selection := ChangeCanvasSize(AInstance.Image.SelectionMaskReadonly,

+ 9 - 1
lazpaint/dialog/uchoosecolorinterface.pas

@@ -503,6 +503,7 @@ end;
 procedure TChooseColorInterface.DoSelect(X, Y: integer);
 var pix, newColor: TBGRAPixel;
   newLight: Word;
+  dist: single;
 begin
   case FSelectZone of
   szAlphascale:
@@ -513,8 +514,15 @@ begin
       UpdateColorview(False, False, True);
     end;
   szColorCircle:
-    if PtInRect(point(x,y), FColorCircle.Bounds) and Assigned(FColorCircle.bmpMaxlight) then
+    if Assigned(FColorCircle.bmpMaxlight) then
     begin
+      dist := sqrt(sqr((x-FColorCircle.center.X)/FColorCircle.bounds.Width*2) +
+              sqr((y-FColorCircle.center.Y)/FColorCircle.bounds.Height*2));
+      if dist > 1 then
+      begin
+        x := round(FColorCircle.center.X + (x-FColorCircle.center.X)/dist);
+        y := round(FColorCircle.center.Y + (y-FColorCircle.center.Y)/dist);
+      end;
       pix := FColorCircle.bmpMaxlight.GetPixel(x-FColorCircle.Bounds.Left,y-FColorCircle.Bounds.top);
       if pix.alpha <> 0 then
       begin

+ 0 - 2
lazpaint/dialog/usaveoption.pas

@@ -427,7 +427,6 @@ procedure TFSaveOption.Button_OKClick(Sender: TObject);
   var inputStream,outputStream: TStream;
     icoCur: TBGRAIconCursor;
     picture: TBGRACustomBitmap;
-    bpp: integer;
   begin
     icoCur := TBGRAIconCursor.Create;
     if FileManager.FileExists(FOutputFilename) then
@@ -443,7 +442,6 @@ procedure TFSaveOption.Button_OKClick(Sender: TObject);
       icoCur.FileType:= ImageFormat;
     end;
     try
-      bpp := WantedBitsPerPixel;
       if PngStreamNeeded then
       begin
         MakePngStreamIfNeeded;

+ 7 - 2
lazpaint/image/uimage.pas

@@ -37,6 +37,7 @@ type
 
   TLazPaintImage = class
   private
+    FLazPaintInstance: TObject;
     FActionInProgress: TCustomLayerAction;
     FOnActionProgress: TLayeredActionProgressEvent;
     FOnSelectedLayerIndexChanging: TOnCurrentLayerIndexChanged;
@@ -295,7 +296,7 @@ type
     property IsTiff: boolean read GetIsTiff;
     property IsGif: boolean read GetIsGif;
     property DPI: integer read GetDPI;
-    constructor Create;
+    constructor Create(ALazPaintInstance: TObject);
     destructor Destroy; override;
   end;
 
@@ -713,7 +714,10 @@ begin
             layeredBmp.Free;
             layeredBmp := temp;
           end;
+          MessagePopupForever(rsResamplingImage);
+          (FLazPaintInstance as TLazPaintCustomInstance).UpdateWindows;
           (layeredBmp as TBGRALayeredBitmap).Resample(cx, cy, rmFineResample);
+          MessagePopupHide;
         end;
       CursorHotSpot := Point(0,0);
       if layeredBmp is TBGRALazPaintImage then
@@ -2326,8 +2330,9 @@ begin
   exit(-1);
 end;
 
-constructor TLazPaintImage.Create;
+constructor TLazPaintImage.Create(ALazPaintInstance: TObject);
 begin
+  FLazPaintInstance := ALazPaintInstance;
   FCurrentState := TImageState.Create;
   FCurrentState.OnOriginalChange:= @OriginalChange;
   FCurrentState.OnOriginalEditingChange:= @OriginalEditingChange;

+ 1 - 1
lazpaint/lazpaint.lpi

@@ -23,7 +23,7 @@
     <VersionInfo>
       <UseVersionInfo Value="True"/>
       <MajorVersionNr Value="7"/>
-      <RevisionNr Value="9"/>
+      <MinorVersionNr Value="1"/>
       <CharSet Value="04B0"/>
       <StringTable CompanyName="http://sourceforge.net/projects/lazpaint/" ProductName="LazPaint" InternalName="lazpaint" OriginalFilename="lazpaint.exe"/>
     </VersionInfo>

+ 1 - 1
lazpaint/lazpaintembeddedpack.lpk

@@ -26,7 +26,7 @@
         </Debugging>
       </Linking>
     </CompilerOptions>
-    <Version Major="7" Release="9"/>
+    <Version Major="7" Minor="1"/>
     <Files Count="94">
       <Item1>
         <Filename Value="lazpaintinstance.pas"/>

+ 17 - 19
lazpaint/lazpaintinstance.pas

@@ -181,6 +181,7 @@ type
     procedure EndLoadingImage; override;
     procedure StartSavingImage(AFilename: string); override;
     procedure EndSavingImage; override;
+    procedure ReportActionProgress(AProgressPercent: integer); override;
     procedure Donate; override;
     procedure SaveMainWindowPosition; override;
     procedure RestoreMainWindowPosition; override;
@@ -313,6 +314,20 @@ begin
   UpdateWindows;
 end;
 
+procedure TLazPaintInstance.ReportActionProgress(AProgressPercent: integer);
+var
+  delay: Integer;
+begin
+  if AProgressPercent < 100 then delay := 10000 else delay := 1000;
+  if Assigned(FMain) then FMain.UpdatingPopup:= true;
+  try
+    MessagePopup(rsActionInProgress+'... '+inttostr(AProgressPercent)+'%', delay);
+    UpdateWindows;
+  finally
+    if Assigned(FMain) then FMain.UpdatingPopup:= false;
+  end;
+end;
+
 procedure TLazPaintInstance.Donate;
 begin
   OpenURL('http://sourceforge.net/donate/index.php?group_id=404555');
@@ -418,7 +433,7 @@ begin
   RegisterScripts(True);
 
   InColorFromFChooseColor := false;
-  FImage := TLazPaintImage.Create;
+  FImage := TLazPaintImage.Create(self);
   FImage.OnStackChanged:= @OnStackChanged;
   FImage.OnException := @OnFunctionException;
   FImage.OnActionProgress:=@OnImageActionProgress;
@@ -663,17 +678,8 @@ end;
 
 procedure TLazPaintInstance.OnImageActionProgress(ASender: TObject;
   AProgressPercent: integer);
-var
-  delay: Integer;
 begin
-  if AProgressPercent < 100 then delay := 10000 else delay := 1000;
-  if Assigned(FMain) then FMain.UpdatingPopup:= true;
-  try
-    MessagePopup(rsActionInProgress+'... '+inttostr(AProgressPercent)+'%', delay);
-    UpdateWindows;
-  finally
-    if Assigned(FMain) then FMain.UpdatingPopup:= false;
-  end;
+  ReportActionProgress(AProgressPercent);
 end;
 
 function TLazPaintInstance.GetInitialized: boolean;
@@ -1521,7 +1527,6 @@ end;
 
 procedure TLazPaintInstance.UpdateWindows;
 begin
-  {$IFDEF LINUX}
   if Assigned(FMain) then FMain.Enabled:= false;
   if Assigned(FFormToolbox) then FFormToolbox.Enabled:= false;
   if Assigned(FChooseColor) then FChooseColor.Enabled:= false;
@@ -1533,13 +1538,6 @@ begin
   if Assigned(FChooseColor) then FChooseColor.Enabled:= true;
   if Assigned(FLayerStack) then FLayerStack.Enabled:= true;
   if Assigned(FImageList) then FImageList.Enabled:= true;
-  {$ELSE}
-  if Assigned(FMain) then FMain.Update;
-  if Assigned(FFormToolbox) then FFormToolbox.Update;
-  if Assigned(FChooseColor) then FChooseColor.Update;
-  if Assigned(FLayerStack) then FLayerStack.Update;
-  if Assigned(FImageList) then FImageList.Update;
-  {$ENDIF}
 end;
 
 procedure TLazPaintInstance.Wait(ACheckActive: TCheckFunction; ADelayMs: integer);

+ 12 - 2
lazpaint/lazpaintmainform.pas

@@ -811,7 +811,7 @@ type
     procedure HideFill(ATimeMs: Integer = 300; AClearTime: boolean = false);
     procedure OnPaintHandler;
     procedure OnImageChangedHandler({%H-}AEvent: TLazPaintImageObservationEvent);
-    procedure OnImageRenderChanged(sender: TObject);
+    procedure OnImageRenderChanged({%H-}Sender: TObject);
     procedure LabelAutosize(ALabel: TLabel);
     procedure AskMergeSelection(ACaption: string);
     procedure ReleaseMouseButtons(Shift: TShiftState);
@@ -2434,6 +2434,16 @@ begin
          ViewZoomOut.Execute;
          UTF8Key := '';
       end else
+      if toolProcessKey and (UTF8Key = '*') then
+      begin
+         ViewZoomOriginal.Execute;
+         UTF8Key := '';
+      end else
+      if toolProcessKey and (UTF8Key = '/') then
+      begin
+         ViewZoomFit.Execute;
+         UTF8Key := '';
+      end else
       begin
         selectedTool := ToolManager.GetCurrentToolType;
         FLayout.Menu.CycleTool(selectedTool, UTF8Key);
@@ -4400,7 +4410,7 @@ begin
   if AEvent.DelayedStackUpdate then FUpdateStackWhenIdle := true;
 end;
 
-procedure TFMain.OnImageRenderChanged(sender: TObject);
+procedure TFMain.OnImageRenderChanged(Sender: TObject);
 begin
   InvalidatePicture;
 end;

+ 2 - 1
lazpaint/lazpainttype.pas

@@ -10,7 +10,7 @@ uses
   {$IFDEF LINUX}, InterfaceBase{$ENDIF};
 
 const
-  LazPaintVersion = 7000900;
+  LazPaintVersion = 7010000;
 
   function LazPaintVersionStr: string;
 
@@ -221,6 +221,7 @@ type
     procedure EndLoadingImage; virtual; abstract;
     procedure StartSavingImage(AFilename: string); virtual; abstract;
     procedure EndSavingImage; virtual; abstract;
+    procedure ReportActionProgress(AProgressPercent: integer); virtual; abstract;
     procedure SaveMainWindowPosition; virtual; abstract;
     procedure RestoreMainWindowPosition; virtual; abstract;
     procedure Donate; virtual; abstract;

+ 13 - 0
lazpaint/release/changelog

@@ -173,3 +173,16 @@ lazpaint (7.0.9) unstable; urgency=low
 
 -- circular <[email protected]>  Fri, 3 Apr 2020 12:40:00 +0100
 
+lazpaint (7.1) stable; urgency=low
+
+  * tool: fix update of pen style from shape
+  * interface: fix file extension mask when opening image browser
+  * interface: fix selection of file after changing folder
+  * interface: show progress when changing canvas size
+  * interface: show popup when downsampling opened big image
+  * interface: fix update of popup on Windows
+  * interface: allow to select outside color circle of color window
+  * interface: added shortcuts / and * to shrink and use original zoom
+
+-- circular <[email protected]>  Fri, 10 Apr 2020 12:07:00 +0100
+

+ 13 - 0
lazpaint/release/debian/linux32/DEBIAN/changelog

@@ -173,3 +173,16 @@ lazpaint (7.0.9) unstable; urgency=low
 
 -- circular <[email protected]>  Fri, 3 Apr 2020 12:40:00 +0100
 
+lazpaint (7.1) stable; urgency=low
+
+  * tool: fix update of pen style from shape
+  * interface: fix file extension mask when opening image browser
+  * interface: fix selection of file after changing folder
+  * interface: show progress when changing canvas size
+  * interface: show popup when downsampling opened big image
+  * interface: fix update of popup on Windows
+  * interface: allow to select outside color circle of color window
+  * interface: added shortcuts / and * to shrink and use original zoom
+
+-- circular <[email protected]>  Fri, 10 Apr 2020 12:07:00 +0100
+

+ 1 - 1
lazpaint/release/debian/linux32/DEBIAN/control

@@ -1,5 +1,5 @@
 Package: lazpaint
-Version: 7.0.9
+Version: 7.1
 Section: base
 Priority: optional
 Architecture: i386

+ 13 - 0
lazpaint/release/debian/linux64/DEBIAN/changelog

@@ -173,3 +173,16 @@ lazpaint (7.0.9) unstable; urgency=low
 
 -- circular <[email protected]>  Fri, 3 Apr 2020 12:40:00 +0100
 
+lazpaint (7.1) stable; urgency=low
+
+  * tool: fix update of pen style from shape
+  * interface: fix file extension mask when opening image browser
+  * interface: fix selection of file after changing folder
+  * interface: show progress when changing canvas size
+  * interface: show popup when downsampling opened big image
+  * interface: fix update of popup on Windows
+  * interface: allow to select outside color circle of color window
+  * interface: added shortcuts / and * to shrink and use original zoom
+
+-- circular <[email protected]>  Fri, 10 Apr 2020 12:07:00 +0100
+

+ 1 - 1
lazpaint/release/debian/linux64/DEBIAN/control

@@ -1,5 +1,5 @@
 Package: lazpaint
-Version: 7.0.9
+Version: 7.1
 Section: base
 Priority: optional
 Architecture: amd64

+ 2 - 2
lazpaint/release/macOS/LazPaint.app/Contents/Info.plist

@@ -19,9 +19,9 @@
     <key>CFBundleSignature</key>
     <string>lazp</string>
     <key>CFBundleShortVersionString</key>
-    <string>7.0.9</string>
+    <string>7.1</string>
     <key>CFBundleVersion</key>
-    <string>7.0.9</string>
+    <string>7.1</string>
     <key>CSResourcesFileMapped</key>
     <true/>
     <key>CFBundleDocumentTypes</key>

+ 1 - 1
lazpaint/release/macOS/makedmg.sh

@@ -12,7 +12,7 @@ fi
 
 
 appname=LazPaint
-appversion=7.0.9
+appversion=7.1
 pkgversion=0
 appnamenospaces=lazpaint
 appbundle="$appname.app"

+ 1 - 1
lazpaint/release/windows/lazpaint.iss

@@ -1,7 +1,7 @@
 #define MyAppName "LazPaint"
 #define MyAppOutputName "lazpaint"
 #define MyInstallerSuffix "_setup_win32_win64"
-#define MyAppVersion "7.0.9"
+#define MyAppVersion "7.1"
 #define MyAppPublisher "Circular, Fabien Wang, Lainz and others"
 #define MyAppURL "http://sourceforge.net/projects/lazpaint/"
 #define MyAppExeName "lazpaint.exe"

+ 1 - 1
lazpaint/tools/utoolbasic.pas

@@ -321,7 +321,7 @@ begin
     if Manager.ShapeOptionAliasing then
     begin
       pts := toolDest.Pen.ComputePolyline([PointF(destF.X,destF.Y),PointF(originF.X,originF.Y)],
-       Manager.PenWidth, testPix, False);
+       Manager.PenWidth, BGRAPixelTransparent, False);
       toolDest.FillPoly(pts, b);
     end else
     begin

+ 6 - 5
lazpaint/tools/utooldeformationgrid.pas

@@ -957,10 +957,9 @@ begin
       if curDist < minDist then
       begin
         minDist := curDist;
-        deformationGridX := xb;
-        deformationGridY := yb;
+        x := xb;
+        y := yb;
         result := True;
-        deformationOrigin := ptF;
       end;
     end;
 end;
@@ -988,7 +987,7 @@ var xb,yb,NbX,NbY: integer;
     layer,backupLayer : TBGRABitmap;
     PreviousClipRect: TRect;
     previousBounds: TRect;
-    gridMinX,gridMinY,gridMaxX,gridMaxY, dummyX, dummY: integer;
+    gridMinX,gridMinY,gridMaxX,gridMaxY, dummyX, dummyY: integer;
 
   procedure AddToDeformationArea(xi,yi: integer);
   var ptF: TPointF;
@@ -1011,7 +1010,9 @@ begin
 
   if not deformationGridMoving then
   begin
-    if GetPointAt(ptF, dummyX, dummY) then
+    dummyX := 1;
+    dummyY := 1;
+    if GetPointAt(ptF, dummyX, dummyY) then
       Cursor := crHandPoint
       else Cursor := crDefault;
     exit;

+ 1 - 0
lazpaint/tools/utoollayer.pas

@@ -590,6 +590,7 @@ begin
       FBackupLayer.nextMatrix := transform;
       Manager.Image.AddUndo(invTransformDiff);
       Manager.Image.AddUndo(FBackupLayer);
+      r := EmptyRect;
       Manager.Image.CurrentState.LayeredBitmap.RenderLayerFromOriginalIfNecessary(layerIdx, false, r);
       FBackupLayer := nil;
     end;

+ 1 - 1
lazpaint/tools/utooltext.pas

@@ -6,7 +6,7 @@ interface
 
 uses
   Classes, SysUtils, UTool, UToolVectorial, LCLType, Graphics, BGRABitmap, BGRABitmapTypes, BGRATextFX,
-  BGRAGradients, LCVectorOriginal, LCVectorialFill;
+  BGRAGradients, LCVectorOriginal;
 
 type
 

+ 1 - 2
lazpaint/tools/utoolvectorial.pas

@@ -407,7 +407,6 @@ end;
 
 procedure TEditShapeTool.UpdateToolManagerFromShape(AShape: TVectorShape);
 var
-  ps: TPenStyle;
   opt: TShapeOptions;
   zoom: single;
   m: TAffineMatrix;
@@ -435,7 +434,7 @@ begin
       else
       begin
         include(opt,toDrawShape);
-        Manager.PenStyle := ps;
+        Manager.PenStyle := BGRAToPenStyle(AShape.PenStyle);
       end;
   end;
   if doDraw then

+ 4 - 4
lazpaint/uimagelist.pas

@@ -125,15 +125,15 @@ type
     function ScriptOpenNext(AVars: TVariableSet): TScriptResult;
     function ScriptOpenPrevious(AVars: TVariableSet): TScriptResult;
     function ScriptOpenSelected(AVars: TVariableSet): TScriptResult;
-    function ScriptRemoveAll(AVars: TVariableSet): TScriptResult;
+    function ScriptRemoveAll({%H-}AVars: TVariableSet): TScriptResult;
     function ScriptRemoveIndex(AVars: TVariableSet): TScriptResult;
-    function ScriptRemoveNonExistent(AVars: TVariableSet): TScriptResult;
-    function ScriptRemoveUnchecked(AVars: TVariableSet): TScriptResult;
+    function ScriptRemoveNonExistent({%H-}AVars: TVariableSet): TScriptResult;
+    function ScriptRemoveUnchecked({%H-}AVars: TVariableSet): TScriptResult;
     function ScriptSetAutoUncheckMode(AVars: TVariableSet): TScriptResult;
     function ScriptSetAutoZoomFit(AVars: TVariableSet): TScriptResult;
     function ScriptSetFileChecked(AVars: TVariableSet): TScriptResult;
     function ScriptSetSelectedIndex(AVars: TVariableSet): TScriptResult;
-    function ScriptUncheckNonExistent(AVars: TVariableSet): TScriptResult;
+    function ScriptUncheckNonExistent({%H-}AVars: TVariableSet): TScriptResult;
     procedure SetLazPaintInstance(AValue: TLazPaintCustomInstance);
     procedure SetRowChecked(AIndex: integer; AValue: boolean);
     procedure RegisterScriptFunctions(ARegister: boolean);

+ 3 - 3
lazpaint/uimageview.pas

@@ -172,13 +172,13 @@ begin
   begin
     FVirtualScreen := TBGRABitmap.Create(FLastPictureParameters.virtualScreenArea.Right-FLastPictureParameters.virtualScreenArea.Left,
                                         FLastPictureParameters.virtualScreenArea.Bottom-FLastPictureParameters.virtualScreenArea.Top, WorkspaceColor);
-  end else
-  begin
-    if picParamWereDefined then FVirtualScreen.ClipRect := GetRenderUpdateRectVS(False);
+    Image.ResetRenderUpdateRect;
+    Image.RenderMayChange(rect(0,0,FVirtualScreen.Width,FVirtualScreen.Height), false, false);
   end;
 
   if not FUpdatingPopup then
   begin
+    if picParamWereDefined then FVirtualScreen.ClipRect := GetRenderUpdateRectVS(False);
     Image.ResetRenderUpdateRect;
 
     if not FVirtualScreen.ClipRect.IsEmpty then

+ 1 - 0
lazpaint/umyslv.pas

@@ -1145,6 +1145,7 @@ begin
   for I := 0 to ItemCount-1 do
     SetItemImage(I,nil,false);
   FData := nil;
+  FSelectedIndex:= -1;
   if FUpdateCount = 0 then InvalidateView;
 end;