- Added image caching system internally.

It would reduce memory usage in case that you use the same image file repeatedly on some meters. (Eg. Crop a part from same image by using ImageCrop.)
- Fixed an issue that Background image isn't drawn correctly when BackgroundMode=0 and tint option is set.
This commit is contained in:
spx
2011-03-08 19:39:04 +00:00
parent f19e76e6ec
commit 8ddc383ed1
3 changed files with 208 additions and 86 deletions

View File

@ -46,6 +46,7 @@
};
class CConfigParser;
class ImageCache;
class CTintedImage
{
@ -84,6 +85,9 @@ public:
void DisposeImage();
void LoadImage(const std::wstring& imageName, bool bLoadAlways);
static Gdiplus::PixelFormat AdjustNonAlphaPixelFormat(Gdiplus::Bitmap* bitmap)
{ return (bitmap->GetPixelFormat() == PixelFormat24bppRGB) ? PixelFormat24bppRGB : PixelFormat32bppPARGB; }
protected:
enum CROPMODE
{
@ -98,7 +102,7 @@ protected:
void ApplyTint();
void ApplyTransform();
static bool LoadImageFromFileHandle(HANDLE fileHandle, Gdiplus::Bitmap** pBitmap, HGLOBAL* phBuffer);
Gdiplus::Bitmap* LoadImageFromFileHandle(HANDLE fileHandle, DWORD fileSize, ImageCache** ppCache);
static Gdiplus::Bitmap* TurnGreyscale(Gdiplus::Bitmap* source);
static bool CompareColorMatrix(const Gdiplus::ColorMatrix* a, const Gdiplus::ColorMatrix* b);
@ -106,9 +110,6 @@ protected:
Gdiplus::Bitmap* m_Bitmap; // The bitmap
Gdiplus::Bitmap* m_BitmapTint; // The tinted bitmap
HGLOBAL m_hBuffer;
FILETIME m_Modified;
const std::wstring m_ConfigName;
const WCHAR** m_ConfigArray;
const bool m_DisableTransform;
@ -124,6 +125,8 @@ protected:
Gdiplus::RotateFlipType m_Flip;
Gdiplus::REAL m_Rotate;
std::wstring m_CacheKey;
static const Gdiplus::ColorMatrix c_GreyScaleMatrix;
static const Gdiplus::ColorMatrix c_IdentifyMatrix;