HowTo : How to get entitiy's coordinates in the result image after RenderToBitmap
Article | 41024143 |
Type | HowTo |
Product | Engine |
Version | 5.1.1.1038 |
Date Added | 11/3/2005 |
Submitted by | Sheena Konikkara |
Keywords | |
Subject
How to get entitiy's coordinates in the result image after RenderToBitmap
Summary
How to get entitiy's coordinates in the result image after RenderToBitmap
Solution
To get the entities coordinates in the result image use the following conversion algorithm:
Set ImageVD = VDPro.ActiveDocument.RenderToBitmap(PixW, PixH,new double() {xmin,ymin}, new double() {xmax,ymax})
double w = xmax-xmin
double h = ymax-ymin
double l1 = PixW / w
double l2 = PixH / h
double l = min( l1, l2 )
double viewsize =PixH / l +( 2.0+l )
double xcen = ( xmax - xmin ) / 2.0
double ycen = ( ymax - ymin ) / 2.0
double pixelsize = viewsize / PixH
int PixelX = ( x - xcen ) / pixelsize + PixW / 2.0
int PixelY = ( ycen - y ) / pixelsize + PixH / 2.0
where the xmin,ymin , xmax,ymax are the rectangle coordinates in drawing units that you want to render and PixH, PixW are the image size in pixels ( for example 800x600 ).
PixelX and PixelY are the entities coordinates in the final image and x, y are the entities coordinate in drawing units.