ReactOS 0.4.16-dev-823-g9a093ec
converter.c
Go to the documentation of this file.
1/*
2 * Copyright 2009 Vincent Povirk
3 * Copyright 2016 Dmitry Timoshkov
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20#include <stdarg.h>
21#include <math.h>
22
23#define COBJMACROS
24
25#include "windef.h"
26#include "winbase.h"
27#include "objbase.h"
28
29#include "wincodecs_private.h"
30
31#include "wine/debug.h"
32
34
35struct FormatConverter;
36
62};
63
64typedef HRESULT (*copyfunc)(struct FormatConverter *This, const WICRect *prc,
65 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format);
66
72};
73
74typedef struct FormatConverter {
82 CRITICAL_SECTION lock; /* must be held when initialized */
84
85/* https://www.w3.org/Graphics/Color/srgb */
86static inline float to_sRGB_component(float f)
87{
88 if (f <= 0.0031308f) return 12.92f * f;
89 return 1.055f * powf(f, 1.0f/2.4f) - 0.055f;
90}
91
92#if 0 /* FIXME: enable once needed */
93static inline float from_sRGB_component(float f)
94{
95 if (f <= 0.04045f) return f / 12.92f;
96 return powf((f + 0.055f) / 1.055f, 2.4f);
97}
98
99static void from_sRGB(BYTE *bgr)
100{
101 float r, g, b;
102
103 r = bgr[2] / 255.0f;
104 g = bgr[1] / 255.0f;
105 b = bgr[0] / 255.0f;
106
107 r = from_sRGB_component(r);
108 g = from_sRGB_component(g);
109 b = from_sRGB_component(b);
110
111 bgr[2] = (BYTE)(r * 255.0f);
112 bgr[1] = (BYTE)(g * 255.0f);
113 bgr[0] = (BYTE)(b * 255.0f);
114}
115
116static void to_sRGB(BYTE *bgr)
117{
118 float r, g, b;
119
120 r = bgr[2] / 255.0f;
121 g = bgr[1] / 255.0f;
122 b = bgr[0] / 255.0f;
123
127
128 bgr[2] = (BYTE)(r * 255.0f);
129 bgr[1] = (BYTE)(g * 255.0f);
130 bgr[0] = (BYTE)(b * 255.0f);
131}
132#endif
133
135{
136 return CONTAINING_RECORD(iface, FormatConverter, IWICFormatConverter_iface);
137}
138
140 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
141{
142 switch (source_format)
143 {
146 if (prc)
147 {
148 HRESULT res;
149 INT x, y;
150 BYTE *srcdata;
151 UINT srcstride, srcdatasize;
152 const BYTE *srcrow;
153 const BYTE *srcbyte;
154 BYTE *dstrow;
155 DWORD *dstpixel;
156 WICColor colors[2];
158 UINT actualcolors;
159
161 if (FAILED(res)) return res;
162
163 if (source_format == format_1bppIndexed)
164 res = IWICBitmapSource_CopyPalette(This->source, palette);
165 else
166 res = IWICPalette_InitializePredefined(palette, WICBitmapPaletteTypeFixedBW, FALSE);
167
168 if (SUCCEEDED(res))
169 res = IWICPalette_GetColors(palette, 2, colors, &actualcolors);
170
171 IWICPalette_Release(palette);
172 if (FAILED(res)) return res;
173
174 srcstride = (prc->Width+7)/8;
175 srcdatasize = srcstride * prc->Height;
176
177 srcdata = malloc(srcdatasize);
178 if (!srcdata) return E_OUTOFMEMORY;
179
180 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
181
182 if (SUCCEEDED(res))
183 {
184 srcrow = srcdata;
185 dstrow = pbBuffer;
186 for (y=0; y<prc->Height; y++) {
187 srcbyte = srcrow;
188 dstpixel=(DWORD*)dstrow;
189 for (x=0; x<prc->Width; x+=8) {
190 BYTE srcval;
191 srcval=*srcbyte++;
192 *dstpixel++ = colors[srcval>>7&1];
193 if (x+1 < prc->Width) *dstpixel++ = colors[srcval>>6&1];
194 if (x+2 < prc->Width) *dstpixel++ = colors[srcval>>5&1];
195 if (x+3 < prc->Width) *dstpixel++ = colors[srcval>>4&1];
196 if (x+4 < prc->Width) *dstpixel++ = colors[srcval>>3&1];
197 if (x+5 < prc->Width) *dstpixel++ = colors[srcval>>2&1];
198 if (x+6 < prc->Width) *dstpixel++ = colors[srcval>>1&1];
199 if (x+7 < prc->Width) *dstpixel++ = colors[srcval&1];
200 }
201 srcrow += srcstride;
202 dstrow += cbStride;
203 }
204 }
205
206 free(srcdata);
207
208 return res;
209 }
210 return S_OK;
212 case format_2bppGray:
213 if (prc)
214 {
215 HRESULT res;
216 INT x, y;
217 BYTE *srcdata;
218 UINT srcstride, srcdatasize;
219 const BYTE *srcrow;
220 const BYTE *srcbyte;
221 BYTE *dstrow;
222 DWORD *dstpixel;
223 WICColor colors[4];
225 UINT actualcolors;
226
228 if (FAILED(res)) return res;
229
230 if (source_format == format_2bppIndexed)
231 res = IWICBitmapSource_CopyPalette(This->source, palette);
232 else
233 res = IWICPalette_InitializePredefined(palette, WICBitmapPaletteTypeFixedGray4, FALSE);
234
235 if (SUCCEEDED(res))
236 res = IWICPalette_GetColors(palette, 4, colors, &actualcolors);
237
238 IWICPalette_Release(palette);
239 if (FAILED(res)) return res;
240
241 srcstride = (prc->Width+3)/4;
242 srcdatasize = srcstride * prc->Height;
243
244 srcdata = malloc(srcdatasize);
245 if (!srcdata) return E_OUTOFMEMORY;
246
247 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
248
249 if (SUCCEEDED(res))
250 {
251 srcrow = srcdata;
252 dstrow = pbBuffer;
253 for (y=0; y<prc->Height; y++) {
254 srcbyte = srcrow;
255 dstpixel=(DWORD*)dstrow;
256 for (x=0; x<prc->Width; x+=4) {
257 BYTE srcval;
258 srcval=*srcbyte++;
259 *dstpixel++ = colors[srcval>>6];
260 if (x+1 < prc->Width) *dstpixel++ = colors[srcval>>4&0x3];
261 if (x+2 < prc->Width) *dstpixel++ = colors[srcval>>2&0x3];
262 if (x+3 < prc->Width) *dstpixel++ = colors[srcval&0x3];
263 }
264 srcrow += srcstride;
265 dstrow += cbStride;
266 }
267 }
268
269 free(srcdata);
270
271 return res;
272 }
273 return S_OK;
275 case format_4bppGray:
276 if (prc)
277 {
278 HRESULT res;
279 INT x, y;
280 BYTE *srcdata;
281 UINT srcstride, srcdatasize;
282 const BYTE *srcrow;
283 const BYTE *srcbyte;
284 BYTE *dstrow;
285 DWORD *dstpixel;
286 WICColor colors[16];
288 UINT actualcolors;
289
291 if (FAILED(res)) return res;
292
293 if (source_format == format_4bppIndexed)
294 res = IWICBitmapSource_CopyPalette(This->source, palette);
295 else
296 res = IWICPalette_InitializePredefined(palette, WICBitmapPaletteTypeFixedGray16, FALSE);
297
298 if (SUCCEEDED(res))
299 res = IWICPalette_GetColors(palette, 16, colors, &actualcolors);
300
301 IWICPalette_Release(palette);
302 if (FAILED(res)) return res;
303
304 srcstride = (prc->Width+1)/2;
305 srcdatasize = srcstride * prc->Height;
306
307 srcdata = malloc(srcdatasize);
308 if (!srcdata) return E_OUTOFMEMORY;
309
310 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
311
312 if (SUCCEEDED(res))
313 {
314 srcrow = srcdata;
315 dstrow = pbBuffer;
316 for (y=0; y<prc->Height; y++) {
317 srcbyte = srcrow;
318 dstpixel=(DWORD*)dstrow;
319 for (x=0; x<prc->Width; x+=2) {
320 BYTE srcval;
321 srcval=*srcbyte++;
322 *dstpixel++ = colors[srcval>>4];
323 if (x+1 < prc->Width) *dstpixel++ = colors[srcval&0xf];
324 }
325 srcrow += srcstride;
326 dstrow += cbStride;
327 }
328 }
329
330 free(srcdata);
331
332 return res;
333 }
334 return S_OK;
335 case format_8bppGray:
336 if (prc)
337 {
338 HRESULT res;
339 INT x, y;
340 BYTE *srcdata;
341 UINT srcstride, srcdatasize;
342 const BYTE *srcrow;
343 const BYTE *srcbyte;
344 BYTE *dstrow;
345 DWORD *dstpixel;
346
347 srcstride = prc->Width;
348 srcdatasize = srcstride * prc->Height;
349
350 srcdata = malloc(srcdatasize);
351 if (!srcdata) return E_OUTOFMEMORY;
352
353 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
354
355 if (SUCCEEDED(res))
356 {
357 srcrow = srcdata;
358 dstrow = pbBuffer;
359 for (y=0; y<prc->Height; y++) {
360 srcbyte = srcrow;
361 dstpixel=(DWORD*)dstrow;
362 for (x=0; x<prc->Width; x++)
363 {
364 *dstpixel++ = 0xff000000|(*srcbyte<<16)|(*srcbyte<<8)|*srcbyte;
365 srcbyte++;
366 }
367 srcrow += srcstride;
368 dstrow += cbStride;
369 }
370 }
371
372 free(srcdata);
373
374 return res;
375 }
376 return S_OK;
378 if (prc)
379 {
380 HRESULT res;
381 INT x, y;
382 BYTE *srcdata;
383 UINT srcstride, srcdatasize;
384 const BYTE *srcrow;
385 const BYTE *srcbyte;
386 BYTE *dstrow;
387 DWORD *dstpixel;
388 WICColor colors[256];
390 UINT actualcolors;
391
393 if (FAILED(res)) return res;
394
395 res = IWICBitmapSource_CopyPalette(This->source, palette);
396 if (SUCCEEDED(res))
397 res = IWICPalette_GetColors(palette, 256, colors, &actualcolors);
398
399 IWICPalette_Release(palette);
400
401 if (FAILED(res)) return res;
402
403 srcstride = prc->Width;
404 srcdatasize = srcstride * prc->Height;
405
406 srcdata = malloc(srcdatasize);
407 if (!srcdata) return E_OUTOFMEMORY;
408
409 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
410
411 if (SUCCEEDED(res))
412 {
413 srcrow = srcdata;
414 dstrow = pbBuffer;
415 for (y=0; y<prc->Height; y++) {
416 srcbyte = srcrow;
417 dstpixel=(DWORD*)dstrow;
418 for (x=0; x<prc->Width; x++)
419 *dstpixel++ = colors[*srcbyte++];
420 srcrow += srcstride;
421 dstrow += cbStride;
422 }
423 }
424
425 free(srcdata);
426
427 return res;
428 }
429 return S_OK;
430 case format_16bppGray:
431 if (prc)
432 {
433 HRESULT res;
434 INT x, y;
435 BYTE *srcdata;
436 UINT srcstride, srcdatasize;
437 const BYTE *srcrow;
438 const BYTE *srcbyte;
439 BYTE *dstrow;
440 DWORD *dstpixel;
441
442 srcstride = prc->Width * 2;
443 srcdatasize = srcstride * prc->Height;
444
445 srcdata = malloc(srcdatasize);
446 if (!srcdata) return E_OUTOFMEMORY;
447
448 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
449
450 if (SUCCEEDED(res))
451 {
452 srcrow = srcdata;
453 dstrow = pbBuffer;
454 for (y=0; y<prc->Height; y++) {
455 srcbyte = srcrow;
456 dstpixel=(DWORD*)dstrow;
457 for (x=0; x<prc->Width; x++)
458 {
459 srcbyte++;
460 *dstpixel++ = 0xff000000|(*srcbyte<<16)|(*srcbyte<<8)|*srcbyte;
461 srcbyte++;
462 }
463 srcrow += srcstride;
464 dstrow += cbStride;
465 }
466 }
467
468 free(srcdata);
469
470 return res;
471 }
472 return S_OK;
474 if (prc)
475 {
476 HRESULT res;
477 INT x, y;
478 BYTE *srcdata;
479 UINT srcstride, srcdatasize;
480 const BYTE *srcrow;
481 const WORD *srcpixel;
482 BYTE *dstrow;
483 DWORD *dstpixel;
484
485 srcstride = 2 * prc->Width;
486 srcdatasize = srcstride * prc->Height;
487
488 srcdata = malloc(srcdatasize);
489 if (!srcdata) return E_OUTOFMEMORY;
490
491 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
492
493 if (SUCCEEDED(res))
494 {
495 srcrow = srcdata;
496 dstrow = pbBuffer;
497 for (y=0; y<prc->Height; y++) {
498 srcpixel=(const WORD*)srcrow;
499 dstpixel=(DWORD*)dstrow;
500 for (x=0; x<prc->Width; x++) {
501 WORD srcval;
502 srcval=*srcpixel++;
503 *dstpixel++=0xff000000 | /* constant 255 alpha */
504 ((srcval << 9) & 0xf80000) | /* r */
505 ((srcval << 4) & 0x070000) | /* r - 3 bits */
506 ((srcval << 6) & 0x00f800) | /* g */
507 ((srcval << 1) & 0x000700) | /* g - 3 bits */
508 ((srcval << 3) & 0x0000f8) | /* b */
509 ((srcval >> 2) & 0x000007); /* b - 3 bits */
510 }
511 srcrow += srcstride;
512 dstrow += cbStride;
513 }
514 }
515
516 free(srcdata);
517
518 return res;
519 }
520 return S_OK;
522 if (prc)
523 {
524 HRESULT res;
525 INT x, y;
526 BYTE *srcdata;
527 UINT srcstride, srcdatasize;
528 const BYTE *srcrow;
529 const WORD *srcpixel;
530 BYTE *dstrow;
531 DWORD *dstpixel;
532
533 srcstride = 2 * prc->Width;
534 srcdatasize = srcstride * prc->Height;
535
536 srcdata = malloc(srcdatasize);
537 if (!srcdata) return E_OUTOFMEMORY;
538
539 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
540
541 if (SUCCEEDED(res))
542 {
543 srcrow = srcdata;
544 dstrow = pbBuffer;
545 for (y=0; y<prc->Height; y++) {
546 srcpixel=(const WORD*)srcrow;
547 dstpixel=(DWORD*)dstrow;
548 for (x=0; x<prc->Width; x++) {
549 WORD srcval;
550 srcval=*srcpixel++;
551 *dstpixel++=0xff000000 | /* constant 255 alpha */
552 ((srcval << 8) & 0xf80000) | /* r */
553 ((srcval << 3) & 0x070000) | /* r - 3 bits */
554 ((srcval << 5) & 0x00fc00) | /* g */
555 ((srcval >> 1) & 0x000300) | /* g - 2 bits */
556 ((srcval << 3) & 0x0000f8) | /* b */
557 ((srcval >> 2) & 0x000007); /* b - 3 bits */
558 }
559 srcrow += srcstride;
560 dstrow += cbStride;
561 }
562 }
563
564 free(srcdata);
565
566 return res;
567 }
568 return S_OK;
570 if (prc)
571 {
572 HRESULT res;
573 INT x, y;
574 BYTE *srcdata;
575 UINT srcstride, srcdatasize;
576 const BYTE *srcrow;
577 const WORD *srcpixel;
578 BYTE *dstrow;
579 DWORD *dstpixel;
580
581 srcstride = 2 * prc->Width;
582 srcdatasize = srcstride * prc->Height;
583
584 srcdata = malloc(srcdatasize);
585 if (!srcdata) return E_OUTOFMEMORY;
586
587 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
588
589 if (SUCCEEDED(res))
590 {
591 srcrow = srcdata;
592 dstrow = pbBuffer;
593 for (y=0; y<prc->Height; y++) {
594 srcpixel=(const WORD*)srcrow;
595 dstpixel=(DWORD*)dstrow;
596 for (x=0; x<prc->Width; x++) {
597 WORD srcval;
598 srcval=*srcpixel++;
599 *dstpixel++=((srcval & 0x8000) ? 0xff000000 : 0) | /* alpha */
600 ((srcval << 9) & 0xf80000) | /* r */
601 ((srcval << 4) & 0x070000) | /* r - 3 bits */
602 ((srcval << 6) & 0x00f800) | /* g */
603 ((srcval << 1) & 0x000700) | /* g - 3 bits */
604 ((srcval << 3) & 0x0000f8) | /* b */
605 ((srcval >> 2) & 0x000007); /* b - 3 bits */
606 }
607 srcrow += srcstride;
608 dstrow += cbStride;
609 }
610 }
611
612 free(srcdata);
613
614 return res;
615 }
616 return S_OK;
617 case format_24bppBGR:
618 if (prc)
619 {
620 HRESULT res;
621 INT x, y;
622 BYTE *srcdata;
623 UINT srcstride, srcdatasize;
624 const BYTE *srcrow;
625 const BYTE *srcpixel;
626 BYTE *dstrow;
627 BYTE *dstpixel;
628
629 srcstride = 3 * prc->Width;
630 srcdatasize = srcstride * prc->Height;
631
632 srcdata = malloc(srcdatasize);
633 if (!srcdata) return E_OUTOFMEMORY;
634
635 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
636
637 if (SUCCEEDED(res))
638 {
639 srcrow = srcdata;
640 dstrow = pbBuffer;
641 for (y=0; y<prc->Height; y++) {
642 srcpixel=srcrow;
643 dstpixel=dstrow;
644 for (x=0; x<prc->Width; x++) {
645 *dstpixel++=*srcpixel++; /* blue */
646 *dstpixel++=*srcpixel++; /* green */
647 *dstpixel++=*srcpixel++; /* red */
648 *dstpixel++=255; /* alpha */
649 }
650 srcrow += srcstride;
651 dstrow += cbStride;
652 }
653 }
654
655 free(srcdata);
656
657 return res;
658 }
659 return S_OK;
660 case format_24bppRGB:
661 if (prc)
662 {
663 HRESULT res;
664 INT x, y;
665 BYTE *srcdata;
666 UINT srcstride, srcdatasize;
667 const BYTE *srcrow;
668 const BYTE *srcpixel;
669 BYTE *dstrow;
670 BYTE *dstpixel;
671 BYTE tmppixel[3];
672
673 srcstride = 3 * prc->Width;
674 srcdatasize = srcstride * prc->Height;
675
676 srcdata = malloc(srcdatasize);
677 if (!srcdata) return E_OUTOFMEMORY;
678
679 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
680
681 if (SUCCEEDED(res))
682 {
683 srcrow = srcdata;
684 dstrow = pbBuffer;
685 for (y=0; y<prc->Height; y++) {
686 srcpixel=srcrow;
687 dstpixel=dstrow;
688 for (x=0; x<prc->Width; x++) {
689 tmppixel[0]=*srcpixel++; /* red */
690 tmppixel[1]=*srcpixel++; /* green */
691 tmppixel[2]=*srcpixel++; /* blue */
692
693 *dstpixel++=tmppixel[2]; /* blue */
694 *dstpixel++=tmppixel[1]; /* green */
695 *dstpixel++=tmppixel[0]; /* red */
696 *dstpixel++=255; /* alpha */
697 }
698 srcrow += srcstride;
699 dstrow += cbStride;
700 }
701 }
702
703 free(srcdata);
704
705 return res;
706 }
707 return S_OK;
708 case format_32bppBGR:
709 if (prc)
710 {
711 HRESULT res;
712 INT x, y;
713
714 res = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
715 if (FAILED(res)) return res;
716
717 /* set all alpha values to 255 */
718 for (y=0; y<prc->Height; y++)
719 for (x=0; x<prc->Width; x++)
720 pbBuffer[cbStride*y+4*x+3] = 0xff;
721 }
722 return S_OK;
723 case format_32bppRGBA:
724 if (prc)
725 {
726 HRESULT res;
727 res = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
728 if (FAILED(res)) return res;
729 reverse_bgr8(4, pbBuffer, prc->Width, prc->Height, cbStride);
730 }
731 return S_OK;
732 case format_32bppBGRA:
733 if (prc)
734 return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
735 return S_OK;
737 if (prc)
738 {
739 HRESULT res;
740 INT x, y;
741
742 res = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
743 if (FAILED(res)) return res;
744
745 for (y=0; y<prc->Height; y++)
746 for (x=0; x<prc->Width; x++)
747 {
748 BYTE alpha = pbBuffer[cbStride*y+4*x+3];
749 if (alpha != 0 && alpha != 255)
750 {
751 pbBuffer[cbStride*y+4*x] = pbBuffer[cbStride*y+4*x] * 255 / alpha;
752 pbBuffer[cbStride*y+4*x+1] = pbBuffer[cbStride*y+4*x+1] * 255 / alpha;
753 pbBuffer[cbStride*y+4*x+2] = pbBuffer[cbStride*y+4*x+2] * 255 / alpha;
754 }
755 }
756 }
757 return S_OK;
758 case format_48bppRGB:
759 if (prc)
760 {
761 HRESULT res;
762 INT x, y;
763 BYTE *srcdata;
764 UINT srcstride, srcdatasize;
765 const BYTE *srcrow;
766 const BYTE *srcpixel;
767 BYTE *dstrow;
768 DWORD *dstpixel;
769
770 srcstride = 6 * prc->Width;
771 srcdatasize = srcstride * prc->Height;
772
773 srcdata = malloc(srcdatasize);
774 if (!srcdata) return E_OUTOFMEMORY;
775
776 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
777
778 if (SUCCEEDED(res))
779 {
780 srcrow = srcdata;
781 dstrow = pbBuffer;
782 for (y=0; y<prc->Height; y++) {
783 srcpixel=srcrow;
784 dstpixel=(DWORD*)dstrow;
785 for (x=0; x<prc->Width; x++) {
786 BYTE red, green, blue;
787 srcpixel++; red = *srcpixel++;
788 srcpixel++; green = *srcpixel++;
789 srcpixel++; blue = *srcpixel++;
790 *dstpixel++=0xff000000|red<<16|green<<8|blue;
791 }
792 srcrow += srcstride;
793 dstrow += cbStride;
794 }
795 }
796
797 free(srcdata);
798
799 return res;
800 }
801 return S_OK;
802 case format_64bppRGBA:
803 if (prc)
804 {
805 HRESULT res;
806 INT x, y;
807 BYTE *srcdata;
808 UINT srcstride, srcdatasize;
809 const BYTE *srcrow;
810 const BYTE *srcpixel;
811 BYTE *dstrow;
812 DWORD *dstpixel;
813
814 srcstride = 8 * prc->Width;
815 srcdatasize = srcstride * prc->Height;
816
817 srcdata = malloc(srcdatasize);
818 if (!srcdata) return E_OUTOFMEMORY;
819
820 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
821
822 if (SUCCEEDED(res))
823 {
824 srcrow = srcdata;
825 dstrow = pbBuffer;
826 for (y=0; y<prc->Height; y++) {
827 srcpixel=srcrow;
828 dstpixel=(DWORD*)dstrow;
829 for (x=0; x<prc->Width; x++) {
831 srcpixel++; red = *srcpixel++;
832 srcpixel++; green = *srcpixel++;
833 srcpixel++; blue = *srcpixel++;
834 srcpixel++; alpha = *srcpixel++;
835 *dstpixel++=alpha<<24|red<<16|green<<8|blue;
836 }
837 srcrow += srcstride;
838 dstrow += cbStride;
839 }
840 }
841
842 free(srcdata);
843
844 return res;
845 }
846 return S_OK;
847 case format_32bppCMYK:
848 if (prc)
849 {
850 HRESULT res;
851 UINT x, y;
852
853 res = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
854 if (FAILED(res)) return res;
855
856 for (y=0; y<prc->Height; y++)
857 for (x=0; x<prc->Width; x++)
858 {
859 BYTE *pixel = pbBuffer+cbStride*y+4*x;
860 BYTE c=pixel[0], m=pixel[1], y=pixel[2], k=pixel[3];
861 pixel[0] = (255-y)*(255-k)/255; /* blue */
862 pixel[1] = (255-m)*(255-k)/255; /* green */
863 pixel[2] = (255-c)*(255-k)/255; /* red */
864 pixel[3] = 255; /* alpha */
865 }
866 }
867 return S_OK;
868 default:
869 FIXME("Unimplemented conversion path!\n");
871 }
872}
873
875 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
876{
877 HRESULT hr;
878
879 switch (source_format)
880 {
881 case format_32bppRGB:
882 if (prc)
883 {
884 INT x, y;
885
886 hr = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
887 if (FAILED(hr)) return hr;
888
889 /* set all alpha values to 255 */
890 for (y=0; y<prc->Height; y++)
891 for (x=0; x<prc->Width; x++)
892 pbBuffer[cbStride*y+4*x+3] = 0xff;
893 }
894 return S_OK;
895
896 case format_32bppRGBA:
897 if (prc)
898 return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
899 return S_OK;
900
902 if (prc)
903 {
904 INT x, y;
905
906 hr = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
907 if (FAILED(hr)) return hr;
908
909 for (y=0; y<prc->Height; y++)
910 for (x=0; x<prc->Width; x++)
911 {
912 BYTE alpha = pbBuffer[cbStride*y+4*x+3];
913 if (alpha != 0 && alpha != 255)
914 {
915 pbBuffer[cbStride*y+4*x] = pbBuffer[cbStride*y+4*x] * 255 / alpha;
916 pbBuffer[cbStride*y+4*x+1] = pbBuffer[cbStride*y+4*x+1] * 255 / alpha;
917 pbBuffer[cbStride*y+4*x+2] = pbBuffer[cbStride*y+4*x+2] * 255 / alpha;
918 }
919 }
920 }
921 return S_OK;
922
923 default:
924 hr = copypixels_to_32bppBGRA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
925 if (SUCCEEDED(hr) && prc)
926 reverse_bgr8(4, pbBuffer, prc->Width, prc->Height, cbStride);
927 return hr;
928 }
929}
930
932 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
933{
934 switch (source_format)
935 {
936 case format_32bppBGR:
937 case format_32bppBGRA:
939 if (prc)
940 return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
941 return S_OK;
942 default:
943 return copypixels_to_32bppBGRA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
944 }
945}
946
948 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
949{
950 switch (source_format)
951 {
952 case format_32bppRGB:
953 case format_32bppRGBA:
955 if (prc)
956 return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
957 return S_OK;
958 default:
959 return copypixels_to_32bppRGBA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
960 }
961}
962
964 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
965{
966 HRESULT hr;
967
968 switch (source_format)
969 {
971 if (prc)
972 return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
973 return S_OK;
974 default:
975 hr = copypixels_to_32bppBGRA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
976 if (SUCCEEDED(hr) && prc)
977 {
978 INT x, y;
979
980 for (y=0; y<prc->Height; y++)
981 for (x=0; x<prc->Width; x++)
982 {
983 BYTE alpha = pbBuffer[cbStride*y+4*x+3];
984 if (alpha != 255)
985 {
986 pbBuffer[cbStride*y+4*x] = (pbBuffer[cbStride*y+4*x] * alpha + 127) / 255;
987 pbBuffer[cbStride*y+4*x+1] = (pbBuffer[cbStride*y+4*x+1] * alpha + 127) / 255;
988 pbBuffer[cbStride*y+4*x+2] = (pbBuffer[cbStride*y+4*x+2] * alpha + 127) / 255;
989 }
990 }
991 }
992 return hr;
993 }
994}
995
997 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
998{
999 HRESULT hr;
1000
1001 switch (source_format)
1002 {
1003 case format_32bppPRGBA:
1004 if (prc)
1005 return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
1006 return S_OK;
1007 default:
1008 hr = copypixels_to_32bppRGBA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
1009 if (SUCCEEDED(hr) && prc)
1010 {
1011 INT x, y;
1012
1013 for (y=0; y<prc->Height; y++)
1014 for (x=0; x<prc->Width; x++)
1015 {
1016 BYTE alpha = pbBuffer[cbStride*y+4*x+3];
1017 if (alpha != 255)
1018 {
1019 pbBuffer[cbStride*y+4*x] = (pbBuffer[cbStride*y+4*x] * alpha + 127) / 255;
1020 pbBuffer[cbStride*y+4*x+1] = (pbBuffer[cbStride*y+4*x+1] * alpha + 127) / 255;
1021 pbBuffer[cbStride*y+4*x+2] = (pbBuffer[cbStride*y+4*x+2] * alpha + 127) / 255;
1022 }
1023 }
1024 }
1025 return hr;
1026 }
1027}
1028
1030 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
1031{
1032 HRESULT hr;
1033
1034 switch (source_format)
1035 {
1036 case format_24bppBGR:
1037 case format_24bppRGB:
1038 if (prc)
1039 {
1040 hr = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
1041 if (SUCCEEDED(hr) && source_format == format_24bppRGB)
1042 reverse_bgr8(3, pbBuffer, prc->Width, prc->Height, cbStride);
1043 return hr;
1044 }
1045 return S_OK;
1046 case format_32bppBGR:
1047 case format_32bppBGRA:
1048 case format_32bppPBGRA:
1049 case format_32bppRGBA:
1050 if (prc)
1051 {
1052 HRESULT res;
1053 INT x, y;
1054 BYTE *srcdata;
1055 UINT srcstride, srcdatasize;
1056 const BYTE *srcrow;
1057 const BYTE *srcpixel;
1058 BYTE *dstrow;
1059 BYTE *dstpixel;
1060
1061 srcstride = 4 * prc->Width;
1062 srcdatasize = srcstride * prc->Height;
1063
1064 srcdata = malloc(srcdatasize);
1065 if (!srcdata) return E_OUTOFMEMORY;
1066
1067 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
1068
1069 if (SUCCEEDED(res))
1070 {
1071 srcrow = srcdata;
1072 dstrow = pbBuffer;
1073
1074 if (source_format == format_32bppRGBA)
1075 {
1076 for (y = 0; y < prc->Height; y++)
1077 {
1078 srcpixel = srcrow;
1079 dstpixel = dstrow;
1080 for (x = 0; x < prc->Width; x++) {
1081 *dstpixel++ = srcpixel[2]; /* blue */
1082 *dstpixel++ = srcpixel[1]; /* green */
1083 *dstpixel++ = srcpixel[0]; /* red */
1084 srcpixel += 4;
1085 }
1086 srcrow += srcstride;
1087 dstrow += cbStride;
1088 }
1089 }
1090 else
1091 {
1092 for (y = 0; y < prc->Height; y++)
1093 {
1094 srcpixel = srcrow;
1095 dstpixel = dstrow;
1096 for (x = 0; x < prc->Width; x++) {
1097 *dstpixel++ = *srcpixel++; /* blue */
1098 *dstpixel++ = *srcpixel++; /* green */
1099 *dstpixel++ = *srcpixel++; /* red */
1100 srcpixel++; /* alpha */
1101 }
1102 srcrow += srcstride;
1103 dstrow += cbStride;
1104 }
1105 }
1106 }
1107
1108 free(srcdata);
1109
1110 return res;
1111 }
1112 return S_OK;
1113
1115 if (prc)
1116 {
1117 BYTE *srcdata;
1118 UINT srcstride, srcdatasize;
1119
1120 srcstride = 4 * prc->Width;
1121 srcdatasize = srcstride * prc->Height;
1122
1123 srcdata = malloc(srcdatasize);
1124 if (!srcdata) return E_OUTOFMEMORY;
1125
1126 hr = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
1127
1128 if (SUCCEEDED(hr))
1129 {
1130 INT x, y;
1131 BYTE *src = srcdata, *dst = pbBuffer;
1132
1133 for (y = 0; y < prc->Height; y++)
1134 {
1135 float *gray_float = (float *)src;
1136 BYTE *bgr = dst;
1137
1138 for (x = 0; x < prc->Width; x++)
1139 {
1140 BYTE gray = (BYTE)floorf(to_sRGB_component(gray_float[x]) * 255.0f + 0.51f);
1141 *bgr++ = gray;
1142 *bgr++ = gray;
1143 *bgr++ = gray;
1144 }
1145 src += srcstride;
1146 dst += cbStride;
1147 }
1148 }
1149
1150 free(srcdata);
1151
1152 return hr;
1153 }
1154 return S_OK;
1155
1156 case format_32bppCMYK:
1157 if (prc)
1158 {
1159 BYTE *srcdata;
1160 UINT srcstride, srcdatasize;
1161
1162 srcstride = 4 * prc->Width;
1163 srcdatasize = srcstride * prc->Height;
1164
1165 srcdata = malloc(srcdatasize);
1166 if (!srcdata) return E_OUTOFMEMORY;
1167
1168 hr = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
1169 if (SUCCEEDED(hr))
1170 {
1171 INT x, y;
1172 BYTE *src = srcdata, *dst = pbBuffer;
1173
1174 for (y = 0; y < prc->Height; y++)
1175 {
1176 BYTE *cmyk = src;
1177 BYTE *bgr = dst;
1178
1179 for (x = 0; x < prc->Width; x++)
1180 {
1181 BYTE c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3];
1182 bgr[0] = (255 - y) * (255 - k) / 255; /* B */
1183 bgr[1] = (255 - m) * (255 - k) / 255; /* G */
1184 bgr[2] = (255 - c) * (255 - k) / 255; /* R */
1185 cmyk += 4;
1186 bgr += 3;
1187 }
1188 src += srcstride;
1189 dst += cbStride;
1190 }
1191 }
1192
1193 free(srcdata);
1194 return hr;
1195 }
1196 return S_OK;
1197
1198 default:
1199 FIXME("Unimplemented conversion path!\n");
1201 }
1202}
1203
1205 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
1206{
1207 HRESULT hr;
1208
1209 switch (source_format)
1210 {
1211 case format_24bppBGR:
1212 case format_24bppRGB:
1213 if (prc)
1214 {
1215 hr = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
1216 if (SUCCEEDED(hr) && source_format == format_24bppBGR)
1217 reverse_bgr8(3, pbBuffer, prc->Width, prc->Height, cbStride);
1218 return hr;
1219 }
1220 return S_OK;
1221 case format_32bppBGR:
1222 case format_32bppBGRA:
1223 case format_32bppPBGRA:
1224 if (prc)
1225 {
1226 HRESULT res;
1227 INT x, y;
1228 BYTE *srcdata;
1229 UINT srcstride, srcdatasize;
1230 const BYTE *srcrow;
1231 const BYTE *srcpixel;
1232 BYTE *dstrow;
1233 BYTE *dstpixel;
1234 BYTE tmppixel[3];
1235
1236 srcstride = 4 * prc->Width;
1237 srcdatasize = srcstride * prc->Height;
1238
1239 srcdata = malloc(srcdatasize);
1240 if (!srcdata) return E_OUTOFMEMORY;
1241
1242 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
1243
1244 if (SUCCEEDED(res))
1245 {
1246 srcrow = srcdata;
1247 dstrow = pbBuffer;
1248 for (y=0; y<prc->Height; y++) {
1249 srcpixel=srcrow;
1250 dstpixel=dstrow;
1251 for (x=0; x<prc->Width; x++) {
1252 tmppixel[0]=*srcpixel++; /* blue */
1253 tmppixel[1]=*srcpixel++; /* green */
1254 tmppixel[2]=*srcpixel++; /* red */
1255 srcpixel++; /* alpha */
1256
1257 *dstpixel++=tmppixel[2]; /* red */
1258 *dstpixel++=tmppixel[1]; /* green */
1259 *dstpixel++=tmppixel[0]; /* blue */
1260 }
1261 srcrow += srcstride;
1262 dstrow += cbStride;
1263 }
1264 }
1265
1266 free(srcdata);
1267
1268 return res;
1269 }
1270 return S_OK;
1271 default:
1272 FIXME("Unimplemented conversion path!\n");
1274 }
1275}
1276
1278 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
1279{
1280 HRESULT hr;
1281
1282 switch (source_format)
1283 {
1284 case format_32bppBGR:
1285 case format_32bppBGRA:
1286 case format_32bppPBGRA:
1288 if (prc)
1289 {
1290 hr = IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
1291 break;
1292 }
1293 return S_OK;
1294
1295 default:
1296 hr = copypixels_to_32bppBGRA(This, prc, cbStride, cbBufferSize, pbBuffer, source_format);
1297 break;
1298 }
1299
1300 if (SUCCEEDED(hr) && prc && source_format != format_32bppGrayFloat)
1301 {
1302 INT x, y;
1303 BYTE *p = pbBuffer;
1304
1305 for (y = 0; y < prc->Height; y++)
1306 {
1307 BYTE *bgr = p;
1308 for (x = 0; x < prc->Width; x++)
1309 {
1310 float gray = (bgr[2] * 0.2126f + bgr[1] * 0.7152f + bgr[0] * 0.0722f) / 255.0f;
1311 *(float *)bgr = gray;
1312 bgr += 4;
1313 }
1314 p += cbStride;
1315 }
1316 }
1317 return hr;
1318}
1319
1321 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
1322{
1323 HRESULT hr;
1324 BYTE *srcdata;
1325 UINT srcstride, srcdatasize;
1326
1327 if (source_format == format_8bppGray)
1328 {
1329 if (prc)
1330 return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
1331
1332 return S_OK;
1333 }
1334
1335 if (source_format == format_32bppGrayFloat)
1336 {
1337 hr = S_OK;
1338
1339 if (prc)
1340 {
1341 srcstride = 4 * prc->Width;
1342 srcdatasize = srcstride * prc->Height;
1343
1344 srcdata = malloc(srcdatasize);
1345 if (!srcdata) return E_OUTOFMEMORY;
1346
1347 hr = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
1348 if (SUCCEEDED(hr))
1349 {
1350 INT x, y;
1351 BYTE *src = srcdata, *dst = pbBuffer;
1352
1353 for (y=0; y < prc->Height; y++)
1354 {
1355 float *srcpixel = (float*)src;
1356 BYTE *dstpixel = dst;
1357
1358 for (x=0; x < prc->Width; x++)
1359 *dstpixel++ = (BYTE)floorf(to_sRGB_component(*srcpixel++) * 255.0f + 0.51f);
1360
1361 src += srcstride;
1362 dst += cbStride;
1363 }
1364 }
1365
1366 free(srcdata);
1367 }
1368
1369 return hr;
1370 }
1371
1372 if (!prc)
1373 return copypixels_to_24bppBGR(This, NULL, cbStride, cbBufferSize, pbBuffer, source_format);
1374
1375 srcstride = 3 * prc->Width;
1376 srcdatasize = srcstride * prc->Height;
1377
1378 srcdata = malloc(srcdatasize);
1379 if (!srcdata) return E_OUTOFMEMORY;
1380
1381 hr = copypixels_to_24bppBGR(This, prc, srcstride, srcdatasize, srcdata, source_format);
1382 if (SUCCEEDED(hr))
1383 {
1384 INT x, y;
1385 BYTE *src = srcdata, *dst = pbBuffer;
1386
1387 for (y = 0; y < prc->Height; y++)
1388 {
1389 BYTE *bgr = src;
1390
1391 for (x = 0; x < prc->Width; x++)
1392 {
1393 float gray = (bgr[2] * 0.2126f + bgr[1] * 0.7152f + bgr[0] * 0.0722f) / 255.0f;
1394
1395 gray = to_sRGB_component(gray) * 255.0f;
1396 dst[x] = (BYTE)floorf(gray + 0.51f);
1397 bgr += 3;
1398 }
1399 src += srcstride;
1400 dst += cbStride;
1401 }
1402 }
1403
1404 free(srcdata);
1405 return hr;
1406}
1407
1409{
1410 UINT best_diff, best_index, i;
1411
1412 best_diff = ~0;
1413 best_index = 0;
1414
1415 for (i = 0; i < count; i++)
1416 {
1417 BYTE pal_r, pal_g, pal_b;
1418 UINT diff_r, diff_g, diff_b, diff;
1419
1420 pal_r = colors[i] >> 16;
1421 pal_g = colors[i] >> 8;
1422 pal_b = colors[i];
1423
1424 diff_r = bgr[2] - pal_r;
1425 diff_g = bgr[1] - pal_g;
1426 diff_b = bgr[0] - pal_b;
1427
1428 diff = diff_r * diff_r + diff_g * diff_g + diff_b * diff_b;
1429 if (diff == 0) return i;
1430
1431 if (diff < best_diff)
1432 {
1433 best_diff = diff;
1434 best_index = i;
1435 }
1436 }
1437
1438 return best_index;
1439}
1440
1442 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
1443{
1444 HRESULT hr;
1445 BYTE *srcdata;
1446 WICColor colors[256];
1447 UINT srcstride, srcdatasize, count;
1448
1449 if (source_format == format_8bppIndexed)
1450 {
1451 if (prc)
1452 return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
1453
1454 return S_OK;
1455 }
1456
1457 if (!prc)
1458 return copypixels_to_24bppBGR(This, NULL, cbStride, cbBufferSize, pbBuffer, source_format);
1459
1460 if (!This->palette) return WINCODEC_ERR_WRONGSTATE;
1461
1462 hr = IWICPalette_GetColors(This->palette, 256, colors, &count);
1463 if (hr != S_OK) return hr;
1464
1465 srcstride = 3 * prc->Width;
1466 srcdatasize = srcstride * prc->Height;
1467
1468 srcdata = malloc(srcdatasize);
1469 if (!srcdata) return E_OUTOFMEMORY;
1470
1471 hr = copypixels_to_24bppBGR(This, prc, srcstride, srcdatasize, srcdata, source_format);
1472 if (SUCCEEDED(hr))
1473 {
1474 INT x, y;
1475 BYTE *src = srcdata, *dst = pbBuffer;
1476
1477 for (y = 0; y < prc->Height; y++)
1478 {
1479 BYTE *bgr = src;
1480
1481 for (x = 0; x < prc->Width; x++)
1482 {
1483 dst[x] = rgb_to_palette_index(bgr, colors, count);
1484 bgr += 3;
1485 }
1486 src += srcstride;
1487 dst += cbStride;
1488 }
1489 }
1490
1491 free(srcdata);
1492 return hr;
1493}
1494
1496 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
1497{
1498 switch (source_format)
1499 {
1501 if (prc)
1502 return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
1503 return S_OK;
1504 case format_32bppBGRA:
1505 if(prc)
1506 {
1507 HRESULT res;
1508 INT x, y;
1509 BYTE *srcdata;
1510 UINT srcstride, srcdatasize;
1511 const BYTE *srcrow;
1512 const DWORD *srcpixel;
1513 BYTE *dstrow;
1514 DWORD srcval = 0;
1515 WORD *dstpixel;
1516
1517 int a, r, g, b;
1518
1519 srcstride = 4 * prc->Width;
1520 srcdatasize = srcstride * prc->Height;
1521
1522 srcdata = malloc(srcdatasize);
1523 if (!srcdata) return E_OUTOFMEMORY;
1524
1525 res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
1526 if(SUCCEEDED(res))
1527 {
1528 srcrow = srcdata;
1529 dstrow = pbBuffer;
1530 for(y=0; y< prc->Height; y++) {
1531 srcpixel = (const DWORD*)srcrow;
1532 dstpixel = (WORD *)dstrow;
1533 for(x=0; x<prc->Width; x++) {
1534 srcval=*srcpixel++;
1535 a = (srcval & 0xff000000) >> 24;
1536 r = (srcval & 0x00ff0000) >> 16;
1537 g = (srcval & 0x0000ff00) >> 8;
1538 b = (srcval & 0x000000ff);
1539 a = (a >> 7) << 15;
1540 r = (r >> 3) << 10;
1541 g = (g >> 3) << 5;
1542 b = (b >> 3);
1543 *dstpixel++ = (a|r|g|b);
1544 }
1545 srcrow += srcstride;
1546 dstrow += cbStride;
1547 }
1548 }
1549 free(srcdata);
1550 }
1551 return S_OK;
1552 default:
1553 FIXME("Unimplemented conversion path! %d\n", source_format);
1555 }
1556}
1557
1559 UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
1560{
1561 HRESULT hr;
1562
1563 switch (source_format)
1564 {
1565 case format_64bppRGBA:
1566 if (prc)
1567 return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
1568 return S_OK;
1569
1570 case format_48bppRGB:
1571 {
1572 UINT srcstride, srcdatasize;
1573 const USHORT *srcpixel;
1574 const BYTE *srcrow;
1575 USHORT *dstpixel;
1576 BYTE *srcdata;
1577 BYTE *dstrow;
1578 INT x, y;
1579
1580 if (!prc)
1581 return S_OK;
1582
1583 srcstride = 6 * prc->Width;
1584 srcdatasize = srcstride * prc->Height;
1585
1586 srcdata = malloc(srcdatasize);
1587 if (!srcdata) return E_OUTOFMEMORY;
1588
1589 hr = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
1590 if (SUCCEEDED(hr))
1591 {
1592 srcrow = srcdata;
1593 dstrow = pbBuffer;
1594 for (y = 0; y < prc->Height; y++)
1595 {
1596 srcpixel = (USHORT *)srcrow;
1597 dstpixel= (USHORT *)dstrow;
1598 for (x = 0; x < prc->Width; x++)
1599 {
1600 *dstpixel++ = *srcpixel++;
1601 *dstpixel++ = *srcpixel++;
1602 *dstpixel++ = *srcpixel++;
1603 *dstpixel++ = 65535;
1604 }
1605 srcrow += srcstride;
1606 dstrow += cbStride;
1607 }
1608 }
1609 free(srcdata);
1610 return hr;
1611 }
1612 default:
1613 FIXME("Unimplemented conversion path %d.\n", source_format);
1615 }
1616}
1617
1618static const struct pixelformatinfo supported_formats[] = {
1619 {format_1bppIndexed, &GUID_WICPixelFormat1bppIndexed, NULL, TRUE},
1620 {format_2bppIndexed, &GUID_WICPixelFormat2bppIndexed, NULL, TRUE},
1621 {format_4bppIndexed, &GUID_WICPixelFormat4bppIndexed, NULL, TRUE},
1622 {format_8bppIndexed, &GUID_WICPixelFormat8bppIndexed, copypixels_to_8bppIndexed, TRUE},
1623 {format_BlackWhite, &GUID_WICPixelFormatBlackWhite, NULL},
1624 {format_2bppGray, &GUID_WICPixelFormat2bppGray, NULL},
1625 {format_4bppGray, &GUID_WICPixelFormat4bppGray, NULL},
1626 {format_8bppGray, &GUID_WICPixelFormat8bppGray, copypixels_to_8bppGray},
1627 {format_16bppGray, &GUID_WICPixelFormat16bppGray, NULL},
1628 {format_16bppBGR555, &GUID_WICPixelFormat16bppBGR555, NULL},
1629 {format_16bppBGR565, &GUID_WICPixelFormat16bppBGR565, NULL},
1630 {format_16bppBGRA5551, &GUID_WICPixelFormat16bppBGRA5551, copypixels_to_16bppBGRA5551},
1631 {format_24bppBGR, &GUID_WICPixelFormat24bppBGR, copypixels_to_24bppBGR},
1632 {format_24bppRGB, &GUID_WICPixelFormat24bppRGB, copypixels_to_24bppRGB},
1633 {format_32bppGrayFloat, &GUID_WICPixelFormat32bppGrayFloat, copypixels_to_32bppGrayFloat},
1634 {format_32bppBGR, &GUID_WICPixelFormat32bppBGR, copypixels_to_32bppBGR},
1635 {format_32bppRGB, &GUID_WICPixelFormat32bppRGB, copypixels_to_32bppRGB},
1636 {format_32bppBGRA, &GUID_WICPixelFormat32bppBGRA, copypixels_to_32bppBGRA},
1637 {format_32bppRGBA, &GUID_WICPixelFormat32bppRGBA, copypixels_to_32bppRGBA},
1638 {format_32bppPBGRA, &GUID_WICPixelFormat32bppPBGRA, copypixels_to_32bppPBGRA},
1639 {format_32bppPRGBA, &GUID_WICPixelFormat32bppPRGBA, copypixels_to_32bppPRGBA},
1640 {format_48bppRGB, &GUID_WICPixelFormat48bppRGB, NULL},
1641 {format_64bppRGBA, &GUID_WICPixelFormat64bppRGBA, copypixels_to_64bppRGBA},
1642 {format_32bppCMYK, &GUID_WICPixelFormat32bppCMYK, NULL},
1643 {0}
1644};
1645
1647{
1648 UINT i;
1649
1650 for (i=0; supported_formats[i].guid; i++)
1652
1653 return NULL;
1654}
1655
1657 void **ppv)
1658{
1660 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
1661
1662 if (!ppv) return E_INVALIDARG;
1663
1664 if (IsEqualIID(&IID_IUnknown, iid) ||
1665 IsEqualIID(&IID_IWICBitmapSource, iid) ||
1666 IsEqualIID(&IID_IWICFormatConverter, iid))
1667 {
1668 *ppv = &This->IWICFormatConverter_iface;
1669 }
1670 else
1671 {
1672 *ppv = NULL;
1673 return E_NOINTERFACE;
1674 }
1675
1676 IUnknown_AddRef((IUnknown*)*ppv);
1677 return S_OK;
1678}
1679
1681{
1684
1685 TRACE("(%p) refcount=%lu\n", iface, ref);
1686
1687 return ref;
1688}
1689
1691{
1694
1695 TRACE("(%p) refcount=%lu\n", iface, ref);
1696
1697 if (ref == 0)
1698 {
1699 This->lock.DebugInfo->Spare[0] = 0;
1701 if (This->source) IWICBitmapSource_Release(This->source);
1702 if (This->palette) IWICPalette_Release(This->palette);
1703 free(This);
1704 }
1705
1706 return ref;
1707}
1708
1710 UINT *puiWidth, UINT *puiHeight)
1711{
1713
1714 TRACE("(%p,%p,%p)\n", iface, puiWidth, puiHeight);
1715
1716 if (This->source)
1717 return IWICBitmapSource_GetSize(This->source, puiWidth, puiHeight);
1718 else
1720}
1721
1723 WICPixelFormatGUID *pPixelFormat)
1724{
1726
1727 TRACE("(%p,%p)\n", iface, pPixelFormat);
1728
1729 if (This->source)
1730 memcpy(pPixelFormat, This->dst_format->guid, sizeof(GUID));
1731 else
1733
1734 return S_OK;
1735}
1736
1738 double *pDpiX, double *pDpiY)
1739{
1741
1742 TRACE("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
1743
1744 if (This->source)
1745 return IWICBitmapSource_GetResolution(This->source, pDpiX, pDpiY);
1746 else
1748}
1749
1752{
1754
1755 TRACE("(%p,%p)\n", iface, palette);
1756
1757 if (!palette) return E_INVALIDARG;
1758 if (!This->source) return WINCODEC_ERR_WRONGSTATE;
1759
1760 if (!This->palette)
1761 {
1762 if (This->dst_format->is_indexed_format) return WINCODEC_ERR_WRONGSTATE;
1763 return IWICBitmapSource_CopyPalette(This->source, palette);
1764 }
1765
1766 return IWICPalette_InitializeFromPalette(palette, This->palette);
1767}
1768
1770 const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
1771{
1773 WICRect rc;
1774 HRESULT hr;
1775 TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
1776
1777 if (This->source)
1778 {
1779 if (!prc)
1780 {
1781 UINT width, height;
1782 hr = IWICBitmapSource_GetSize(This->source, &width, &height);
1783 if (FAILED(hr)) return hr;
1784 rc.X = 0;
1785 rc.Y = 0;
1786 rc.Width = width;
1787 rc.Height = height;
1788 prc = &rc;
1789 }
1790
1791 return This->dst_format->copy_function(This, prc, cbStride, cbBufferSize,
1792 pbBuffer, This->src_format->format);
1793 }
1794 else
1796}
1797
1800 IWICPalette *palette, double alpha_threshold, WICBitmapPaletteType palette_type)
1801{
1803 const struct pixelformatinfo *srcinfo, *dstinfo;
1804 GUID srcFormat;
1805 HRESULT res;
1806
1807 TRACE("(%p,%p,%s,%u,%p,%0.3f,%u)\n", iface, source, debugstr_guid(dstFormat),
1808 dither, palette, alpha_threshold, palette_type);
1809
1810 dstinfo = get_formatinfo(dstFormat);
1811 if (!dstinfo)
1812 {
1813 FIXME("Unsupported destination format %s\n", debugstr_guid(dstFormat));
1815 }
1816
1817 if (!palette)
1818 {
1819 UINT bpp;
1820 res = get_pixelformat_bpp(dstFormat, &bpp);
1821 if (res != S_OK) return res;
1822
1824 if (res != S_OK) return res;
1825
1826 switch (palette_type)
1827 {
1829 IWICPalette_Release(palette);
1830 palette = NULL;
1831
1832 /* Indexed types require a palette */
1833 if (dstinfo->is_indexed_format)
1834 return E_INVALIDARG;
1835 break;
1836
1838 {
1839 if (dstinfo->is_indexed_format)
1840 res = IWICPalette_InitializeFromBitmap(palette, source, 1 << bpp, FALSE);
1841 break;
1842 }
1843
1844 default:
1845 if (dstinfo->is_indexed_format)
1846 res = IWICPalette_InitializePredefined(palette, palette_type, FALSE);
1847 break;
1848 }
1849
1850 if (res != S_OK)
1851 {
1852 IWICPalette_Release(palette);
1853 return res;
1854 }
1855 }
1856 else
1857 IWICPalette_AddRef(palette);
1858
1859 EnterCriticalSection(&This->lock);
1860
1861 if (This->source)
1862 {
1864 goto end;
1865 }
1866
1867 res = IWICBitmapSource_GetPixelFormat(source, &srcFormat);
1868 if (FAILED(res)) goto end;
1869
1870 srcinfo = get_formatinfo(&srcFormat);
1871 if (!srcinfo)
1872 {
1874 FIXME("Unsupported source format %s\n", debugstr_guid(&srcFormat));
1875 goto end;
1876 }
1877
1878 if (dstinfo->copy_function)
1879 {
1880 IWICBitmapSource_AddRef(source);
1881 This->src_format = srcinfo;
1882 This->dst_format = dstinfo;
1883 This->dither = dither;
1884 This->alpha_threshold = alpha_threshold;
1885 This->palette = palette;
1886 This->source = source;
1887 }
1888 else
1889 {
1890 FIXME("Unsupported conversion %s -> %s\n", debugstr_guid(&srcFormat), debugstr_guid(dstFormat));
1892 }
1893
1894end:
1895
1896 LeaveCriticalSection(&This->lock);
1897
1898 if (res != S_OK && palette)
1899 IWICPalette_Release(palette);
1900
1901 return res;
1902}
1903
1905 REFWICPixelFormatGUID srcPixelFormat, REFWICPixelFormatGUID dstPixelFormat,
1906 BOOL *pfCanConvert)
1907{
1909 const struct pixelformatinfo *srcinfo, *dstinfo;
1910
1911 TRACE("(%p,%s,%s,%p)\n", iface, debugstr_guid(srcPixelFormat),
1912 debugstr_guid(dstPixelFormat), pfCanConvert);
1913
1914 srcinfo = get_formatinfo(srcPixelFormat);
1915 if (!srcinfo)
1916 {
1917 FIXME("Unsupported source format %s\n", debugstr_guid(srcPixelFormat));
1919 }
1920
1921 dstinfo = get_formatinfo(dstPixelFormat);
1922 if (!dstinfo)
1923 {
1924 FIXME("Unsupported destination format %s\n", debugstr_guid(dstPixelFormat));
1926 }
1927
1928 if (dstinfo->copy_function &&
1929 SUCCEEDED(dstinfo->copy_function(This, NULL, 0, 0, NULL, dstinfo->format)))
1930 *pfCanConvert = TRUE;
1931 else
1932 {
1933 FIXME("Unsupported conversion %s -> %s\n", debugstr_guid(srcPixelFormat), debugstr_guid(dstPixelFormat));
1934 *pfCanConvert = FALSE;
1935 }
1936
1937 return S_OK;
1938}
1939
1940static const IWICFormatConverterVtbl FormatConverter_Vtbl = {
1951};
1952
1954{
1956 HRESULT ret;
1957
1958 TRACE("(%s,%p)\n", debugstr_guid(iid), ppv);
1959
1960 *ppv = NULL;
1961
1962 This = malloc(sizeof(FormatConverter));
1963 if (!This) return E_OUTOFMEMORY;
1964
1965 This->IWICFormatConverter_iface.lpVtbl = &FormatConverter_Vtbl;
1966 This->ref = 1;
1967 This->source = NULL;
1968 This->palette = NULL;
1969#ifdef __REACTOS__
1971#else
1973#endif
1974 This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": FormatConverter.lock");
1975
1976 ret = IWICFormatConverter_QueryInterface(&This->IWICFormatConverter_iface, iid, ppv);
1977 IWICFormatConverter_Release(&This->IWICFormatConverter_iface);
1978
1979 return ret;
1980}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
const GUID IID_IUnknown
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD bpp
Definition: surface.c:185
WICBitmapPaletteType palette_type
Definition: image.c:53
BOOL WINAPI InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount, IN DWORD flags)
Definition: sync.c:107
static HRESULT WINAPI FormatConverter_QueryInterface(IWICFormatConverter *iface, REFIID iid, void **ppv)
Definition: converter.c:1656
static UINT rgb_to_palette_index(BYTE bgr[3], WICColor *colors, UINT count)
Definition: converter.c:1408
static HRESULT copypixels_to_32bppRGB(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:947
static FormatConverter * impl_from_IWICFormatConverter(IWICFormatConverter *iface)
Definition: converter.c:134
static HRESULT WINAPI FormatConverter_CanConvert(IWICFormatConverter *iface, REFWICPixelFormatGUID srcPixelFormat, REFWICPixelFormatGUID dstPixelFormat, BOOL *pfCanConvert)
Definition: converter.c:1904
static const IWICFormatConverterVtbl FormatConverter_Vtbl
Definition: converter.c:1940
static HRESULT WINAPI FormatConverter_CopyPalette(IWICFormatConverter *iface, IWICPalette *palette)
Definition: converter.c:1750
static HRESULT copypixels_to_32bppPRGBA(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:996
HRESULT FormatConverter_CreateInstance(REFIID iid, void **ppv)
Definition: converter.c:1953
static HRESULT WINAPI FormatConverter_GetResolution(IWICFormatConverter *iface, double *pDpiX, double *pDpiY)
Definition: converter.c:1737
static HRESULT copypixels_to_32bppBGR(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:931
static HRESULT WINAPI FormatConverter_Initialize(IWICFormatConverter *iface, IWICBitmapSource *source, REFWICPixelFormatGUID dstFormat, WICBitmapDitherType dither, IWICPalette *palette, double alpha_threshold, WICBitmapPaletteType palette_type)
Definition: converter.c:1798
static ULONG WINAPI FormatConverter_Release(IWICFormatConverter *iface)
Definition: converter.c:1690
static HRESULT copypixels_to_24bppBGR(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:1029
static const struct pixelformatinfo supported_formats[]
Definition: converter.c:1618
static const struct pixelformatinfo * get_formatinfo(const WICPixelFormatGUID *format)
Definition: converter.c:1646
static HRESULT copypixels_to_24bppRGB(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:1204
static HRESULT copypixels_to_64bppRGBA(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:1558
static HRESULT copypixels_to_8bppGray(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:1320
static HRESULT copypixels_to_8bppIndexed(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:1441
static HRESULT WINAPI FormatConverter_CopyPixels(IWICFormatConverter *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
Definition: converter.c:1769
static float to_sRGB_component(float f)
Definition: converter.c:86
static HRESULT copypixels_to_32bppRGBA(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:874
static ULONG WINAPI FormatConverter_AddRef(IWICFormatConverter *iface)
Definition: converter.c:1680
static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:139
pixelformat
Definition: converter.c:37
@ format_8bppIndexed
Definition: converter.c:41
@ format_24bppRGB
Definition: converter.c:51
@ format_4bppIndexed
Definition: converter.c:40
@ format_4bppGray
Definition: converter.c:44
@ format_32bppRGBA
Definition: converter.c:56
@ format_32bppRGB
Definition: converter.c:54
@ format_2bppGray
Definition: converter.c:43
@ format_64bppRGBA
Definition: converter.c:60
@ format_16bppBGR565
Definition: converter.c:48
@ format_32bppBGR
Definition: converter.c:53
@ format_32bppPRGBA
Definition: converter.c:58
@ format_32bppBGRA
Definition: converter.c:55
@ format_32bppPBGRA
Definition: converter.c:57
@ format_16bppBGR555
Definition: converter.c:47
@ format_48bppRGB
Definition: converter.c:59
@ format_16bppBGRA5551
Definition: converter.c:49
@ format_BlackWhite
Definition: converter.c:42
@ format_16bppGray
Definition: converter.c:46
@ format_8bppGray
Definition: converter.c:45
@ format_1bppIndexed
Definition: converter.c:38
@ format_32bppCMYK
Definition: converter.c:61
@ format_24bppBGR
Definition: converter.c:50
@ format_2bppIndexed
Definition: converter.c:39
@ format_32bppGrayFloat
Definition: converter.c:52
static HRESULT copypixels_to_32bppPBGRA(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:963
static HRESULT WINAPI FormatConverter_GetPixelFormat(IWICFormatConverter *iface, WICPixelFormatGUID *pPixelFormat)
Definition: converter.c:1722
HRESULT(* copyfunc)(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:64
static HRESULT copypixels_to_16bppBGRA5551(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:1495
static HRESULT copypixels_to_32bppGrayFloat(struct FormatConverter *This, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer, enum pixelformat source_format)
Definition: converter.c:1277
static HRESULT WINAPI FormatConverter_GetSize(IWICFormatConverter *iface, UINT *puiWidth, UINT *puiHeight)
Definition: converter.c:1709
HRESULT get_pixelformat_bpp(const GUID *pixelformat, UINT *bpp)
Definition: main.c:62
HRESULT PaletteImpl_Create(IWICPalette **palette)
Definition: palette.c:897
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLclampf green
Definition: gl.h:1740
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLclampf GLclampf GLclampf alpha
Definition: gl.h:1740
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint end
Definition: gl.h:1545
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLclampf GLclampf blue
Definition: gl.h:1740
GLint GLint GLsizei width
Definition: gl.h:1546
GLuint res
Definition: glext.h:9613
GLenum src
Definition: glext.h:6340
const GLubyte * c
Definition: glext.h:8905
GLfloat f
Definition: glext.h:7540
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLenum GLenum dst
Definition: glext.h:6340
GLboolean GLboolean g
Definition: glext.h:6204
GLfloat GLfloat p
Definition: glext.h:8902
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
const GLfloat * m
Definition: glext.h:10848
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
Definition: glfuncs.h:248
_Check_return_ float __cdecl powf(_In_ float b, _In_ float e)
Definition: math.h:246
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
j_compress_ptr dstinfo
Definition: jpeglib.h:1100
#define f
Definition: ke_i.h:83
#define a
Definition: ke_i.h:78
#define c
Definition: ke_i.h:80
#define b
Definition: ke_i.h:79
#define debugstr_guid
Definition: kernel32.h:35
#define red
Definition: linetest.c:67
const GUID * guid
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HPALETTE palette
Definition: clipboard.c:1345
int k
Definition: mpi.c:3369
#define floorf(x)
Definition: mymath.h:65
unsigned int UINT
Definition: ndis.h:50
_Out_ LPRECT prc
Definition: ntgdi.h:1658
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
double alpha_threshold
Definition: converter.c:80
IWICFormatConverter IWICFormatConverter_iface
Definition: converter.c:75
IWICPalette * palette
Definition: converter.c:81
const struct pixelformatinfo * src_format
Definition: converter.c:78
IWICBitmapSource * source
Definition: converter.c:77
const struct pixelformatinfo * dst_format
Definition: converter.c:78
WICBitmapDitherType dither
Definition: converter.c:79
CRITICAL_SECTION lock
Definition: converter.c:82
INT Height
Definition: wincodec.idl:335
INT Width
Definition: wincodec.idl:334
Definition: scsiwmi.h:51
Definition: format.c:58
enum pixelformat format
Definition: converter.c:68
BOOL is_indexed_format
Definition: converter.c:71
copyfunc copy_function
Definition: converter.c:70
const WICPixelFormatGUID * guid
Definition: converter.c:69
Definition: send.c:48
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define DWORD_PTR
Definition: treelist.c:76
int32_t INT
Definition: typedefs.h:58
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
int ret
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
WICBitmapDitherType
Definition: wincodec.idl:56
WICBitmapPaletteType
Definition: wincodec.idl:91
@ WICBitmapPaletteTypeCustom
Definition: wincodec.idl:92
@ WICBitmapPaletteTypeFixedBW
Definition: wincodec.idl:94
@ WICBitmapPaletteTypeFixedGray16
Definition: wincodec.idl:104
@ WICBitmapPaletteTypeFixedGray4
Definition: wincodec.idl:103
@ WICBitmapPaletteTypeMedianCut
Definition: wincodec.idl:93
UINT32 WICColor
Definition: wincodec.idl:364
void reverse_bgr8(UINT bytesperpixel, LPBYTE bits, UINT width, UINT height, INT stride)
static const char * debug_wic_rect(const WICRect *rect)
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3281
#define WINCODEC_ERR_UNSUPPORTEDOPERATION
Definition: winerror.h:3308
#define WINCODEC_ERR_NOTINITIALIZED
Definition: winerror.h:3285
#define E_NOINTERFACE
Definition: winerror.h:2364
#define WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT
Definition: winerror.h:3307
#define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO
Definition: winnt_old.h:1118
unsigned char BYTE
Definition: xxhash.c:193