Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Thursday, April 5, 2012 5:56:09 PM(UTC)

Flood  
Flood

Groups: Registered
Posts: 11


I draw a rect by mouse,map this rect to piscure's rgn.and then draw the rgn.but they show not completely at the same pos. in attachement sample, the dotrect is the rng,the black sold is the original.and i find that, the bigger of image ,the bigger measurement error .

my code is this:

RECT rcScaled;
rcScaled.left=(int)((m_rcCLoneRect.left-m_rcDst.left)/(GetZoomPercent()/100.0)+0.5);

rcScaled.top=(int)((m_rcCLoneRect.top-m_rcDst.top)/(GetZoomPercent()/100.0)+0.5);

rcScaled.right=rcScaled.left+(int)((m_rcCLoneRect.Width()*100/GetZoomPercent()));
rcScaled.bottom=rcScaled.top+(int)((m_rcCLoneRect.Height()*100/GetZoomPercent()));

SetAutoRgnToFloater(TRUE);
LBitmapRgn Region(this);
Region.SetRgnRect(&rcScaled);
this->Repaint();
File Attachment(s):
sample.zip (1,636kb) downloaded 31 time(s).
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Sunday, April 8, 2012 1:44:28 AM(UTC)

mohamed  
mohamed

Groups: Registered, Tech Support
Posts: 179


The most likely cause of the difference is rounding errors. The GetZoomPercent() function returns integer, and all the calculations in your code are integer based.
This means you will not get accurate results this way.

A better way to convert from client coordinates to bitmap coordinates, is to use the formula in this forum post:
http://support.leadtools.com/cs/forums/34411/ShowPost.aspx

You can also use the same rectangles to do the inverse calculation from bitmap to client coordinates if you need it.
Mohamed Abedallah
Developer Support Engineer
LEAD Technologies, Inc.

LEAD Logo
 
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.

Powered by YAF.NET | YAF.NET © 2003-2020, Yet Another Forum.NET
This page was generated in 0.151 seconds.