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



Last Go to last post Unread Go to first unread post
#1 Posted : Monday, November 14, 2005 8:57:40 AM(UTC)

Groups: Registered
Posts: 4

My goal, which seemed simple enough was to size an image to fit the physical control, maintaining the aspect ratio.  I first determined which direction, horizontal or vertical would require the most scaling down and then scaled both directions by the same amount.  I did all this (see code below) and it only NEARLY worked!  I found that the resultant image was clipped by a small amount on the top.  After struggling for quite some time, I decided to start breaking down the code.  When I removed the SetDstClipRect line, which essentiallly just set the Clip Rect to match the Dest Rect,everything was fine, leading me to believe that there must be something important that I didn't know about the Clip Rect.  It would seem that perhaps, the Clip Rect origin is different from the Dest Rect ?????  Any explanation or a pointer to any pertinent documentation would be GREATLY appreaciated.



Code Follows:


void CPatientImaging::OnSizeToFit()

 float scaleFactor;
 float vFactor =  (float)m_lead_control_rect.Height() / (float)  m_current_source_rect.Height();
 float hFactor =  (float)m_lead_control_rect.Width() / (float)m_current_source_rect.Width();

 if (vFactor < 0)
  vFactor = -vFactor;

 if (hFactor < 0)
  hFactor = -hFactor;

 if (vFactor < hFactor)

  // Vertical is controlling dimension so scale both by vFactor
  scaleFactor = vFactor;


  // Horizontal is controlling dimension so scale both by hFactor
  scaleFactor = hFactor;


 float  ImageWidth = (float)m_current_source_rect.Width() * scaleFactor;
 float  ImageHeight = (float)m_current_source_rect.Height() * scaleFactor;
 float ImageTop = (m_image_control.GetScaleHeight() / 2) - (ImageHeight / 2);
 float ImageLeft = (m_image_control.GetScaleWidth() / 2) - (ImageWidth / 2);
 m_image_control.SetDstRect(ImageLeft, ImageTop, ImageWidth, ImageHeight);
 m_image_control.SetDstClipRect(ImageLeft, ImageTop, ImageWidth, ImageHeight);  // With this in, it doesn't work




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 : Thursday, November 17, 2005 8:21:39 AM(UTC)


Groups: Manager, Tech Support
Posts: 367

Was thanked: 1 time(s) in 1 post(s)

If the AutoScroll property is set to TRUE, the image will begin at the
left-top corner of the control, even if you try to set a different
destination rectangle. That's why the values you set for the
destination rect will change and no longer match the dest clipping rect.

Try to set the AutoScroll property to FALSE and see if this solves the problem.

Edited by user Tuesday, December 6, 2016 3:44:03 PM(UTC)  | Reason: Not specified

Amin Dodin

Senior Support Engineer
LEAD Technologies, Inc.
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-2024, Yet Another Forum.NET
This page was generated in 0.379 seconds.