62 *
ppv = &
This->IWICPalette_iface;
79 TRACE(
"(%p) refcount=%u\n", iface,
ref);
89 TRACE(
"(%p) refcount=%u\n", iface,
ref);
93 This->lock.DebugInfo->Spare[0] = 0;
109 if (!entries)
return NULL;
111 for (
i = 0;
i < 16;
i++)
113 entries[
i] = 0xff000000;
114 entries[
i] |= (
i<<20) | (
i<<16) | (
i<<12) | (
i<<8) | (
i<<4) |
i;
126 if (!entries)
return NULL;
128 for (
i = 0;
i < 256;
i++)
130 entries[
i] = 0xff000000;
131 entries[
i] |= (
i<<16) | (
i<<8) |
i;
141 *
count = add_transparent ? 17 : 16;
143 if (!entries)
return NULL;
145 for (
i = 0;
i < 8;
i++)
147 entries[
i] = 0xff000000;
148 if (
i & 1) entries[
i] |= 0xff;
149 if (
i & 2) entries[
i] |= 0xff00;
150 if (
i & 4) entries[
i] |= 0xff0000;
153 for (
i = 8;
i < 16;
i++)
155 static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
156 0x000080, 0x808000, 0x800080, 0x008080 };
157 entries[
i] = 0xff000000;
158 entries[
i] |= halftone[
i-8];
172 *
count = add_transparent ? 29 : 28;
174 if (!entries)
return NULL;
176 for (
i = 0;
i < 27;
i++)
178 static const BYTE halftone_values[4] = { 0x00,0x80,0xff };
179 entries[
i] = 0xff000000;
180 entries[
i] |= halftone_values[
i%3];
181 entries[
i] |= halftone_values[(
i/3)%3] << 8;
182 entries[
i] |= halftone_values[(
i/9)%3] << 16;
185 entries[
i++] = 0xffc0c0c0;
197 *
count = add_transparent ? 73 : 72;
199 if (!entries)
return NULL;
201 for (
i = 0;
i < 64;
i++)
203 static const BYTE halftone_values[4] = { 0x00,0x55,0xaa,0xff };
204 entries[
i] = 0xff000000;
205 entries[
i] |= halftone_values[
i%4];
206 entries[
i] |= halftone_values[(
i/4)%4] << 8;
207 entries[
i] |= halftone_values[(
i/16)%4] << 16;
210 for (
i = 64;
i < 72;
i++)
212 static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
213 0x000080, 0x808000, 0x800080, 0x008080 };
214 entries[
i] = 0xff000000;
215 entries[
i] |= halftone[
i-64];
229 *
count = add_transparent ? 127 : 126;
231 if (!entries)
return NULL;
233 for (
i = 0;
i < 125;
i++)
235 static const BYTE halftone_values[5] = { 0x00,0x40,0x80,0xbf,0xff };
236 entries[
i] = 0xff000000;
237 entries[
i] |= halftone_values[
i%5];
238 entries[
i] |= halftone_values[(
i/5)%5] << 8;
239 entries[
i] |= halftone_values[(
i/25)%5] << 16;
242 entries[
i++] = 0xffc0c0c0;
254 *
count = add_transparent ? 225 : 224;
256 if (!entries)
return NULL;
258 for (
i = 0;
i < 216;
i++)
260 static const BYTE halftone_values[6] = { 0x00,0x33,0x66,0x99,0xcc,0xff };
261 entries[
i] = 0xff000000;
262 entries[
i] |= halftone_values[
i%6];
263 entries[
i] |= halftone_values[(
i/6)%6] << 8;
264 entries[
i] |= halftone_values[(
i/36)%6] << 16;
267 for (
i = 216;
i < 224;
i++)
269 static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
270 0x000080, 0x808000, 0x800080, 0x008080 };
271 entries[
i] = 0xff000000;
272 entries[
i] |= halftone[
i-216];
286 *
count = add_transparent ? 253 : 252;
288 if (!entries)
return NULL;
290 for (
i = 0;
i < 252;
i++)
292 static const BYTE halftone_values_rb[6] = { 0x00,0x33,0x66,0x99,0xcc,0xff };
293 static const BYTE halftone_values_g[7] = { 0x00,0x2b,0x55,0x80,0xaa,0xd5,0xff };
294 entries[
i] = 0xff000000;
295 entries[
i] |= halftone_values_rb[
i%6];
296 entries[
i] |= halftone_values_g[(
i/6)%7] << 8;
297 entries[
i] |= halftone_values_rb[(
i/42)%6] << 16;
313 if (!entries)
return NULL;
315 for (
i = 0;
i < 256;
i++)
317 static const BYTE halftone_values_b[4] = { 0x00,0x55,0xaa,0xff };
318 static const BYTE halftone_values_gr[8] = { 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff };
319 entries[
i] = 0xff000000;
320 entries[
i] |= halftone_values_b[
i%4];
321 entries[
i] |= halftone_values_gr[(
i/4)%8] << 8;
322 entries[
i] |= halftone_values_gr[(
i/32)%8] << 16;
338 TRACE(
"(%p,%u,%d)\n", iface,
type, add_transparent);
346 colors[0] = 0xff000000;
347 colors[1] = 0xffffffff;
354 colors[0] = 0xff000000;
355 colors[1] = 0xff555555;
356 colors[2] = 0xffaaaaaa;
357 colors[3] = 0xffffffff;
406 WARN(
"invalid palette type %u\n",
type);
412 This->colors = colors;
426 TRACE(
"(%p,%p,%u)\n", iface, pColors, colorCount);
442 This->colors = new_colors;
443 This->count = colorCount;
450#define R_COUNT (1 << 5)
451#define R_SHIFT (8 - 5)
454#define G_COUNT (1 << 6)
455#define G_SHIFT (8 - 6)
458#define B_COUNT (1 << 5)
459#define B_SHIFT (8 - 5)
478 int g_min,
int g_max,
int b_min,
int b_max)
480 unsigned int count = 0;
482 for (
r = r_min;
r <= r_max;
r++)
483 for (
g = g_min;
g <= g_max;
g++)
484 for (
b = b_min;
b <= b_max;
b++)
491 int g_min,
int g_max,
int b_min,
int b_max)
493 unsigned long long r_sum = 0, g_sum = 0, b_sum = 0;
494 unsigned int tmp,
count = 0;
497 for (
r = r_min;
r <= r_max;
r++)
498 for (
g = g_min;
g <= g_max;
g++)
499 for (
b = b_min;
b <= b_max;
b++)
501 if (!(tmp =
h->data[
r][
g][
b]))
continue;
510 ((r_sum + (
count / 2)) /
count) << 16 | 0xff000000;
528 unsigned int tmp,
sum = 0;
539 for (
i =
b->r_min; i <= b->r_max;
i++)
541 for (
i =
b->r_max;
i >=
b->r_min;
i--)
543 for (
i =
b->g_min; i <= b->g_max;
i++)
545 for (
i =
b->g_max;
i >=
b->g_min;
i--)
547 for (
i =
b->b_min; i <= b->b_max;
i++)
549 for (
i =
b->b_max;
i >=
b->b_min;
i--)
558 int avg = (*
min + *
max) / 2;
610 struct box boxes[256];
630 while (numboxes <=
desired / 2)
633 b2 = &boxes[numboxes++];
639 b2 = &boxes[numboxes++];
643 for (
i = 0;
i < numboxes;
i++)
666 if (!
source || desired < 2 || desired > 256)
685 if (
hr !=
S_OK)
goto fail;
688 if (
hr !=
S_OK)
goto fail;
691 if (
hr !=
S_OK)
goto fail;
698 TRACE(
"actual number of colors: %u\n", actual_number_of_colors);
700 if (actual_number_of_colors)
702 if (add_transparent) colors[actual_number_of_colors++] = 0;
704 hr = IWICPalette_InitializeCustom(
palette, colors, actual_number_of_colors);
711 IWICBitmapLock_Release(
lock);
714 IWICBitmap_Release(rgb24_bitmap);
717 IWICImagingFactory_Release(
factory);
719 if (rgb24_source !=
source)
720 IWICBitmapSource_Release(rgb24_source);
756 This->colors = colors;
769 TRACE(
"(%p,%p)\n", iface, pePaletteType);
774 *pePaletteType =
This->type;
784 TRACE(
"(%p,%p)\n", iface, pcCount);
789 *pcCount =
This->count;
800 TRACE(
"(%p,%i,%p,%p)\n", iface, colorCount, pColors, pcActualColors);
806 if (
This->count < colorCount) colorCount =
This->count;
810 *pcActualColors = colorCount;
821 TRACE(
"(%p,%p)\n", iface, pfIsBlackWhite);
827 *pfIsBlackWhite =
TRUE;
829 *pfIsBlackWhite =
FALSE;
839 TRACE(
"(%p,%p)\n", iface, pfIsGrayscale);
850 *pfIsGrayscale =
TRUE;
853 *pfIsGrayscale =
FALSE;
865 TRACE(
"(%p,%p)\n", iface, pfHasAlpha);
873 if ((
This->colors[
i]&0xff000000) != 0xff000000)
912 This->lock.DebugInfo->Spare[0] = (
DWORD_PTR)(__FILE__
": PaletteImpl.lock");
#define InterlockedIncrement
#define InterlockedDecrement
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
#define HeapFree(x, y, z)
HRESULT WINAPI WICConvertBitmapSource(REFWICPixelFormatGUID dstFormat, IWICBitmapSource *pISrc, IWICBitmapSource **ppIDst)
static HRESULT WINAPI PaletteImpl_IsBlackWhite(IWICPalette *iface, BOOL *pfIsBlackWhite)
static HRESULT WINAPI PaletteImpl_GetType(IWICPalette *iface, WICBitmapPaletteType *pePaletteType)
static HRESULT WINAPI PaletteImpl_InitializeCustom(IWICPalette *iface, WICColor *pColors, UINT colorCount)
static HRESULT WINAPI PaletteImpl_QueryInterface(IWICPalette *iface, REFIID iid, void **ppv)
static unsigned int box_score(struct box *b)
HRESULT PaletteImpl_Create(IWICPalette **palette)
static WICColor * generate_halftone125_palette(UINT *count, BOOL add_transparent)
static HRESULT WINAPI PaletteImpl_GetColors(IWICPalette *iface, UINT colorCount, WICColor *pColors, UINT *pcActualColors)
static const IWICPaletteVtbl PaletteImpl_Vtbl
static ULONG WINAPI PaletteImpl_Release(IWICPalette *iface)
static HRESULT WINAPI PaletteImpl_IsGrayscale(IWICPalette *iface, BOOL *pfIsGrayscale)
static int median_cut(unsigned char *image, unsigned int width, unsigned int height, unsigned int stride, int desired, unsigned int *colors)
static void split_box(struct histogram *h, struct box *b1, struct box *b2)
static WICColor * generate_halftone8_palette(UINT *count, BOOL add_transparent)
static HRESULT WINAPI PaletteImpl_GetColorCount(IWICPalette *iface, UINT *pcCount)
static WICColor * generate_gray256_palette(UINT *count)
static HRESULT WINAPI PaletteImpl_InitializeFromPalette(IWICPalette *iface, IWICPalette *source)
static ULONG WINAPI PaletteImpl_AddRef(IWICPalette *iface)
static WICColor * generate_halftone256_palette(UINT *count, BOOL add_transparent)
static unsigned int box_count(struct histogram *h, struct box *b)
static WICColor * generate_gray16_palette(UINT *count)
static WICColor * generate_halftone252_palette(UINT *count, BOOL add_transparent)
static HRESULT WINAPI PaletteImpl_InitializeFromBitmap(IWICPalette *palette, IWICBitmapSource *source, UINT desired, BOOL add_transparent)
static HRESULT WINAPI PaletteImpl_HasAlpha(IWICPalette *iface, BOOL *pfHasAlpha)
static void shrink_box(struct histogram *h, struct box *b)
static WICColor * generate_halftone216_palette(UINT *count, BOOL add_transparent)
static unsigned int box_color(struct histogram *h, struct box *b)
static struct box * find_box_max_count(struct box *b, int count)
static void set_avg(int *min, int *max)
static unsigned int histogram_count(struct histogram *h, int r_min, int r_max, int g_min, int g_max, int b_min, int b_max)
static PaletteImpl * impl_from_IWICPalette(IWICPalette *iface)
static unsigned int histogram_color(struct histogram *h, int r_min, int r_max, int g_min, int g_max, int b_min, int b_max)
static WICColor * generate_halftone64_palette(UINT *count, BOOL add_transparent)
static WICColor * generate_halftone27_palette(UINT *count, BOOL add_transparent)
static struct box * find_box_max_score(struct box *b, int count)
static HRESULT WINAPI PaletteImpl_InitializePredefined(IWICPalette *iface, WICBitmapPaletteType type, BOOL add_transparent)
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei GLenum type
GLint GLint GLint GLint GLint GLint y
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble r
GLint GLint GLsizei width
GLboolean GLboolean GLboolean b
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
HRESULT ImagingFactory_CreateInstance(REFIID iid, void **ppv)
#define memcpy(s1, s2, n)
static CRYPT_DATA_BLOB b2[]
static CRYPT_DATA_BLOB b1[]
#define IsEqualGUID(rguid1, rguid2)
#define IsEqualIID(riid1, riid2)
static int sum(int x_, int y_)
WICBitmapPaletteType type
IWICPalette IWICPalette_iface
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
#define CONTAINING_RECORD(address, type, field)
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
@ WICBitmapPaletteTypeFixedHalftone256
@ WICBitmapPaletteTypeCustom
@ WICBitmapPaletteTypeFixedGray256
@ WICBitmapPaletteTypeFixedBW
@ WICBitmapPaletteTypeFixedHalftone64
@ WICBitmapPaletteTypeFixedGray16
@ WICBitmapPaletteTypeFixedGray4
@ WICBitmapPaletteTypeFixedHalftone216
@ WICBitmapPaletteTypeFixedHalftone27
@ WICBitmapPaletteTypeFixedHalftone125
@ WICBitmapPaletteTypeFixedHalftone8
@ WICBitmapPaletteTypeFixedHalftone252