LEADTOOLS Support
Imaging
Imaging SDK Questions
Copy rectangle within image. V16/full version, dotnet / vs2008 / c#
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Wednesday, November 19, 2008 2:36:06 PM(UTC)
Groups: Registered
Posts: 8
I am trying to copy a rectangle from one area of an image to another.
I have first cloned image1 to image2, and used CombineFastCommand to get the rectangle on image2.
This seems to work, but I guess I don't understand the xForm object. Because i can't seem to get a "good" handle on where i'm grabbing from, and where i'm placing the rectangles.
I tried to ignore the whole xForm object (using null) and creating my own scaler methodology.
double ppiWide1 = image1.Width / 8.5;
double ppiHigh1 = image1.Height / 11;
image1.AddRectangleToRegion(null, new Rectangle(Convert.ToInt32( 2 * ppiWide1), Convert.ToInt32(2 * ppiHigh1), Convert.ToInt32(2 * ppiWide1), Convert.ToInt32(2 * ppiHigh1)), RasterRegionCombineMode.Set);
in theory... this should be creating a rectangle that is 2 inches by 2 inches, located 2 inches from the top, left of the image.
Any suggestions? or am I possibly making this more difficult than in should be?
-Dan
#2
Posted
:
Thursday, November 20, 2008 5:32:11 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Dan,
I am not sure what exactly do you mean. Can you post some before and after images that describe what are you trying to do?
You can either post the images here, but you need to post each image in a new post (do not preview before posting or the attachment will be lost). Or you can put all images in one ZIP or RAR file and post it here.
If you don't want to post images here, you can send them to
support@leadtools.com and mention this forum post in the email.
#3
Posted
:
Thursday, November 20, 2008 6:22:44 AM(UTC)
Groups: Registered
Posts: 8
Here is an example of what I want to do.
Most of what I've had trouble with seems to be getting the coordinates of the rectangles. And seeing as how not all the images I'm working with are the same resolution, the coordinates are different.
#4
Posted
:
Thursday, November 20, 2008 6:50:27 AM(UTC)
Groups: Registered
Posts: 8
More odd / unexpected behavior...
I am playing with the objects in different ways to try to understand how rectangle coordinates behave on various documents.
this code
Leadtools.Codecs.RasterCodecs.Startup();
Leadtools.Codecs.RasterCodecs codecs = new Leadtools.Codecs.RasterCodecs();
RasterImage image1 = codecs.Load(@"C:\BLNKCERT1.tif");
image1.AddRectangleToRegion(null, new Rectangle(1, 1, 1, 1), RasterRegionCombineMode.Set);
Leadtools.ImageProcessing.Color.InvertCommand invert = new Leadtools.ImageProcessing.Color.InvertCommand();
invert.Run(image1);
codecs.Save(image1, @"C:\testpatt1.tif", RasterImageFormat.Tif, 0);
Inverts the entire image when applied to the attached image. When I point it at other types of images it seems to behave more normally...
Any thoughts?
#5
Posted
:
Thursday, November 20, 2008 6:54:31 AM(UTC)
Groups: Registered
Posts: 8
note... it seems to do the same thing regardless of the numbers I put in "new Rectangle(1, 1, 1, 1)"
#6
Posted
:
Sunday, November 23, 2008 5:13:18 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
I think that the CombineFastCommand method should work for you.
I'm attaching a small project that demonstrates how this is done using the sample image you sent me. All coordinates I used are in image pixels.
If this doesn't meet your needs, please tell me why not.
#7
Posted
:
Monday, November 24, 2008 11:21:12 AM(UTC)
Groups: Registered
Posts: 8
Looking at your stuff, helped me get what I needed !
Thanks!
LEADTOOLS Support
Imaging
Imaging SDK Questions
Copy rectangle within image. V16/full version, dotnet / vs2008 / c#
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.