Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gdiplusimageattributes.h « gdiplus « include « w32api « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0f7db98b26122dc28b7cdde14c7237c68517f0fe (plain)
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
228
229
230
231
232
233
234
235
236
/*
 * gdiplusimageattributes.h
 *
 * GDI+ ImageAttributes class
 *
 * This file is part of the w32api package.
 *
 * Contributors:
 *   Created by Markus Koenig <markus@stber-koenig.de>
 *
 * THIS SOFTWARE IS NOT COPYRIGHTED
 *
 * This source code is offered for use in the public domain. You may
 * use, modify or distribute it freely.
 *
 * This code is distributed in the hope that it will be useful but
 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
 * DISCLAIMED. This includes but is not limited to warranties of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 */

#ifndef __GDIPLUS_IMAGEATTRIBUTES_H
#define __GDIPLUS_IMAGEATTRIBUTES_H
#if __GNUC__ >=3
#pragma GCC system_header
#endif

#ifndef __cplusplus
#error "A C++ compiler is required to include gdiplusimageattributes.h."
#endif

class ImageAttributes: public GdiplusBase
{
	friend class Graphics;
	friend class TextureBrush;

public:
	ImageAttributes(): nativeImageAttributes(NULL), lastStatus(Ok)
	{
		lastStatus = DllExports::GdipCreateImageAttributes(
				&nativeImageAttributes);
	}
	~ImageAttributes()
	{
		DllExports::GdipDisposeImageAttributes(nativeImageAttributes);
	}
	ImageAttributes* Clone() const
	{
		GpImageAttributes *cloneImageAttributes = NULL;
		Status status = updateStatus(DllExports::GdipCloneImageAttributes(
				nativeImageAttributes, &cloneImageAttributes));
		if (status == Ok) {
			ImageAttributes *result = new ImageAttributes(
					cloneImageAttributes, lastStatus);
			if (!result) {
				DllExports::GdipDisposeImageAttributes(cloneImageAttributes);
				lastStatus = OutOfMemory;
			}
			return result;
		} else {
			return NULL;
		}
	}

	Status ClearBrushRemapTable()
	{
		return updateStatus(DllExports::GdipSetImageAttributesRemapTable(
				nativeImageAttributes, ColorAdjustTypeBrush,
				FALSE, 0, NULL));
	}
	Status ClearColorKey(ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesColorKeys(
				nativeImageAttributes, type, FALSE, 0, 0));
	}
	Status ClearColorMatrices(ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesColorMatrix(
				nativeImageAttributes, type, FALSE,
				NULL, NULL, ColorMatrixFlagsDefault));
	}
	Status ClearColorMatrix(ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesColorMatrix(
				nativeImageAttributes, type, FALSE,
				NULL, NULL, ColorMatrixFlagsDefault));
	}
	Status ClearGamma(ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesGamma(
				nativeImageAttributes, type, FALSE, 1.0f));
	}
	Status ClearNoOp(ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesNoOp(
				nativeImageAttributes, type, FALSE));
	}
	Status ClearOutputChannel(ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesOutputChannel(
				nativeImageAttributes, type, FALSE,
				ColorChannelFlagsC));
	}
	Status ClearOutputChannelColorProfile(
			ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesOutputChannelColorProfile(
				nativeImageAttributes, type, FALSE, NULL));
	}
	Status ClearRemapTable(ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesRemapTable(
				nativeImageAttributes, type, FALSE, 0, NULL));
	}
	Status ClearThreshold(ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesThreshold(
				nativeImageAttributes, type, FALSE, 0.0));
	}
	Status GetAdjustedPalette(ColorPalette *colorPalette,
			ColorAdjustType type) const
	{
		return updateStatus(DllExports::GdipGetImageAttributesAdjustedPalette(
				nativeImageAttributes, colorPalette, type));
	}
	Status GetLastStatus() const
	{
		Status result = lastStatus;
		lastStatus = Ok;
		return result;
	}
	Status Reset(ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipResetImageAttributes(
				nativeImageAttributes, type));
	}
	Status SetBrushRemapTable(UINT mapSize, ColorMap *map)
	{
		return updateStatus(DllExports::GdipSetImageAttributesRemapTable(
				nativeImageAttributes, ColorAdjustTypeBrush,
				TRUE, mapSize, map));
	}
	Status SetColorKey(const Color& colorLow, const Color& colorHigh,
			ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesColorKeys(
				nativeImageAttributes, type, TRUE,
				colorLow.GetValue(), colorHigh.GetValue()));
	}
	Status SetColorMatrices(const ColorMatrix *colorMatrix,
			const ColorMatrix *grayMatrix,
			ColorMatrixFlags mode = ColorMatrixFlagsDefault,
			ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesColorMatrix(
				nativeImageAttributes, type, TRUE,
				colorMatrix, grayMatrix, mode));
	}
	Status SetColorMatrix(const ColorMatrix *colorMatrix,
			ColorMatrixFlags mode = ColorMatrixFlagsDefault,
			ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesColorMatrix(
				nativeImageAttributes, type, TRUE,
				colorMatrix, NULL, mode));
	}
	Status SetGamma(REAL gamma,
			ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesGamma(
				nativeImageAttributes, type, TRUE, gamma));
	}
	Status SetNoOp(ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesNoOp(
				nativeImageAttributes, type, TRUE));
	}
	Status SetOutputChannel(ColorChannelFlags channelFlags,
			ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesOutputChannel(
				nativeImageAttributes, type, TRUE,
				channelFlags));
	}
	Status SetOutputChannelColorProfile(const WCHAR *colorProfileFilename,
			ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesOutputChannelColorProfile(
				nativeImageAttributes, type, TRUE,
				colorProfileFilename));
	}
	Status SetRemapTable(UINT mapSize, const ColorMap *map,
			ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesRemapTable(
				nativeImageAttributes, type, TRUE,
				mapSize, map));
	}
	Status SetThreshold(REAL threshold,
			ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesThreshold(
				nativeImageAttributes, type, TRUE, threshold));
	}
	Status SetToIdentity(ColorAdjustType type = ColorAdjustTypeDefault)
	{
		return updateStatus(DllExports::GdipSetImageAttributesToIdentity(
				nativeImageAttributes, type));
	}
	Status SetWrapMode(WrapMode wrap, const Color& color = Color(),
			BOOL clamp = FALSE)
	{
		return updateStatus(DllExports::GdipSetImageAttributesWrapMode(
				nativeImageAttributes, wrap,
				color.GetValue(), clamp));
	}

private:
	ImageAttributes(GpImageAttributes *imageAttributes, Status status):
		nativeImageAttributes(imageAttributes), lastStatus(status) {}
	ImageAttributes(const ImageAttributes&);
	ImageAttributes& operator=(const ImageAttributes&);

	Status updateStatus(Status newStatus) const
	{
		if (newStatus != Ok) lastStatus = newStatus;
		return newStatus;
	}

	GpImageAttributes *nativeImageAttributes;
	mutable Status lastStatus;
};


#endif /* __GDIPLUS_IMAGEATTRIBUTES_H */