ReactOS 0.4.16-dev-974-g5022a45
tgaformat.c
Go to the documentation of this file.
1/*
2 * Copyright 2010 Vincent Povirk for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include <stdarg.h>
20
21#define COBJMACROS
22
23#include "windef.h"
24#include "winbase.h"
25#include "objbase.h"
26
27#include "wincodecs_private.h"
28
29#include "wine/debug.h"
30
32
33#include "pshpack1.h"
34
35typedef struct {
39 /* Colormap Specification */
43 /* Image Specification */
51
52#define IMAGETYPE_COLORMAPPED 1
53#define IMAGETYPE_TRUECOLOR 2
54#define IMAGETYPE_GRAYSCALE 3
55#define IMAGETYPE_RLE 8
56
57#define IMAGE_ATTRIBUTE_BITCOUNT_MASK 0xf
58#define IMAGE_RIGHTTOLEFT 0x10
59#define IMAGE_TOPTOBOTTOM 0x20
60
61typedef struct {
64 char magic[18];
66
67static const BYTE tga_footer_magic[18] = "TRUEVISION-XFILE.";
68
69typedef struct {
71 char author_name[41];
72 char author_comments[324];
74 char job_name[41];
75 WORD job_timestamp[6];
76 char software_id[41];
89
90#define ATTRIBUTE_NO_ALPHA 0
91#define ATTRIBUTE_UNDEFINED 1
92#define ATTRIBUTE_UNDEFINED_PRESERVE 2
93#define ATTRIBUTE_ALPHA 3
94#define ATTRIBUTE_PALPHA 4
95
96#include "poppack.h"
97
98typedef struct {
116} TgaDecoder;
117
119{
120 return CONTAINING_RECORD(iface, TgaDecoder, IWICBitmapDecoder_iface);
121}
122
124{
125 return CONTAINING_RECORD(iface, TgaDecoder, IWICBitmapFrameDecode_iface);
126}
127
129 void **ppv)
130{
132 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
133
134 if (!ppv) return E_INVALIDARG;
135
136 if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IWICBitmapDecoder, iid))
137 {
138 *ppv = &This->IWICBitmapDecoder_iface;
139 }
140 else
141 {
142 *ppv = NULL;
143 return E_NOINTERFACE;
144 }
145
146 IUnknown_AddRef((IUnknown*)*ppv);
147 return S_OK;
148}
149
151{
154
155 TRACE("(%p) refcount=%lu\n", iface, ref);
156
157 return ref;
158}
159
161{
164
165 TRACE("(%p) refcount=%lu\n", iface, ref);
166
167 if (ref == 0)
168 {
169 This->lock.DebugInfo->Spare[0] = 0;
171 if (This->stream)
172 IStream_Release(This->stream);
173 free(This->imagebits);
174 free(This);
175 }
176
177 return ref;
178}
179
181 DWORD *capability)
182{
183 HRESULT hr;
184
185 TRACE("(%p,%p,%p)\n", iface, stream, capability);
186
187 if (!stream || !capability) return E_INVALIDARG;
188
189 hr = IWICBitmapDecoder_Initialize(iface, stream, WICDecodeMetadataCacheOnDemand);
190 if (hr != S_OK) return hr;
191
194 return S_OK;
195}
196
198 WICDecodeOptions cacheOptions)
199{
202 DWORD bytesread;
204 tga_footer footer;
205 int attribute_bitcount;
206 int mapped_depth=0;
207
208 TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOptions);
209
211
212 if (This->initialized)
213 {
215 goto end;
216 }
217
218 seek.QuadPart = 0;
219 hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL);
220 if (FAILED(hr)) goto end;
221
222 hr = IStream_Read(pIStream, &This->header, sizeof(tga_header), &bytesread);
223 if (SUCCEEDED(hr) && bytesread != sizeof(tga_header))
224 {
225 TRACE("got only %lu bytes\n", bytesread);
226 hr = E_FAIL;
227 }
228 if (FAILED(hr)) goto end;
229
230 TRACE("imagetype=%u, colormap type=%u, depth=%u, image descriptor=0x%x\n",
231 This->header.image_type, This->header.colormap_type,
232 This->header.depth, This->header.image_descriptor);
233
234 /* Sanity checking. Since TGA has no clear identifying markers, we need
235 * to be careful to not load a non-TGA image. */
236 switch (This->header.image_type)
237 {
240 if (This->header.colormap_type != 1)
241 hr = E_FAIL;
242 mapped_depth = This->header.colormap_entrysize;
243 break;
246 if (This->header.colormap_type != 0 && This->header.colormap_type != 1)
247 hr = E_FAIL;
248 mapped_depth = This->header.depth;
249 break;
252 if (This->header.colormap_type != 0)
253 hr = E_FAIL;
254 mapped_depth = 0;
255 break;
256 default:
257 hr = E_FAIL;
258 }
259
260 if (This->header.depth != 8 && This->header.depth != 16 &&
261 This->header.depth != 24 && This->header.depth != 32)
262 hr = E_FAIL;
263
264 if ((This->header.image_descriptor & 0xc0) != 0)
265 hr = E_FAIL;
266
267 attribute_bitcount = This->header.image_descriptor & IMAGE_ATTRIBUTE_BITCOUNT_MASK;
268
269 if (attribute_bitcount &&
270 !((mapped_depth == 32 && attribute_bitcount == 8) ||
271 (mapped_depth == 16 && attribute_bitcount == 1)))
272 hr = E_FAIL;
273
274 if (FAILED(hr))
275 {
276 WARN("bad tga header\n");
277 goto end;
278 }
279
280 /* Locate data in the file based on the header. */
281 This->id_offset = sizeof(tga_header);
282 This->colormap_offset = This->id_offset + This->header.id_length;
283 if (This->header.colormap_type == 1)
284 This->colormap_length = ((This->header.colormap_entrysize+7)/8) * This->header.colormap_length;
285 else
286 This->colormap_length = 0;
287 This->image_offset = This->colormap_offset + This->colormap_length;
288
289 /* Read footer if there is one */
290 seek.QuadPart = -(LONGLONG)sizeof(tga_footer);
291 hr = IStream_Seek(pIStream, seek, STREAM_SEEK_END, NULL);
292
293 if (SUCCEEDED(hr)) {
294 hr = IStream_Read(pIStream, &footer, sizeof(tga_footer), &bytesread);
295 if (SUCCEEDED(hr) && bytesread != sizeof(tga_footer))
296 {
297 TRACE("got only %lu footer bytes\n", bytesread);
298 hr = E_FAIL;
299 }
300
301 if (memcmp(footer.magic, tga_footer_magic, sizeof(tga_footer_magic)) == 0)
302 {
303 This->extension_area_offset = footer.extension_area_offset;
304 This->developer_directory_offset = footer.developer_directory_offset;
305 }
306 else
307 {
308 This->extension_area_offset = 0;
309 This->developer_directory_offset = 0;
310 }
311 }
312 else
313 {
314 /* File is too small to have a footer. */
315 This->extension_area_offset = 0;
316 This->developer_directory_offset = 0;
317 hr = S_OK;
318 }
319
320 if (This->extension_area_offset)
321 {
322 seek.QuadPart = This->extension_area_offset;
323 hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL);
324 if (FAILED(hr)) goto end;
325
326 hr = IStream_Read(pIStream, &This->extension_area, sizeof(tga_extension_area), &bytesread);
327 if (SUCCEEDED(hr) && bytesread != sizeof(tga_extension_area))
328 {
329 TRACE("got only %lu extension area bytes\n", bytesread);
330 hr = E_FAIL;
331 }
332 if (SUCCEEDED(hr) && This->extension_area.size < 495)
333 {
334 TRACE("extension area is only %u bytes long\n", This->extension_area.size);
335 hr = E_FAIL;
336 }
337 if (FAILED(hr)) goto end;
338 }
339
340 IStream_AddRef(pIStream);
341 This->stream = pIStream;
342 This->initialized = TRUE;
343
344end:
346 return hr;
347}
348
350 GUID *pguidContainerFormat)
351{
352 memcpy(pguidContainerFormat, &GUID_WineContainerFormatTga, sizeof(GUID));
353 return S_OK;
354}
355
357 IWICBitmapDecoderInfo **ppIDecoderInfo)
358{
359 TRACE("(%p,%p)\n", iface, ppIDecoderInfo);
360
361 return get_decoder_info(&CLSID_WineTgaDecoder, ppIDecoderInfo);
362}
363
365 IWICPalette *pIPalette)
366{
367 FIXME("(%p,%p): stub\n", iface, pIPalette);
368 return E_NOTIMPL;
369}
370
372 IWICMetadataQueryReader **ppIMetadataQueryReader)
373{
374 FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
375 return E_NOTIMPL;
376}
377
379 IWICBitmapSource **ppIBitmapSource)
380{
381 FIXME("(%p,%p): stub\n", iface, ppIBitmapSource);
383}
384
386 UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
387{
388 FIXME("(%p,%u,%p,%p): stub\n", iface, cCount, ppIColorContexts, pcActualCount);
390}
391
393 IWICBitmapSource **ppIThumbnail)
394{
395 FIXME("(%p,%p): stub\n", iface, ppIThumbnail);
397}
398
400 UINT *pCount)
401{
402 if (!pCount) return E_INVALIDARG;
403
404 *pCount = 1;
405 return S_OK;
406}
407
409 UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
410{
412 TRACE("(%p,%p)\n", iface, ppIBitmapFrame);
413
414 if (!This->initialized) return WINCODEC_ERR_FRAMEMISSING;
415
416 if (index != 0) return E_INVALIDARG;
417
418 IWICBitmapDecoder_AddRef(iface);
419 *ppIBitmapFrame = &This->IWICBitmapFrameDecode_iface;
420
421 return S_OK;
422}
423
424static const IWICBitmapDecoderVtbl TgaDecoder_Vtbl = {
439};
440
442 void **ppv)
443{
444 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
445
446 if (!ppv) return E_INVALIDARG;
447
448 if (IsEqualIID(&IID_IUnknown, iid) ||
449 IsEqualIID(&IID_IWICBitmapSource, iid) ||
450 IsEqualIID(&IID_IWICBitmapFrameDecode, iid))
451 {
452 *ppv = iface;
453 }
454 else
455 {
456 *ppv = NULL;
457 return E_NOINTERFACE;
458 }
459
460 IUnknown_AddRef((IUnknown*)*ppv);
461 return S_OK;
462}
463
465{
467 return IWICBitmapDecoder_AddRef(&This->IWICBitmapDecoder_iface);
468}
469
471{
473 return IWICBitmapDecoder_Release(&This->IWICBitmapDecoder_iface);
474}
475
477 UINT *puiWidth, UINT *puiHeight)
478{
480
481 *puiWidth = This->header.width;
482 *puiHeight = This->header.height;
483
484 TRACE("(%p)->(%u,%u)\n", iface, *puiWidth, *puiHeight);
485
486 return S_OK;
487}
488
490 WICPixelFormatGUID *pPixelFormat)
491{
493 int attribute_bitcount;
494 byte attribute_type;
495
496 TRACE("(%p,%p)\n", iface, pPixelFormat);
497
498 attribute_bitcount = This->header.image_descriptor & IMAGE_ATTRIBUTE_BITCOUNT_MASK;
499
500 if (attribute_bitcount && This->extension_area_offset)
501 attribute_type = This->extension_area.attributes_type;
502 else if (attribute_bitcount)
503 attribute_type = ATTRIBUTE_ALPHA;
504 else
505 attribute_type = ATTRIBUTE_NO_ALPHA;
506
507 switch (This->header.image_type & ~IMAGETYPE_RLE)
508 {
510 switch (This->header.depth)
511 {
512 case 8:
513 memcpy(pPixelFormat, &GUID_WICPixelFormat8bppIndexed, sizeof(GUID));
514 break;
515 default:
516 FIXME("Unhandled indexed color depth %u\n", This->header.depth);
517 return E_NOTIMPL;
518 }
519 break;
521 switch (This->header.depth)
522 {
523 case 16:
524 switch (attribute_type)
525 {
529 memcpy(pPixelFormat, &GUID_WICPixelFormat16bppBGR555, sizeof(GUID));
530 break;
531 case ATTRIBUTE_ALPHA:
532 case ATTRIBUTE_PALPHA:
533 memcpy(pPixelFormat, &GUID_WICPixelFormat16bppBGRA5551, sizeof(GUID));
534 break;
535 default:
536 FIXME("Unhandled 16-bit attribute type %u\n", attribute_type);
537 return E_NOTIMPL;
538 }
539 break;
540 case 24:
541 memcpy(pPixelFormat, &GUID_WICPixelFormat24bppBGR, sizeof(GUID));
542 break;
543 case 32:
544 switch (attribute_type)
545 {
549 memcpy(pPixelFormat, &GUID_WICPixelFormat32bppBGR, sizeof(GUID));
550 break;
551 case ATTRIBUTE_ALPHA:
552 memcpy(pPixelFormat, &GUID_WICPixelFormat32bppBGRA, sizeof(GUID));
553 break;
554 case ATTRIBUTE_PALPHA:
555 memcpy(pPixelFormat, &GUID_WICPixelFormat32bppPBGRA, sizeof(GUID));
556 break;
557 default:
558 FIXME("Unhandled 32-bit attribute type %u\n", attribute_type);
559 return E_NOTIMPL;
560 }
561 break;
562 default:
563 FIXME("Unhandled truecolor depth %u\n", This->header.depth);
564 return E_NOTIMPL;
565 }
566 break;
568 switch (This->header.depth)
569 {
570 case 8:
571 memcpy(pPixelFormat, &GUID_WICPixelFormat8bppGray, sizeof(GUID));
572 break;
573 case 16:
574 memcpy(pPixelFormat, &GUID_WICPixelFormat16bppGray, sizeof(GUID));
575 break;
576 default:
577 FIXME("Unhandled grayscale depth %u\n", This->header.depth);
578 return E_NOTIMPL;
579 }
580 break;
581 default:
582 ERR("Unknown image type %u\n", This->header.image_type);
583 return E_FAIL;
584 }
585
586 return S_OK;
587}
588
590 double *pDpiX, double *pDpiY)
591{
592 FIXME("(%p,%p,%p): stub\n", iface, pDpiX, pDpiY);
593 return E_NOTIMPL;
594}
595
597 IWICPalette *pIPalette)
598{
601 WICColor colors[256], *color;
602 BYTE *colormap_data;
603 WORD *wcolormap_data;
604 DWORD *dwcolormap_data;
606 ULONG bytesread;
607 int depth, attribute_bitcount, attribute_type;
608 int i;
609
610 TRACE("(%p,%p)\n", iface, pIPalette);
611
612 if (!This->colormap_length)
613 {
614 WARN("no colormap present in this file\n");
616 }
617
618 if (This->header.colormap_firstentry + This->header.colormap_length > 256)
619 {
620 FIXME("cannot read colormap with %i entries starting at %i\n",
621 This->header.colormap_firstentry + This->header.colormap_length,
622 This->header.colormap_firstentry);
623 return E_FAIL;
624 }
625
626 colormap_data = malloc(This->colormap_length);
627 if (!colormap_data) return E_OUTOFMEMORY;
628
629 wcolormap_data = (WORD*)colormap_data;
630 dwcolormap_data = (DWORD*)colormap_data;
631
633
634 seek.QuadPart = This->colormap_offset;
635 hr = IStream_Seek(This->stream, seek, STREAM_SEEK_SET, NULL);
636
637 if (SUCCEEDED(hr))
638 {
639 hr = IStream_Read(This->stream, colormap_data, This->colormap_length, &bytesread);
640 if (SUCCEEDED(hr) && bytesread != This->colormap_length)
641 {
642 WARN("expected %li bytes in colormap, got %li\n", This->colormap_length, bytesread);
643 hr = E_FAIL;
644 }
645 }
646
648
649 if (SUCCEEDED(hr))
650 {
651 attribute_bitcount = This->header.image_descriptor & IMAGE_ATTRIBUTE_BITCOUNT_MASK;
652
653 if (attribute_bitcount && This->extension_area_offset)
654 attribute_type = This->extension_area.attributes_type;
655 else if (attribute_bitcount)
656 attribute_type = ATTRIBUTE_ALPHA;
657 else
658 attribute_type = ATTRIBUTE_NO_ALPHA;
659
660 depth = This->header.colormap_entrysize;
661 if (depth == 15)
662 {
663 depth = 16;
664 attribute_type = ATTRIBUTE_NO_ALPHA;
665 }
666
667 memset(colors, 0, sizeof(colors));
668
669 color = &colors[This->header.colormap_firstentry];
670
671 /* Colormap entries can be in any truecolor format, and we have to convert them. */
672 switch (depth)
673 {
674 case 16:
675 switch (attribute_type)
676 {
680 for (i=0; i<This->header.colormap_length; i++)
681 {
682 WORD srcval = wcolormap_data[i];
683 *color++=0xff000000 | /* constant 255 alpha */
684 ((srcval << 9) & 0xf80000) | /* r */
685 ((srcval << 4) & 0x070000) | /* r - 3 bits */
686 ((srcval << 6) & 0x00f800) | /* g */
687 ((srcval << 1) & 0x000700) | /* g - 3 bits */
688 ((srcval << 3) & 0x0000f8) | /* b */
689 ((srcval >> 2) & 0x000007); /* b - 3 bits */
690 }
691 break;
692 case ATTRIBUTE_ALPHA:
693 case ATTRIBUTE_PALPHA:
694 for (i=0; i<This->header.colormap_length; i++)
695 {
696 WORD srcval = wcolormap_data[i];
697 *color++=((srcval & 0x8000) ? 0xff000000 : 0) | /* alpha */
698 ((srcval << 9) & 0xf80000) | /* r */
699 ((srcval << 4) & 0x070000) | /* r - 3 bits */
700 ((srcval << 6) & 0x00f800) | /* g */
701 ((srcval << 1) & 0x000700) | /* g - 3 bits */
702 ((srcval << 3) & 0x0000f8) | /* b */
703 ((srcval >> 2) & 0x000007); /* b - 3 bits */
704 }
705 break;
706 default:
707 FIXME("Unhandled 16-bit attribute type %u\n", attribute_type);
708 hr = E_NOTIMPL;
709 }
710 break;
711 case 24:
712 for (i=0; i<This->header.colormap_length; i++)
713 {
714 *color++=0xff000000 | /* alpha */
715 colormap_data[i*3+2] | /* red */
716 colormap_data[i*3+1] | /* green */
717 colormap_data[i*3]; /* blue */
718 }
719 break;
720 case 32:
721 switch (attribute_type)
722 {
726 for (i=0; i<This->header.colormap_length; i++)
727 *color++=dwcolormap_data[i]|0xff000000;
728 break;
729 case ATTRIBUTE_ALPHA:
730 for (i=0; i<This->header.colormap_length; i++)
731 *color++=dwcolormap_data[i];
732 break;
733 case ATTRIBUTE_PALPHA:
734 /* FIXME: Unpremultiply alpha */
735 default:
736 FIXME("Unhandled 16-bit attribute type %u\n", attribute_type);
737 hr = E_NOTIMPL;
738 }
739 break;
740 default:
741 FIXME("Unhandled truecolor depth %u\n", This->header.depth);
742 hr = E_NOTIMPL;
743 }
744 }
745
746 free(colormap_data);
747
748 if (SUCCEEDED(hr))
749 hr = IWICPalette_InitializeCustom(pIPalette, colors, 256);
750
751 return hr;
752}
753
755{
756 int i=0, j, bytesperpixel;
757 ULONG bytesread;
759
760 bytesperpixel = This->header.depth / 8;
761
762 while (i<datasize)
763 {
764 BYTE rc;
765 int count, size;
766 BYTE pixeldata[4];
767
768 hr = IStream_Read(This->stream, &rc, 1, &bytesread);
769 if (bytesread != 1) hr = E_FAIL;
770 if (FAILED(hr)) break;
771
772 count = (rc&0x7f)+1;
773 size = count * bytesperpixel;
774
775 if (size + i > datasize)
776 {
777 WARN("RLE packet too large\n");
778 hr = E_FAIL;
779 break;
780 }
781
782 if (rc&0x80)
783 {
784 /* Run-length packet */
785 hr = IStream_Read(This->stream, pixeldata, bytesperpixel, &bytesread);
786 if (bytesread != bytesperpixel) hr = E_FAIL;
787 if (FAILED(hr)) break;
788
789 if (bytesperpixel == 1)
790 memset(&imagebits[i], pixeldata[0], count);
791 else
792 {
793 for (j=0; j<count; j++)
794 memcpy(&imagebits[i+j*bytesperpixel], pixeldata, bytesperpixel);
795 }
796 }
797 else
798 {
799 /* Raw packet */
800 hr = IStream_Read(This->stream, &imagebits[i], size, &bytesread);
801 if (bytesread != size) hr = E_FAIL;
802 if (FAILED(hr)) break;
803 }
804
805 i += size;
806 }
807
808 return hr;
809}
810
812{
814 int datasize;
816 ULONG bytesread;
817
818 if (This->imagebits)
819 return S_OK;
820
822
823 if (!This->imagebits)
824 {
825 if (This->header.image_descriptor & IMAGE_RIGHTTOLEFT)
826 {
827 FIXME("Right to left image reading not implemented\n");
828 hr = E_NOTIMPL;
829 }
830
831 if (SUCCEEDED(hr))
832 {
833 datasize = This->header.width * This->header.height * (This->header.depth / 8);
834 This->imagebits = malloc(datasize);
835 if (!This->imagebits) hr = E_OUTOFMEMORY;
836 }
837
838 if (SUCCEEDED(hr))
839 {
840 seek.QuadPart = This->image_offset;
841 hr = IStream_Seek(This->stream, seek, STREAM_SEEK_SET, NULL);
842 }
843
844 if (SUCCEEDED(hr))
845 {
846 if (This->header.image_type & IMAGETYPE_RLE)
847 {
848 hr = TgaDecoder_ReadRLE(This, This->imagebits, datasize);
849 }
850 else
851 {
852 hr = IStream_Read(This->stream, This->imagebits, datasize, &bytesread);
853 if (SUCCEEDED(hr) && bytesread != datasize)
854 hr = E_FAIL;
855 }
856 }
857
858 if (SUCCEEDED(hr))
859 {
860 if (This->header.image_descriptor & IMAGE_TOPTOBOTTOM)
861 {
862 This->origin = This->imagebits;
863 This->stride = This->header.width * (This->header.depth / 8);
864 }
865 else
866 {
867 This->stride = -This->header.width * (This->header.depth / 8);
868 This->origin = This->imagebits + This->header.width * (This->header.height - 1) * (This->header.depth / 8);
869 }
870 }
871 else
872 {
873 free(This->imagebits);
874 This->imagebits = NULL;
875 }
876 }
877
879
880 return hr;
881}
882
884 const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
885{
887 HRESULT hr;
888
889 TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
890
892
893 if (SUCCEEDED(hr))
894 {
895 hr = copy_pixels(This->header.depth, This->origin,
896 This->header.width, This->header.height, This->stride,
897 prc, cbStride, cbBufferSize, pbBuffer);
898 }
899
900 return hr;
901}
902
904 IWICMetadataQueryReader **ppIMetadataQueryReader)
905{
906 FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
908}
909
911 UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
912{
913 FIXME("(%p,%u,%p,%p): stub\n", iface, cCount, ppIColorContexts, pcActualCount);
915}
916
918 IWICBitmapSource **ppIThumbnail)
919{
920 FIXME("(%p,%p): stub\n", iface, ppIThumbnail);
922}
923
924static const IWICBitmapFrameDecodeVtbl TgaDecoder_Frame_Vtbl = {
936};
937
939{
941 HRESULT ret;
942
943 TRACE("(%s,%p)\n", debugstr_guid(iid), ppv);
944
945 *ppv = NULL;
946
947 This = malloc(sizeof(TgaDecoder));
948 if (!This) return E_OUTOFMEMORY;
949
950 This->IWICBitmapDecoder_iface.lpVtbl = &TgaDecoder_Vtbl;
951 This->IWICBitmapFrameDecode_iface.lpVtbl = &TgaDecoder_Frame_Vtbl;
952 This->ref = 1;
953 This->initialized = FALSE;
954 This->stream = NULL;
955 This->imagebits = NULL;
956#ifdef __REACTOS__
958#else
960#endif
961 This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": TgaDecoder.lock");
962
963 ret = IWICBitmapDecoder_QueryInterface(&This->IWICBitmapDecoder_iface, iid, ppv);
964 IWICBitmapDecoder_Release(&This->IWICBitmapDecoder_iface);
965
966 return ret;
967}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#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
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
static SIZE_T datasize
Definition: asm.c:30
void copy_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *size, const struct pixel_format_desc *format) DECLSPEC_HIDDEN
Definition: surface.c:1700
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#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
static GpStatus get_decoder_info(IStream *stream, const struct image_codec **result)
Definition: image.c:4285
BOOL WINAPI InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection, IN DWORD dwSpinCount, IN DWORD flags)
Definition: sync.c:107
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLuint color
Definition: glext.h:6243
GLuint index
Definition: glext.h:6031
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
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 GLint GLint j
Definition: glfuncs.h:250
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
#define debugstr_guid
Definition: kernel32.h:35
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int UINT
Definition: ndis.h:50
_Out_ LPRECT prc
Definition: ntgdi.h:1658
long LONG
Definition: pedump.c:60
#define IsEqualIID(riid1, riid2)
Definition: guiddef.h:95
#define REFIID
Definition: guiddef.h:118
int seek(void *fd, ulong off, int mode)
Definition: pe.c:51
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
tga_header header
Definition: tgaformat.c:104
tga_extension_area extension_area
Definition: tgaformat.c:105
IStream * stream
Definition: tgaformat.c:103
BYTE * origin
Definition: tgaformat.c:107
IWICBitmapFrameDecode IWICBitmapFrameDecode_iface
Definition: tgaformat.c:100
ULONG id_offset
Definition: tgaformat.c:109
ULONG image_offset
Definition: tgaformat.c:112
BOOL initialized
Definition: tgaformat.c:102
ULONG developer_directory_offset
Definition: tgaformat.c:114
ULONG colormap_offset
Definition: tgaformat.c:111
ULONG extension_area_offset
Definition: tgaformat.c:113
CRITICAL_SECTION lock
Definition: tgaformat.c:115
int stride
Definition: tgaformat.c:108
IWICBitmapDecoder IWICBitmapDecoder_iface
Definition: tgaformat.c:99
LONG ref
Definition: tgaformat.c:101
ULONG colormap_length
Definition: tgaformat.c:110
BYTE * imagebits
Definition: tgaformat.c:106
Definition: send.c:48
Definition: parse.h:23
DWORD thumbnail_offset
Definition: tgaformat.c:85
DWORD color_correction_offset
Definition: tgaformat.c:84
char software_version_letter
Definition: tgaformat.c:78
DWORD scanline_offset
Definition: tgaformat.c:86
WORD gamma_denominator
Definition: tgaformat.c:83
BYTE id_length
Definition: tgaformat.c:36
BYTE depth
Definition: tgaformat.c:48
WORD yorigin
Definition: tgaformat.c:45
WORD height
Definition: tgaformat.c:47
BYTE colormap_entrysize
Definition: tgaformat.c:42
WORD colormap_length
Definition: tgaformat.c:41
WORD xorigin
Definition: tgaformat.c:44
BYTE image_descriptor
Definition: tgaformat.c:49
BYTE colormap_type
Definition: tgaformat.c:37
WORD colormap_firstentry
Definition: tgaformat.c:40
WORD width
Definition: tgaformat.c:46
BYTE image_type
Definition: tgaformat.c:38
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
static HRESULT WINAPI TgaDecoder_Frame_GetPixelFormat(IWICBitmapFrameDecode *iface, WICPixelFormatGUID *pPixelFormat)
Definition: tgaformat.c:489
#define ATTRIBUTE_ALPHA
Definition: tgaformat.c:93
static const IWICBitmapFrameDecodeVtbl TgaDecoder_Frame_Vtbl
Definition: tgaformat.c:924
#define ATTRIBUTE_NO_ALPHA
Definition: tgaformat.c:90
static HRESULT TgaDecoder_ReadImage(TgaDecoder *This)
Definition: tgaformat.c:811
static HRESULT WINAPI TgaDecoder_Frame_CopyPalette(IWICBitmapFrameDecode *iface, IWICPalette *pIPalette)
Definition: tgaformat.c:596
#define IMAGE_ATTRIBUTE_BITCOUNT_MASK
Definition: tgaformat.c:57
static HRESULT WINAPI TgaDecoder_GetDecoderInfo(IWICBitmapDecoder *iface, IWICBitmapDecoderInfo **ppIDecoderInfo)
Definition: tgaformat.c:356
static HRESULT WINAPI TgaDecoder_QueryCapability(IWICBitmapDecoder *iface, IStream *stream, DWORD *capability)
Definition: tgaformat.c:180
static HRESULT WINAPI TgaDecoder_GetFrame(IWICBitmapDecoder *iface, UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
Definition: tgaformat.c:408
static HRESULT WINAPI TgaDecoder_GetContainerFormat(IWICBitmapDecoder *iface, GUID *pguidContainerFormat)
Definition: tgaformat.c:349
HRESULT TgaDecoder_CreateInstance(REFIID iid, void **ppv)
Definition: tgaformat.c:938
static HRESULT WINAPI TgaDecoder_Frame_GetSize(IWICBitmapFrameDecode *iface, UINT *puiWidth, UINT *puiHeight)
Definition: tgaformat.c:476
static const IWICBitmapDecoderVtbl TgaDecoder_Vtbl
Definition: tgaformat.c:424
static const BYTE tga_footer_magic[18]
Definition: tgaformat.c:67
#define IMAGETYPE_COLORMAPPED
Definition: tgaformat.c:52
static HRESULT WINAPI TgaDecoder_GetFrameCount(IWICBitmapDecoder *iface, UINT *pCount)
Definition: tgaformat.c:399
static HRESULT WINAPI TgaDecoder_Frame_GetThumbnail(IWICBitmapFrameDecode *iface, IWICBitmapSource **ppIThumbnail)
Definition: tgaformat.c:917
static HRESULT WINAPI TgaDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface, IWICMetadataQueryReader **ppIMetadataQueryReader)
Definition: tgaformat.c:371
static HRESULT TgaDecoder_ReadRLE(TgaDecoder *This, BYTE *imagebits, int datasize)
Definition: tgaformat.c:754
static HRESULT WINAPI TgaDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream, WICDecodeOptions cacheOptions)
Definition: tgaformat.c:197
static HRESULT WINAPI TgaDecoder_GetColorContexts(IWICBitmapDecoder *iface, UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
Definition: tgaformat.c:385
static ULONG WINAPI TgaDecoder_Release(IWICBitmapDecoder *iface)
Definition: tgaformat.c:160
#define IMAGE_RIGHTTOLEFT
Definition: tgaformat.c:58
#define IMAGE_TOPTOBOTTOM
Definition: tgaformat.c:59
static HRESULT WINAPI TgaDecoder_Frame_GetMetadataQueryReader(IWICBitmapFrameDecode *iface, IWICMetadataQueryReader **ppIMetadataQueryReader)
Definition: tgaformat.c:903
#define ATTRIBUTE_UNDEFINED_PRESERVE
Definition: tgaformat.c:92
static ULONG WINAPI TgaDecoder_Frame_Release(IWICBitmapFrameDecode *iface)
Definition: tgaformat.c:470
static HRESULT WINAPI TgaDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid, void **ppv)
Definition: tgaformat.c:128
static HRESULT WINAPI TgaDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
Definition: tgaformat.c:883
static HRESULT WINAPI TgaDecoder_GetThumbnail(IWICBitmapDecoder *iface, IWICBitmapSource **ppIThumbnail)
Definition: tgaformat.c:392
static HRESULT WINAPI TgaDecoder_GetPreview(IWICBitmapDecoder *iface, IWICBitmapSource **ppIBitmapSource)
Definition: tgaformat.c:378
static ULONG WINAPI TgaDecoder_Frame_AddRef(IWICBitmapFrameDecode *iface)
Definition: tgaformat.c:464
static TgaDecoder * impl_from_IWICBitmapDecoder(IWICBitmapDecoder *iface)
Definition: tgaformat.c:118
#define IMAGETYPE_GRAYSCALE
Definition: tgaformat.c:54
#define IMAGETYPE_RLE
Definition: tgaformat.c:55
#define ATTRIBUTE_UNDEFINED
Definition: tgaformat.c:91
#define IMAGETYPE_TRUECOLOR
Definition: tgaformat.c:53
#define ATTRIBUTE_PALPHA
Definition: tgaformat.c:94
static HRESULT WINAPI TgaDecoder_Frame_QueryInterface(IWICBitmapFrameDecode *iface, REFIID iid, void **ppv)
Definition: tgaformat.c:441
static TgaDecoder * impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode *iface)
Definition: tgaformat.c:123
static HRESULT WINAPI TgaDecoder_Frame_GetColorContexts(IWICBitmapFrameDecode *iface, UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
Definition: tgaformat.c:910
static HRESULT WINAPI TgaDecoder_CopyPalette(IWICBitmapDecoder *iface, IWICPalette *pIPalette)
Definition: tgaformat.c:364
static HRESULT WINAPI TgaDecoder_Frame_GetResolution(IWICBitmapFrameDecode *iface, double *pDpiX, double *pDpiY)
Definition: tgaformat.c:589
static ULONG WINAPI TgaDecoder_AddRef(IWICBitmapDecoder *iface)
Definition: tgaformat.c:150
#define DWORD_PTR
Definition: treelist.c:76
int64_t LONGLONG
Definition: typedefs.h:68
#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)
WICDecodeOptions
Definition: wincodec.idl:28
@ WICDecodeMetadataCacheOnDemand
Definition: wincodec.idl:29
UINT32 WICColor
Definition: wincodec.idl:364
@ WICBitmapDecoderCapabilityCanDecodeSomeImages
Definition: wincodec.idl:51
@ WICBitmapDecoderCapabilityCanDecodeAllImages
Definition: wincodec.idl:50
static const char * debug_wic_rect(const WICRect *rect)
#define WINAPI
Definition: msvc.h:6
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3281
#define WINCODEC_ERR_UNSUPPORTEDOPERATION
Definition: winerror.h:3308
#define E_NOINTERFACE
Definition: winerror.h:2364
#define WINCODEC_ERR_PALETTEUNAVAILABLE
Definition: winerror.h:3292
#define WINCODEC_ERR_CODECNOTHUMBNAIL
Definition: winerror.h:3291
#define WINCODEC_ERR_FRAMEMISSING
Definition: winerror.h:3301
#define RTL_CRITICAL_SECTION_FLAG_FORCE_DEBUG_INFO
Definition: winnt_old.h:1116
unsigned char BYTE
Definition: xxhash.c:193