Versie 2.86: ImageConvert zal automatisch croppen voor SaveAs als aspectratio veranderd is
svn path=/Slnkdwf/trunk/; revision=16052
This commit is contained in:
@@ -118,6 +118,31 @@ STDMETHODIMP CImageConvert::SaveAs(BSTR IMGPath)
|
||||
if (m_height != m_image.GetHeight() ||
|
||||
m_width != m_image.GetWidth())
|
||||
{
|
||||
// Eerst croppen indien nodig, we doen niet aan distortion
|
||||
// myDoTRACE("\nSaveAs h=%d, w=%d, H=%d, W=%d", m_height, m_width, m_image.GetHeight(), m_image.GetWidth());
|
||||
if (m_height * m_image.GetWidth() != m_width * m_image.GetHeight())
|
||||
{
|
||||
int left, top, right, bottom;
|
||||
if (m_height * m_image.GetWidth() > m_width * m_image.GetHeight())
|
||||
{ // smaller maken
|
||||
int diff = m_image.GetWidth() - m_width * m_image.GetHeight() / m_height;
|
||||
left = diff / 2;
|
||||
top = 0;
|
||||
}
|
||||
else
|
||||
{ // lager maken
|
||||
int diff = m_image.GetHeight() - m_height * m_image.GetWidth() / m_width;
|
||||
top = diff / 2;
|
||||
left = 0;
|
||||
}
|
||||
right = m_image.GetWidth() - left;
|
||||
bottom = m_image.GetHeight() - top;
|
||||
// myDoTRACE("\nSaveAs crop to l=%d, t=%d, r=%d, b=%d", left, top, right, bottom);
|
||||
if (!m_image.Crop(left, top, right, bottom))
|
||||
return myAtlReportError (GetObjectCLSID(), "Error cropping to l=%d, t=%d, r=%d, b=%d\n%s",
|
||||
left, top, right, bottom, m_image.GetLastError());
|
||||
}
|
||||
|
||||
// mode 1 for fast (nearest pixel) method, or 2 for accurate (bicubic spline interpolation) method.
|
||||
if (!m_image.Resample(m_width, m_height, /*mode*/ 2))
|
||||
return myAtlReportError (GetObjectCLSID(), "Error resizing to w=%d, h=%d\n%s",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Zorg dat versies alfabetisch altijd op elkaar volgen!
|
||||
#define SLNK_MAJOR_VERSION 2
|
||||
#define SLNK_MINOR_VERSION 85
|
||||
#define SLNK_MINOR_VERSION 86
|
||||
#define SLNK_BUILD_VERSION 0
|
||||
|
||||
// Define resource strings
|
||||
|
||||
Reference in New Issue
Block a user