From 615f615a9126b67ac0a7162b6aaf9972c98e89b6 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Mon, 7 Jun 2010 16:36:27 -0500 Subject: [PATCH 4/7] windowscodecs: Implement GetPixelFormat for the TGA decoder. --- dlls/windowscodecs/tgaformat.c | 62 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 60 insertions(+), 2 deletions(-) diff --git a/dlls/windowscodecs/tgaformat.c b/dlls/windowscodecs/tgaformat.c index 74fa792..9b30ffb 100644 --- a/dlls/windowscodecs/tgaformat.c +++ b/dlls/windowscodecs/tgaformat.c @@ -354,8 +354,66 @@ static HRESULT WINAPI TgaDecoder_Frame_GetSize(IWICBitmapFrameDecode *iface, static HRESULT WINAPI TgaDecoder_Frame_GetPixelFormat(IWICBitmapFrameDecode *iface, WICPixelFormatGUID *pPixelFormat) { - TRACE("(%p,%p): stub\n", iface, pPixelFormat); - return E_NOTIMPL; + TgaDecoder *This = decoder_from_frame(iface); + int attribute_bitcount; + + TRACE("(%p,%p)\n", iface, pPixelFormat); + + attribute_bitcount = This->header.image_descriptor & IMAGE_ATTRIBUTE_BITCOUNT_MASK; + + if (attribute_bitcount) + { + FIXME("Need to read footer to find meaning of attribute bits\n"); + return E_NOTIMPL; + } + + switch (This->header.image_type & ~IMAGETYPE_RLE) + { + case IMAGETYPE_COLORMAPPED: + switch (This->header.depth) + { + case 8: + memcpy(pPixelFormat, &GUID_WICPixelFormat8bppIndexed, sizeof(GUID)); + break; + default: + FIXME("Unhandled indexed color depth %u\n", This->header.depth); + return E_NOTIMPL; + } + break; + case IMAGETYPE_TRUECOLOR: + switch (This->header.depth) + { + case 16: + memcpy(pPixelFormat, &GUID_WICPixelFormat16bppBGR555, sizeof(GUID)); + break; + case 24: + memcpy(pPixelFormat, &GUID_WICPixelFormat24bppBGR, sizeof(GUID)); + break; + default: + FIXME("Unhandled truecolor depth %u\n", This->header.depth); + return E_NOTIMPL; + } + break; + case IMAGETYPE_GRAYSCALE: + switch (This->header.depth) + { + case 8: + memcpy(pPixelFormat, &GUID_WICPixelFormat8bppGray, sizeof(GUID)); + break; + case 16: + memcpy(pPixelFormat, &GUID_WICPixelFormat16bppGray, sizeof(GUID)); + break; + default: + FIXME("Unhandled grayscale depth %u\n", This->header.depth); + return E_NOTIMPL; + } + break; + default: + ERR("Unknown image type %u\n", This->header.image_type); + return E_FAIL; + } + + return S_OK; } static HRESULT WINAPI TgaDecoder_Frame_GetResolution(IWICBitmapFrameDecode *iface, -- 1.7.0.4