Get Annotations Size in Pixel or DrawGdPictureImage in Inch

Example requests & Code samples for GdPicture Toolkits.
Post Reply
adadero
Posts: 3
Joined: Sat May 24, 2014 4:56 pm

Get Annotations Size in Pixel or DrawGdPictureImage in Inch

Post by adadero » Sat May 24, 2014 5:30 pm

Hi, I'm using GDPicture Trial. I have the following difficulties in annotations. Here's the logic steps:
1. I create image annotation

Code: Select all

this.gdViewer.AddEmbeddedImageAnnotInteractive(path, false, Color.White, System.Convert.ToSingle(0.02), 1);
2. When I click a button, let's call it save_button then I burn the annotation to the viewer

Code: Select all

this.gdViewer.BurnAnnotationsToPage(true);
When save_button is clicked I also save the size of the annotation

Code: Select all

Annotation annotation = this.gdViewer.GetAnnotationFromIdx(index);
variable_from_annotation_left = annotation.Left;
variable_from_annotation_height = annotation.Height;
variable_from_annotation_top = annotation.Top;
variable_from_annotation_width = annotation.Width 
//return float (inch measurement)
3. Now, I want to redraw then annotation (draw image) using GdPictureImaging and the size and position are based on annotation size and position

Code: Select all

GdPictureImaging imaging = new GdPictureImaging imaging();
int left = variable_from_annotation_left; //it's impossible because returns float (inch)
int top = variable_from_annotation_top;
int width = variable_from_annotation_width;
int height = variable_from_annotation_height;
imaging.DrawGdPictureImage(imageTobeAnnotation, imageOnGdViewer, left, top, width, height, System.Drawing.Drawing2D.InterpolationMode.Default);
So, the questions are:
1. Is it possible to draw image using GdPictureImaging.DrawGdPictureImage with inch measurement? I want to draw image based on Annotation annotation = this.gdViewer.GetAnnotationFromIdx(index) code.
2. Or, is there a method to get size of annotation NOT in inch but in pixels?

Is there anybody can give me a sample code, please?

Sorry for my bad English.
Thanks in advance

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Get Annotations Size in Pixel or DrawGdPictureImage in I

Post by Loïc » Thu May 29, 2014 10:28 am

Hello,

Sorry for the delayed reply.
1. Is it possible to draw image using GdPictureImaging.DrawGdPictureImage with inch measurement? I want to draw image based on Annotation annotation = this.gdViewer.GetAnnotationFromIdx(index) code.
Yes, just translate your inch values to pixel by multiplying it by horizontal or vertical resolution of the document.

For example:

Code: Select all

GdPictureImaging imaging = new GdPictureImaging imaging();
int left = (int)Math.Round((variable_from_annotation_left - variable_from_annotation_width / 2) * imaging.GetHorizontalResolution(imageTobeAnnotation));
int top= (int)Math.Round((variable_from_annotation_top - variable_from_annotation_height /2) * imaging.GetVerticalResolution(imageTobeAnnotation));
int width= (int)Math.Round(variable_from_annotation_width * imaging.GetHorizontalResolution(imageTobeAnnotation));
int height= (int)Math.Round(variable_from_annotation_height * imaging.GetVerticalResolution(imageTobeAnnotation));
imaging.DrawGdPictureImage(imageTobeAnnotation, imageOnGdViewer, left, top, width, height, System.Drawing.Drawing2D.InterpolationMode.Default);
Note: this works only if the annotation has a rotation of 0 degree.
Note 2: annotation.Left, annotation.Top specify the coordinates of the center point of the annotation.

Hope this brings some help!

With best regards,

Loïc Carrère

adadero
Posts: 3
Joined: Sat May 24, 2014 4:56 pm

Re: Get Annotations Size in Pixel or DrawGdPictureImage in I

Post by adadero » Fri May 30, 2014 12:54 am

I use example and it's not solved the problem. The "imageTobeAnnotation" doesn't fit the size of annotation size in width, height, top and left. Should I resize the "imageTobeAnnotation"? If yes, how to do it properly? I have no idea how to solve the problem because the following code doesn't work.

Code: Select all

imaging.SetHorizontalResolution(imageTobeAnnotation, imageOnGdViewer.Width);
imaging.SetVerticalResolution(imageTobeAnnotation, imageOnGdViewer.Height);
Or

Code: Select all

imaging.ResizeHeightRatio(imageTobeAnnotation, imageOnGdViewer.Height, System.Drawing.Drawing2D.InterpolationMode.Default);
imaging.ResizeWidthRatio(imageTobeAnnotation, imageOnGdViewer.Width, System.Drawing.Drawing2D.InterpolationMode.Default);

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Get Annotations Size in Pixel or DrawGdPictureImage in I

Post by Loïc » Sun Jun 01, 2014 11:44 am

Hello,

Both of your snippets are wrong. Why not using the one I provided?

If you are still not able to fix this issue please reproduce what you've done in a standalone application and share it with our team through https://www.gdpicture.com/support/getting-support-from-our-team.

With best regards,

Loïc Carrère

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests