Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Copy rectangle within image. V16/full version, dotnet / vs2008 / c#
Started by pocketzz at 11-19-2008 19:41. Topic has 6 replies.

Print Search « Previous Thread Next Thread »
  11-19-2008, 19:41
pocketzz is not online. Last active: 10/27/2008 3:48:44 PM pocketzz

Top 150 Posts
Joined on 10-27-2008
Posts 17
Copy rectangle within image. V16/full version, dotnet / vs2008 / c#
Reply Quote
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




   Report 
  11-20-2008, 10:37
Yasir Alani is not online. Last active: 11/16/2008 11:29:23 AM Yasir Alani



Top 10 Posts
Joined on 02-05-2007
Posts 311
Re: Copy rectangle within image. V16/full version, dotnet / vs2008 / c#
Reply Quote
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.
Yasir Alani
LEADTOOLS Technical Support
support@leadtools.com
   Report 
  11-20-2008, 11:27
pocketzz is not online. Last active: 10/27/2008 3:48:44 PM pocketzz

Top 150 Posts
Joined on 10-27-2008
Posts 17
Re: Copy rectangle within image. V16/full version, dotnet / vs2008 / c#

Attachment: BLNKCERTdemo.tif
Reply Quote
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.
   Report 
  11-20-2008, 11:55
pocketzz is not online. Last active: 10/27/2008 3:48:44 PM pocketzz

Top 150 Posts
Joined on 10-27-2008
Posts 17
Re: Copy rectangle within image. V16/full version, dotnet / vs2008 / c#

Attachment: BLNKCERT1.tif
Reply Quote
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?
   Report 
  11-20-2008, 11:59
pocketzz is not online. Last active: 10/27/2008 3:48:44 PM pocketzz

Top 150 Posts
Joined on 10-27-2008
Posts 17
Re: Copy rectangle within image. V16/full version, dotnet / vs2008 / c#
Reply Quote
note... it seems to do the same thing regardless of the numbers I put in "new Rectangle(1, 1, 1, 1)"
   Report 
  11-23-2008, 10:18
Yasir Alani is not online. Last active: 11/16/2008 11:29:23 AM Yasir Alani



Top 10 Posts
Joined on 02-05-2007
Posts 311
Re: Copy rectangle within image. V16/full version, dotnet / vs2008 / c#

Attachment: TestCombineFast.zip
Reply Quote
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.
Yasir Alani
LEADTOOLS Technical Support
support@leadtools.com
   Report 
  11-24-2008, 16:26
pocketzz is not online. Last active: 10/27/2008 3:48:44 PM pocketzz

Top 150 Posts
Joined on 10-27-2008
Posts 17
Re: Copy rectangle within image. V16/full version, dotnet / vs2008 / c#
Reply Quote
Looking at your stuff, helped me get what I needed !

Thanks!
   Report 
Post
LEAD Support Fo... » Developer » DotNet » Copy rectangle within image. V16/full version, dotnet / vs2008 / c#

Powered by Community Server, by Telligent Systems