forked from rainmeter/rainmeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeneralImage.h
97 lines (79 loc) · 2.69 KB
/
GeneralImage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* Copyright (C) 2018 Rainmeter Project Developers
*
* This Source Code Form is subject to the terms of the GNU General Public
* License; either version 2 of the License, or (at your option) any later
* version. If a copy of the GPL was not distributed with this file, You can
* obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */
#ifndef __GENERALIMAGE_H__
#define __GENERALIMAGE_H__
#include "../Common/Gfx/D2DBitmap.h"
#include "../Common/Gfx/Util/D2DEffectStream.h"
#include <string>
#include "Skin.h"
#include "ImageCache.h"
#include "ImageOptions.h"
/*
** Helper macro to define an array of option names. A prefix must be given.
**
*/
#define GeneralImageHelper_DefineOptionArray(name, prefix) \
const WCHAR* (name)[GeneralImage::OptionCount] = { \
prefix L"ImageCrop", \
prefix L"Greyscale", \
prefix L"ImageTint", \
prefix L"ImageAlpha", \
prefix L"ColorMatrix1", \
prefix L"ColorMatrix2", \
prefix L"ColorMatrix3", \
prefix L"ColorMatrix4", \
prefix L"ColorMatrix5", \
prefix L"ImageFlip", \
prefix L"ImageRotate", \
prefix L"UseExifOrientation", \
prefix L"ImagePath" \
};
class GeneralImage
{
public:
enum OptionIndex
{
OptionIndexImageCrop = 0,
OptionIndexGreyscale,
OptionIndexImageTint,
OptionIndexImageAlpha,
OptionIndexColorMatrix1,
OptionIndexColorMatrix2,
OptionIndexColorMatrix3,
OptionIndexColorMatrix4,
OptionIndexColorMatrix5,
OptionIndexImageFlip,
OptionIndexImageRotate,
OptionIndexUseExifOrientation,
OptionIndexImagePath,
OptionCount
};
GeneralImage(const WCHAR* name = L"ImageName", const WCHAR** optionArray = c_DefaultOptionArray,
bool disableTransform = false, Skin* skin = nullptr);
~GeneralImage();
void DisposeImage();
bool IsLoaded() { return m_BitmapProcessed != nullptr; }
Gfx::D2DBitmap* GetImage() { return m_BitmapProcessed ? m_BitmapProcessed->GetBitmap() : nullptr; }
void ReadOptions(ConfigParser& parser, const WCHAR* section, const WCHAR* imagePath = L"");
bool LoadImage(const std::wstring& imageName);
private:
D2D1_SIZE_F ApplyCrop(Gfx::Util::D2DEffectStream* stream, Gfx::D2DBitmap* bitmap) const;
void ApplyTransforms();
ImageCacheHandle* m_Bitmap;
ImageCacheHandle* m_BitmapProcessed;
Skin* m_Skin;
const WCHAR* m_Name;
const WCHAR** m_OptionArray;
const bool m_DisableTransform;
ImageOptions m_Options;
std::wstring m_Path;
static bool CompareColorMatrix(const D2D1_MATRIX_5X4_F& a, const D2D1_MATRIX_5X4_F& b);
static const D2D1_MATRIX_5X4_F c_GreyScaleMatrix;
static const D2D1_MATRIX_5X4_F c_IdentityMatrix;
static const WCHAR* c_DefaultOptionArray[OptionCount];
};
#endif