aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_devices/image.h
blob: 4787132493f6a98c3ba0ccad14af7c46c387d8d3 (plain) (blame)
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#ifndef _NULLSOFT_WINAMP_ML_DEVICES_IMAGE_HEADER
#define _NULLSOFT_WINAMP_ML_DEVICES_IMAGE_HEADER

#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif

#define IMAGE_FILTER_NORMAL		0x00000000
#define IMAGE_FILTER_GRAYSCALE	0x00010000
#define IMAGE_FILTER_BLEND		0x00020000
#define IMAGE_FILTER_MASK		0xFFFF0000


typedef struct ImageInfo
{
	unsigned int width;
	unsigned int height;
	const wchar_t *path;
} ImageInfo;


HBITMAP
Image_Load(const wchar_t *path,
		   unsigned int type, 
		   unsigned int flags,
		   int width,
		   int height);

HBITMAP
Image_LoadEx(HINSTANCE instance, 
		   const wchar_t *path,
		   unsigned int type, 
		   unsigned int flags,
		   int width,
		   int height);

HBITMAP 
Image_LoadSkinned(const wchar_t *path,
				  unsigned int type,
				  unsigned int flags, //ISF_XXX + IMAGE_FILTER_XXX
				  int width,
				  int height,
				  COLORREF backColor, 
				  COLORREF frontColor,
				  COLORREF blendColor); // only valid if IMAGE_FILTER_BLEND set

HBITMAP 
Image_LoadSkinnedEx(HINSTANCE instance, 
				  const wchar_t *path,
				  unsigned int type,
				  unsigned int flags, //ISF_XXX + IMAGE_FILTER_XXX
				  int width,
				  int height,
				  COLORREF backColor, 
				  COLORREF frontColor,
				  COLORREF blendColor); // only valid if IMAGE_FILTER_BLEND set

BOOL
Image_FilterEx(void *pixelData,
			   long width,
			   long height,
			   unsigned short bpp, 
			   unsigned int flags, 
			   COLORREF backColor, 
			   COLORREF frontColor, 
			   COLORREF blendColor);

BOOL
Image_Filter(HBITMAP bitmap, 
			 unsigned int flags, 
			 COLORREF backColor, 
			 COLORREF frontColor, 
			 COLORREF blendColor);

BOOL
Image_BlendEx(void *pixelData,
			  long width,
			  long height,
			  unsigned short bpp,
			  COLORREF blendColor);
BOOL
Image_Blend(HBITMAP bitmap,
			COLORREF blendColor);

HBITMAP
Image_DuplicateDib(HBITMAP source);

BOOL 
Image_ColorOver(HBITMAP hbmp, 
				const RECT *prcPart, 
				BOOL premult, 
				COLORREF rgb);

BOOL 
Image_ColorOverEx(unsigned char *pPixels, 
				  int bitmapCX, 
				  int bitmapCY, 
				  long x, 
				  long y, 
				  long cx, 
				  long cy, 
				  unsigned short bpp, 
				  BOOL premult, 
				  COLORREF rgb);

BOOL 
Image_Premultiply(HBITMAP hbmp, 
				  const RECT *prcPart);

BOOL 
Image_PremultiplyEx(unsigned char *pPixels, 
					int bitmapCX, 
					int bitmapCY, 
					long x, 
					long y, 
					long cx, 
					long cy, 
					unsigned short bpp);

BOOL 
Image_Demultiply(HBITMAP hbmp, 
				  const RECT *prcPart);

BOOL 
Image_DemultiplyEx(unsigned char *pPixels, 
					int bitmapCX, 
					int bitmapCY, 
					long x, 
					long y, 
					long cx, 
					long cy, 
					unsigned short bpp);

BOOL 
Image_Saturate(HBITMAP hbmp, 
			   const RECT *prcPart, 
			   int n, 
			   BOOL fScale);

BOOL 
Image_SaturateEx(unsigned char *pPixels, 
				 int bitmapCX, 
				 int bitmapCY, 
				 long x, 
				 long y, 
				 long cx, 
				 long cy, 
				 unsigned short bpp, 
				 int n, 
				 BOOL fScale);

BOOL 
Image_AdjustAlpha(HBITMAP hbmp, 
				  const RECT *prcPart, 
				  int n, 
				  BOOL fScale);

BOOL 
Image_AdjustAlphaEx(unsigned char *pPixels, 
					int bitmapCX, 
					int bitmapCY, 
					long x, 
					long y, 
					long cx, 
					long cy, 
					unsigned short bpp, 
					int n, 
					BOOL fScale);

BOOL 
Image_AdjustSaturationAlpha(HBITMAP hbmp, 
							const RECT *prcPart, 
							int nSaturation, 
							int nAlpha);

BOOL 
Image_AdjustSaturationAlphaEx(unsigned char *pPixels, 
							  int bitmapCX, 
							  int bitmapCY, 
							  long x, 
							  long y, 
							  long cx, 
							  long cy, 
							  unsigned short bpp, 
							  int nSaturation, 
							  int nAlpha);

BOOL
Image_FillBorder(HDC targetDC, 
				 const RECT *targetRect, 
				 HDC sourceDC, 
				 const RECT *sourceRect, 
				 BOOL fillCenter, 
				 BYTE alphaConstant);


const ImageInfo *
Image_GetBestFit(const ImageInfo *images, 
				 size_t count, 
				 unsigned int width, 
				 unsigned int height);

typedef enum AlphaBlendFlags
{
	AlphaBlend_Normal = 0,
	AlphaBlend_ScaleSource = (1 << 0),
	AlphaBlend_AlignLeft = (1 << 1),
	AlphaBlend_AlignRight = (1 << 2),
	AlphaBlend_AlignCenter = 0,
	AlphaBlend_AlignTop = (1 << 3),
	AlphaBlend_AlignBottom = (1 << 4),
	AlphaBlend_AlignVCenter = 0,
}AlphaBlendFlags;
DEFINE_ENUM_FLAG_OPERATORS(AlphaBlendFlags);

BOOL
Image_AlphaBlend(HDC targetDC, 
				 const RECT *targetRect,
				 HDC sourceDC, 
				 const RECT *sourceRect, 
				 BYTE sourceAlpha, 
				 HBITMAP sourceBitmap, 
				 const RECT *paintRect, 
				 AlphaBlendFlags flags, 
				 RECT *rectOut);

#endif //_NULLSOFT_WINAMP_ML_DEVICES_IMAGE_HEADER