Fixed a regression (in r776) that ImageCrop cannot treat a transparent part of the outside of the image.

This commit is contained in:
spx 2011-03-09 03:03:02 +00:00
parent 8ddc383ed1
commit ec49c6e588
2 changed files with 4 additions and 3 deletions

View File

@ -425,7 +425,8 @@ void CTintedImage::ApplyCrop()
}
Rect r(0, 0, m_Crop.Width, m_Crop.Height);
m_BitmapTint = new Bitmap(r.Width, r.Height, AdjustNonAlphaPixelFormat(m_Bitmap));
m_BitmapTint = new Bitmap(r.Width, r.Height,
AdjustNonAlphaPixelFormat(m_Bitmap, x >= 0 && y >= 0 && (x + m_Crop.Width) <= imageW && (y + m_Crop.Height) <= imageH));
Graphics graphics(m_BitmapTint);
graphics.DrawImage(m_Bitmap, r, x, y, r.Width, r.Height, UnitPixel);

View File

@ -85,8 +85,8 @@ public:
void DisposeImage();
void LoadImage(const std::wstring& imageName, bool bLoadAlways);
static Gdiplus::PixelFormat AdjustNonAlphaPixelFormat(Gdiplus::Bitmap* bitmap)
{ return (bitmap->GetPixelFormat() == PixelFormat24bppRGB) ? PixelFormat24bppRGB : PixelFormat32bppPARGB; }
static Gdiplus::PixelFormat AdjustNonAlphaPixelFormat(Gdiplus::Bitmap* bitmap, bool additionalCondition = true)
{ return (bitmap->GetPixelFormat() == PixelFormat24bppRGB && additionalCondition) ? PixelFormat24bppRGB : PixelFormat32bppPARGB; }
protected:
enum CROPMODE