View Issue Details

IDProjectCategoryView StatusLast Update
0027144PackagesFCLpublic2018-04-13 14:38
ReporterCedricAssigned Towp 
PrioritynormalSeverityminorReproducibilityhave not tried
Status resolvedResolutionfixed 
PlatformlinuxOSOS Version
Product Version1.2.7 (SVN)Product Build 
Target Version1.8.4Fixed in Version 
Summary0027144: TLazIntfImage.CopyPixels allow clipping only on right and bottom and raise an exception if XDst and YDst are negatives
Descriptionthe source image with TLazIntfImage.CopyPixels can be clipped only on bottom and right, trying to copy an image with negative value in parameter x and y an exception is raised.

i joined a patch to allow clipping on top and left.

Perhaps TLazCanvas can do clipping, but i didn't tried it.
Steps To Reproducesee sample.zip
TagsNo tags attached.
Fixed in Revision57653
LazTarget1.8.4
WidgetsetGTK 2
Attached Files
  • sample.zip (2,461 bytes)
  • CopyPixels.diff (1,479 bytes)
    Index: lcl/intfgraphics.pas
    ===================================================================
    --- lcl/intfgraphics.pas	(révision 47135)
    +++ lcl/intfgraphics.pas	(copie de travail)
    @@ -3768,7 +3768,7 @@
     var
       SrcImg: TLazIntfImage absolute ASource;
       SrcHasMask, DstHasMask: Boolean;
    -  x, y, xStop, yStop: Integer;
    +  x, y, xStart, yStart, xStop, yStop: Integer;
       c: TFPColor;
     begin
     {
    @@ -3776,7 +3776,7 @@
         SetSize(Src.Width,Src.Height);
     }
       if (ASource is TLazIntfImage) and
    -     FRawImage.Description.IsEqual(SrcImg.FRawImage.Description) and (XDst =  0) and (YDst = 0) then
    +  FRawImage.Description.IsEqual(SrcImg.FRawImage.Description) and (XDst =  0) and (YDst = 0) then
       begin
         // same description -> copy
         if FRawImage.Data <> nil then
    @@ -3787,6 +3787,14 @@
       end;
     
       // copy pixels
    +  if XDst<0 then
    +    XStart := -XDst
    +  else
    +    XStart := 0;
    +  if YDst<0 then
    +    YStart := -YDst
    +  else
    +    YStart := 0;
       xStop := ASource.Width;
       if Width - XDst < xStop
       then xStop := Width - XDst;
    @@ -3806,13 +3814,13 @@
       if DstHasMask
       and (ASource is TLazIntfImage)
       then begin
    -    for y:=0 to yStop do
    -      for x:=0 to xStop do
    +    for y:=yStart to yStop do
    +      for x:=xStart to xStop do
             Masked[x+XDst,y+YDst] := SrcHasMask and SrcImg.Masked[x,y];
       end;
     
    -  for y:=0 to yStop do
    -    for x:=0 to xStop do
    +  for y:=yStart to yStop do
    +    for x:=xStart to xStop do
         begin
           c := ASource.Colors[x,y];
     
    
    CopyPixels.diff (1,479 bytes)

Activities

Cedric

2014-12-08 13:57

reporter  

sample.zip (2,461 bytes)

Cedric

2014-12-08 13:58

reporter  

CopyPixels.diff (1,479 bytes)
Index: lcl/intfgraphics.pas
===================================================================
--- lcl/intfgraphics.pas	(révision 47135)
+++ lcl/intfgraphics.pas	(copie de travail)
@@ -3768,7 +3768,7 @@
 var
   SrcImg: TLazIntfImage absolute ASource;
   SrcHasMask, DstHasMask: Boolean;
-  x, y, xStop, yStop: Integer;
+  x, y, xStart, yStart, xStop, yStop: Integer;
   c: TFPColor;
 begin
 {
@@ -3776,7 +3776,7 @@
     SetSize(Src.Width,Src.Height);
 }
   if (ASource is TLazIntfImage) and
-     FRawImage.Description.IsEqual(SrcImg.FRawImage.Description) and (XDst =  0) and (YDst = 0) then
+  FRawImage.Description.IsEqual(SrcImg.FRawImage.Description) and (XDst =  0) and (YDst = 0) then
   begin
     // same description -> copy
     if FRawImage.Data <> nil then
@@ -3787,6 +3787,14 @@
   end;
 
   // copy pixels
+  if XDst<0 then
+    XStart := -XDst
+  else
+    XStart := 0;
+  if YDst<0 then
+    YStart := -YDst
+  else
+    YStart := 0;
   xStop := ASource.Width;
   if Width - XDst < xStop
   then xStop := Width - XDst;
@@ -3806,13 +3814,13 @@
   if DstHasMask
   and (ASource is TLazIntfImage)
   then begin
-    for y:=0 to yStop do
-      for x:=0 to xStop do
+    for y:=yStart to yStop do
+      for x:=xStart to xStop do
         Masked[x+XDst,y+YDst] := SrcHasMask and SrcImg.Masked[x,y];
   end;
 
-  for y:=0 to yStop do
-    for x:=0 to xStop do
+  for y:=yStart to yStop do
+    for x:=xStart to xStop do
     begin
       c := ASource.Colors[x,y];
 
CopyPixels.diff (1,479 bytes)

wp

2018-04-13 14:38

developer   ~0107762

Fixed. Please test and close if ok. Sorry for the delay!

Issue History

Date Modified Username Field Change
2014-12-08 13:57 Cedric New Issue
2014-12-08 13:57 Cedric File Added: sample.zip
2014-12-08 13:58 Cedric File Added: CopyPixels.diff
2018-04-13 14:37 wp Assigned To => wp
2018-04-13 14:37 wp Status new => assigned
2018-04-13 14:38 wp Fixed in Revision => 57653
2018-04-13 14:38 wp LazTarget => 1.8.4
2018-04-13 14:38 wp Note Added: 0107762
2018-04-13 14:38 wp Status assigned => resolved
2018-04-13 14:38 wp Resolution open => fixed
2018-04-13 14:38 wp Target Version => 1.8.4