From ec49c6e588e3006b49f76d524452bef3b8002934 Mon Sep 17 00:00:00 2001 From: spx Date: Wed, 9 Mar 2011 03:03:02 +0000 Subject: [PATCH] Fixed a regression (in r776) that ImageCrop cannot treat a transparent part of the outside of the image. --- Library/TintedImage.cpp | 3 ++- Library/TintedImage.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Library/TintedImage.cpp b/Library/TintedImage.cpp index af22b74c..772e5a89 100644 --- a/Library/TintedImage.cpp +++ b/Library/TintedImage.cpp @@ -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); diff --git a/Library/TintedImage.h b/Library/TintedImage.h index ddc48374..87b06bc3 100644 --- a/Library/TintedImage.h +++ b/Library/TintedImage.h @@ -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