60 *
ppv = &
This->IWICPalette_iface;
77 TRACE(
"(%p) refcount=%lu\n", iface,
ref);
87 TRACE(
"(%p) refcount=%lu\n", iface,
ref);
91 This->lock.DebugInfo->Spare[0] = 0;
107 if (!entries)
return NULL;
109 for (
i = 0;
i < 16;
i++)
111 entries[
i] = 0xff000000;
112 entries[
i] |= (
i<<20) | (
i<<16) | (
i<<12) | (
i<<8) | (
i<<4) |
i;
124 if (!entries)
return NULL;
126 for (
i = 0;
i < 256;
i++)
128 entries[
i] = 0xff000000;
129 entries[
i] |= (
i<<16) | (
i<<8) |
i;
139 *
count = add_transparent ? 17 : 16;
141 if (!entries)
return NULL;
143 for (
i = 0;
i < 8;
i++)
145 entries[
i] = 0xff000000;
146 if (
i & 1) entries[
i] |= 0xff;
147 if (
i & 2) entries[
i] |= 0xff00;
148 if (
i & 4) entries[
i] |= 0xff0000;
151 for (
i = 8;
i < 16;
i++)
153 static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
154 0x000080, 0x808000, 0x800080, 0x008080 };
155 entries[
i] = 0xff000000;
156 entries[
i] |= halftone[
i-8];
170 *
count = add_transparent ? 29 : 28;
172 if (!entries)
return NULL;
174 for (
i = 0;
i < 27;
i++)
176 static const BYTE halftone_values[4] = { 0x00,0x80,0xff };
177 entries[
i] = 0xff000000;
178 entries[
i] |= halftone_values[
i%3];
179 entries[
i] |= halftone_values[(
i/3)%3] << 8;
180 entries[
i] |= halftone_values[(
i/9)%3] << 16;
183 entries[
i++] = 0xffc0c0c0;
195 *
count = add_transparent ? 73 : 72;
197 if (!entries)
return NULL;
199 for (
i = 0;
i < 64;
i++)
201 static const BYTE halftone_values[4] = { 0x00,0x55,0xaa,0xff };
202 entries[
i] = 0xff000000;
203 entries[
i] |= halftone_values[
i%4];
204 entries[
i] |= halftone_values[(
i/4)%4] << 8;
205 entries[
i] |= halftone_values[(
i/16)%4] << 16;
208 for (
i = 64;
i < 72;
i++)
210 static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
211 0x000080, 0x808000, 0x800080, 0x008080 };
212 entries[
i] = 0xff000000;
213 entries[
i] |= halftone[
i-64];
227 *
count = add_transparent ? 127 : 126;
229 if (!entries)
return NULL;
231 for (
i = 0;
i < 125;
i++)
233 static const BYTE halftone_values[5] = { 0x00,0x40,0x80,0xbf,0xff };
234 entries[
i] = 0xff000000;
235 entries[
i] |= halftone_values[
i%5];
236 entries[
i] |= halftone_values[(
i/5)%5] << 8;
237 entries[
i] |= halftone_values[(
i/25)%5] << 16;
240 entries[
i++] = 0xffc0c0c0;
252 *
count = add_transparent ? 225 : 224;
254 if (!entries)
return NULL;
256 for (
i = 0;
i < 216;
i++)
258 static const BYTE halftone_values[6] = { 0x00,0x33,0x66,0x99,0xcc,0xff };
259 entries[
i] = 0xff000000;
260 entries[
i] |= halftone_values[
i%6];
261 entries[
i] |= halftone_values[(
i/6)%6] << 8;
262 entries[
i] |= halftone_values[(
i/36)%6] << 16;
265 for (
i = 216;
i < 224;
i++)
267 static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
268 0x000080, 0x808000, 0x800080, 0x008080 };
269 entries[
i] = 0xff000000;
270 entries[
i] |= halftone[
i-216];
284 *
count = add_transparent ? 253 : 252;
286 if (!entries)
return NULL;
288 for (
i = 0;
i < 252;
i++)
290 static const BYTE halftone_values_rb[6] = { 0x00,0x33,0x66,0x99,0xcc,0xff };
291 static const BYTE halftone_values_g[7] = { 0x00,0x2b,0x55,0x80,0xaa,0xd5,0xff };
292 entries[
i] = 0xff000000;
293 entries[
i] |= halftone_values_rb[
i%6];
294 entries[
i] |= halftone_values_g[(
i/6)%7] << 8;
295 entries[
i] |= halftone_values_rb[(
i/42)%6] << 16;
311 if (!entries)
return NULL;
313 for (
i = 0;
i < 256;
i++)
315 static const BYTE halftone_values_b[4] = { 0x00,0x55,0xaa,0xff };
316 static const BYTE halftone_values_gr[8] = { 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff };
317 entries[
i] = 0xff000000;
318 entries[
i] |= halftone_values_b[
i%4];
319 entries[
i] |= halftone_values_gr[(
i/4)%8] << 8;
320 entries[
i] |= halftone_values_gr[(
i/32)%8] << 16;
336 TRACE(
"(%p,%u,%d)\n", iface,
type, add_transparent);
344 colors[0] = 0xff000000;
345 colors[1] = 0xffffffff;
352 colors[0] = 0xff000000;
353 colors[1] = 0xff555555;
354 colors[2] = 0xffaaaaaa;
355 colors[3] = 0xffffffff;
404 WARN(
"invalid palette type %u\n",
type);
410 This->colors = colors;
424 TRACE(
"(%p,%p,%u)\n", iface, pColors, colorCount);
440 This->colors = new_colors;
441 This->count = colorCount;
448#define R_COUNT (1 << 5)
449#define R_SHIFT (8 - 5)
452#define G_COUNT (1 << 6)
453#define G_SHIFT (8 - 6)
456#define B_COUNT (1 << 5)
457#define B_SHIFT (8 - 5)
476 int g_min,
int g_max,
int b_min,
int b_max)
478 unsigned int count = 0;
480 for (
r = r_min;
r <= r_max;
r++)
481 for (
g = g_min;
g <= g_max;
g++)
482 for (
b = b_min;
b <= b_max;
b++)
489 int g_min,
int g_max,
int b_min,
int b_max)
491 unsigned long long r_sum = 0, g_sum = 0, b_sum = 0;
492 unsigned int tmp,
count = 0;
495 for (
r = r_min;
r <= r_max;
r++)
496 for (
g = g_min;
g <= g_max;
g++)
497 for (
b = b_min;
b <= b_max;
b++)
499 if (!(tmp =
h->data[
r][
g][
b]))
continue;
508 ((r_sum + (
count / 2)) /
count) << 16 | 0xff000000;
526 unsigned int tmp,
sum = 0;
537 for (
i =
b->r_min; i <= b->r_max;
i++)
539 for (
i =
b->r_max;
i >=
b->r_min;
i--)
541 for (
i =
b->g_min; i <= b->g_max;
i++)
543 for (
i =
b->g_max;
i >=
b->g_min;
i--)
545 for (
i =
b->b_min; i <= b->b_max;
i++)
547 for (
i =
b->b_max;
i >=
b->b_min;
i--)
556 int avg = (*
min + *
max) / 2;
608 struct box boxes[256];
628 while (numboxes <=
desired / 2)
631 b2 = &boxes[numboxes++];
637 b2 = &boxes[numboxes++];
641 for (
i = 0;
i < numboxes;
i++)
664 if (!
source || desired < 2 || desired > 256)
683 if (
hr !=
S_OK)
goto fail;
686 if (
hr !=
S_OK)
goto fail;
689 if (
hr !=
S_OK)
goto fail;
696 TRACE(
"actual number of colors: %u\n", actual_number_of_colors);
698 if (actual_number_of_colors)
700 if (add_transparent) colors[actual_number_of_colors++] = 0;
702 hr = IWICPalette_InitializeCustom(
palette, colors, actual_number_of_colors);
709 IWICBitmapLock_Release(
lock);
712 IWICBitmap_Release(rgb24_bitmap);
715 IWICImagingFactory_Release(
factory);
717 if (rgb24_source !=
source)
718 IWICBitmapSource_Release(rgb24_source);
754 This->colors = colors;
767 TRACE(
"(%p,%p)\n", iface, pePaletteType);
772 *pePaletteType =
This->type;
782 TRACE(
"(%p,%p)\n", iface, pcCount);
787 *pcCount =
This->count;
798 TRACE(
"(%p,%i,%p,%p)\n", iface, colorCount, pColors, pcActualColors);
804 if (
This->count < colorCount) colorCount =
This->count;
808 *pcActualColors = colorCount;
819 TRACE(
"(%p,%p)\n", iface, pfIsBlackWhite);
825 *pfIsBlackWhite =
TRUE;
827 *pfIsBlackWhite =
FALSE;
837 TRACE(
"(%p,%p)\n", iface, pfIsGrayscale);
848 *pfIsGrayscale =
TRUE;
851 *pfIsGrayscale =
FALSE;
863 TRACE(
"(%p,%p)\n", iface, pfHasAlpha);
871 if ((
This->colors[
i]&0xff000000) != 0xff000000)
914 This->lock.DebugInfo->Spare[0] = (
DWORD_PTR)(__FILE__
": PaletteImpl.lock");
#define InterlockedIncrement
#define InterlockedDecrement
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
HRESULT create_instance(const CLSID *clsid, const IID *iid, void **ppv)
BOOL WINAPI InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount, IN DWORD flags)
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 count
GLuint GLuint GLsizei GLenum type
GLint GLint GLint GLint GLint GLint y
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
#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
#define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO