getting "Annotation" objects Co-ordinates

Discussions about annotation support.
Post Reply
subink
Posts: 1
Joined: Tue Jul 26, 2011 11:15 pm

getting "Annotation" objects Co-ordinates

Post by subink » Tue Jul 26, 2011 11:55 pm

Hello,

Please help me to retreive annotation object's co-ordinates in pixels, current LEFT,TOP,WIDTH,HEIGHT properties are returning this in Inches. My ultimate idea is to mark specific regions in a document with Annotation & read this using OCR/OMR/Barcode. With this annotation objeject's retreived co-ordinates, I need to use in SETROI method.

I saw an option to convert Inches from a 200 DPI document using (where ann is a annotation object)

int LeftAreaInches = (int)ann.Left; int TopAreaInches = (int)ann.Top; int WidthAreaInches = (int)ann.Width; int heightAreaInches = (int)ann.Height;
int LeftAreaPixel;int TopAreaPixel;int WidthAreaPixel;int HeightAreaPixel;
//
LeftAreaPixel = LeftAreaInches * 200;
TopAreaPixel = TopAreaInches * 200;
WidthAreaPixel= WidthAreaInches * 200;
HeightAreaPixel= heightAreaInches * 200;

but I have serious issue of data loss when I convert Inch to int then to Pixel. Also I am having trouble to understand why SETROI only takes "int", is there is any other method which takes float which will give us more accuracy.

Please send me any sample code on this area.

My Environment
-----------------------
Demo V8 .Net
Tiff/tif document

Thanks,
Sub

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

Re: getting "Annotation" objects Co-ordinates

Post by Loïc » Thu Jul 28, 2011 4:00 pm

Hi,

Easy to do:

Code: Select all

        private void button1_Click_1(object sender, EventArgs e)
        {
           GdPicture.Annotation MyAnnot = GdViewer1.GetAnnotationFromIdx(0);
           int left_pix = (int)(MyAnnot.Left * GdViewer1.HorizontalResolution);
           int top_pix = (int)(MyAnnot.Top * GdViewer1.HorizontalResolution);
           int width_pix = (int)(MyAnnot.Width * GdViewer1.HorizontalResolution);
           int height_pix = (int)(MyAnnot.Height * GdViewer1.HorizontalResolution);
           GdViewer1.SetRectCoordinatesOnDocument(left_pix - width_pix / 2, top_pix - height_pix/2, width_pix, height_pix); //note: left & top are coordinates of the center point of the annot !
        }
Let me know if you need further information.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests