LEADTOOLS Support
Imaging
Imaging SDK Questions
Confused about the Destination Clipping Rectangle for Raster Image Processing (Visual C++ Version 6)
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#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.
Thanks,
Doug
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;
}
else
{
// 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
m_image_control.ForceRepaint();
}
#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)
Doug,
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.
LEADTOOLS Support
Imaging
Imaging SDK Questions
Confused about the Destination Clipping Rectangle for Raster Image Processing (Visual C++ Version 6)
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.