Author |
Topic  |
|
John@Field

United Kingdom
13 Posts |
Posted - Mar 10 2014 : 13:55:57
|
I would like to copy one part of an image to another part of the image in the same way that it is done with the clone brush in PaintshopPro.
Any suggestions would be much appreciated.
JWA |
|
John@Field

United Kingdom
13 Posts |
Posted - Mar 10 2014 : 13:58:22
|
I would also like to add a feather effect to the result
JWA |
 |
|
w2m
   
USA
1990 Posts |
|
John@Field

United Kingdom
13 Posts |
Posted - Mar 11 2014 : 03:14:30
|
Thanks I will look into it.
JWA |
 |
|
spetric
  
Croatia
308 Posts |
Posted - Mar 11 2014 : 07:32:38
|
The best way to do this task is to determine region of interest (ROI/bounding rectangle) over cloning image with the same size as your cloning brush. Then, while you're moving your mouse over some image (we will call it Image1), you need to copy region of interest from cloning image (Image2) to to Image1 using gray-scale mask that represents your brush tip.
Actually, you have two mouse positions: real on Image1 and calculated (virtual) on Image2.
It can be also done using off-screen bitmap with same size as your cloning brush tip.
Also, you need to take care when position of your brush tip exceeds Image2 width/height (wrapping may be performed).
I do this task using low-level byte access routines, but it can be achieved using ImageEn methods. |
 |
|
John@Field

United Kingdom
13 Posts |
Posted - Mar 13 2014 : 15:49:27
|
Thanks spectric
I have managed to clone an area using a technique similar to the one you suggested. I am now working on the feathering.
JWA |
 |
|
spetric
  
Croatia
308 Posts |
Posted - Mar 13 2014 : 16:06:02
|
That's a good idea to use selection as brush tip and then move selection across the image(s).
Are you using two identical selections on both images? |
 |
|
John@Field

United Kingdom
13 Posts |
Posted - Mar 14 2014 : 14:03:51
|
Thanks again spectric,
I am not sure how to copy one selection to another Yet as I am new to ImageEn.
The method I am using is similar, I think, to the low level byte routines you mention.
I am selecting an area using a right mouse click then move the mouse to where I want to place the copy. Then pressing the left mouse button, pick up one area and place it in another several pixels at a time. This is continues while I drag the mouse over the new area.
The pixel copying is done using the following Function.
iRad = Radius S & P Select & Place Points Image1 the image to be cloned.
Call the function. ImageEnView1 := CopySelection(1, Sel, Place, ImageEnView1);
function TCloneForm.CopySelection(iRad: Integer; S, P: TPoint; Image1: TImageEnview): TImageEnview; var Rad, x, xx, yy, y : integer; { x is the column y is the row } Horz, Vert : Integer; ItemRad : Double; begin xx := iRad * 2; { The Radius x 2} yy := iRad * 2; Rad := iRad;
for y := 0 to yy do begin for x := 0 to xx do begin {This Calculates the radius to Keep the Pixels within the circle} Horz := sqr(Rad - X); Vert := sqr(Rad - Y); ItemRad := Sqrt(Horz + Vert); { is it in the circle } { PixColour : array[0..100] of array[0..100] of TColor; } { If the pixel is within the radius then copy it } if (ItemRad <= Rad) then begin PixColour[y, x] := Image1.Bitmap.Canvas.Pixels[S.X + x - Rad, S.Y + y - Rad]; Image1.Bitmap.canvas.pixels[P.X + x - Rad, P.Y + y - Rad] := PixColour[y, x]; end; end; end;
Result := Image1; end;
JWA |
 |
|
|
Topic  |
|