2010-11-27 19:53:23 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2010 Kimmo Pekkola, MattKing, spx
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __TINTEDIMAGE_H__
|
|
|
|
#define __TINTEDIMAGE_H__
|
|
|
|
|
|
|
|
#include "Meter.h"
|
|
|
|
#include "MeterWindow.h"
|
|
|
|
|
|
|
|
class CTintedImage
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CTintedImage(bool disableTransform = false);
|
|
|
|
virtual ~CTintedImage();
|
|
|
|
|
|
|
|
void SetConfigAttributes(const WCHAR* name, const WCHAR* prefix);
|
|
|
|
void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
|
|
|
|
|
|
|
bool IsLoaded() { return (m_Bitmap != NULL); }
|
|
|
|
bool IsTinted() { return (m_BitmapTint != NULL); }
|
2010-12-04 15:07:28 +00:00
|
|
|
bool IsConfigsChanged() { return m_NeedsCrop || m_NeedsTinting || m_NeedsTransform; }
|
|
|
|
void ClearConfigFlags() { m_NeedsCrop = m_NeedsTinting = m_NeedsTransform = false; }
|
2010-11-27 19:53:23 +00:00
|
|
|
|
|
|
|
Gdiplus::Bitmap* GetOriginalImage() { return m_Bitmap; }
|
|
|
|
Gdiplus::Bitmap* GetTintedImage() { return m_BitmapTint; }
|
|
|
|
Gdiplus::Bitmap* GetImage() { return (m_BitmapTint) ? m_BitmapTint : m_Bitmap; }
|
|
|
|
|
|
|
|
void DisposeImage();
|
|
|
|
void LoadImage(const std::wstring& imageName, bool bLoadAlways);
|
|
|
|
|
|
|
|
protected:
|
2010-12-06 08:59:55 +00:00
|
|
|
enum CROPMODE
|
|
|
|
{
|
|
|
|
CROPMODE_TL = 1,
|
|
|
|
CROPMODE_TR,
|
|
|
|
CROPMODE_BR,
|
|
|
|
CROPMODE_BL,
|
|
|
|
CROPMODE_C
|
|
|
|
};
|
|
|
|
|
2010-12-04 15:07:28 +00:00
|
|
|
void ApplyCrop();
|
2010-11-27 19:53:23 +00:00
|
|
|
void ApplyTint();
|
|
|
|
void ApplyTransform();
|
|
|
|
|
|
|
|
static Gdiplus::Bitmap* TurnGreyscale(Gdiplus::Bitmap* source);
|
|
|
|
static bool CompareColorMatrix(const Gdiplus::ColorMatrix& a, const Gdiplus::ColorMatrix& b);
|
|
|
|
|
|
|
|
Gdiplus::Bitmap* m_Bitmap; // The bitmap
|
|
|
|
Gdiplus::Bitmap* m_BitmapTint; // The tinted bitmap
|
|
|
|
|
|
|
|
HGLOBAL m_hBuffer;
|
|
|
|
FILETIME m_Modified;
|
|
|
|
|
|
|
|
std::wstring m_ConfigName;
|
2010-12-04 15:07:28 +00:00
|
|
|
std::wstring m_ConfigImageCrop;
|
2010-11-27 19:53:23 +00:00
|
|
|
std::wstring m_ConfigGreyscale;
|
|
|
|
std::wstring m_ConfigImageTint;
|
|
|
|
std::wstring m_ConfigImageAlpha;
|
|
|
|
std::wstring m_ConfigColorMatrix1;
|
|
|
|
std::wstring m_ConfigColorMatrix2;
|
|
|
|
std::wstring m_ConfigColorMatrix3;
|
|
|
|
std::wstring m_ConfigColorMatrix4;
|
|
|
|
std::wstring m_ConfigColorMatrix5;
|
|
|
|
std::wstring m_ConfigImageFlip;
|
|
|
|
std::wstring m_ConfigImageRotate;
|
|
|
|
|
|
|
|
const bool m_DisableTransform;
|
|
|
|
|
2010-12-04 15:07:28 +00:00
|
|
|
bool m_NeedsCrop;
|
2010-11-27 19:53:23 +00:00
|
|
|
bool m_NeedsTinting;
|
|
|
|
bool m_NeedsTransform;
|
|
|
|
|
2010-12-04 15:07:28 +00:00
|
|
|
Gdiplus::Rect m_Crop;
|
2010-12-05 15:34:37 +00:00
|
|
|
CROPMODE m_CropMode;
|
2010-11-27 19:53:23 +00:00
|
|
|
bool m_GreyScale;
|
|
|
|
Gdiplus::ColorMatrix m_ColorMatrix;
|
|
|
|
Gdiplus::RotateFlipType m_Flip;
|
|
|
|
Gdiplus::REAL m_Rotate;
|
|
|
|
|
|
|
|
static const Gdiplus::ColorMatrix c_GreyScaleMatrix;
|
|
|
|
static const Gdiplus::ColorMatrix c_IdentifyMatrix;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|