Commit 7bf6ad91 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

windowscodecs: Add stub TGA decoder.

parent b9beb922
......@@ -21,6 +21,7 @@ C_SRCS = \
propertybag.c \
regsvr.c \
stream.c \
tgaformat.c \
tiffformat.c \
ungif.c
......
......@@ -53,6 +53,7 @@ static classinfo wic_classes[] = {
{&CLSID_WICTiffDecoder, TiffDecoder_CreateInstance},
{&CLSID_WICIcnsEncoder, IcnsEncoder_CreateInstance},
{&CLSID_WICDefaultFormatConverter, FormatConverter_CreateInstance},
{&CLSID_WineTgaDecoder, TgaDecoder_CreateInstance},
{0}};
typedef struct {
......
......@@ -978,13 +978,19 @@ static struct regsvr_coclass const coclass_list[] = {
"windowscodecs.dll",
"Both"
},
{ &CLSID_WineTgaDecoder,
"WIC TGA Decoder",
NULL,
"windowscodecs.dll",
"Both"
},
{ NULL } /* list terminator */
};
/***********************************************************************
* decoder list
*/
static const BYTE mask_all[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
static const BYTE mask_all[] = {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
static const BYTE bmp_magic[] = {0x42,0x4d};
......@@ -1094,6 +1100,36 @@ static struct decoder_pattern const tiff_patterns[] = {
{0}
};
static const BYTE tga_footer_magic[18] = "TRUEVISION-XFILE.";
static const BYTE tga_indexed_magic[18] = {0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0};
static const BYTE tga_indexed_mask[18] = {0,0xff,0xf7,0,0,0,0,0,0,0,0,0,0,0,0,0,0xff,0xcf};
static const BYTE tga_truecolor_magic[18] = {0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
static const BYTE tga_truecolor_mask[18] = {0,0xff,0xf7,0,0,0,0,0,0,0,0,0,0,0,0,0,0x87,0xc0};
static const BYTE tga_grayscale_magic[18] = {0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0};
static const BYTE tga_grayscale_mask[18] = {0,0xff,0xf7,0,0,0,0,0,0,0,0,0,0,0,0,0,0xff,0xcf};
static GUID const * const tga_formats[] = {
&GUID_WICPixelFormat8bppGray,
&GUID_WICPixelFormat8bppIndexed,
&GUID_WICPixelFormat16bppGray,
&GUID_WICPixelFormat16bppBGR555,
&GUID_WICPixelFormat24bppBGR,
&GUID_WICPixelFormat32bppBGRA,
&GUID_WICPixelFormat32bppPBGRA,
NULL
};
static struct decoder_pattern const tga_patterns[] = {
{18,18,tga_footer_magic,mask_all,1},
{18,0,tga_indexed_magic,tga_indexed_mask,0},
{18,0,tga_truecolor_magic,tga_truecolor_mask,0},
{18,0,tga_grayscale_magic,tga_grayscale_mask,0},
{0}
};
static struct regsvr_decoder const decoder_list[] = {
{ &CLSID_WICBmpDecoder,
"The Wine Project",
......@@ -1155,6 +1191,16 @@ static struct regsvr_decoder const decoder_list[] = {
tiff_formats,
tiff_patterns
},
{ &CLSID_WineTgaDecoder,
"The Wine Project",
"TGA Decoder",
"1.0.0.0",
&GUID_VendorWine,
"image/x-targa",
".tga;.tpic",
tga_formats,
tga_patterns
},
{ NULL } /* list terminator */
};
......
/*
* Copyright 2010 Vincent Povirk for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "wincodec.h"
#include "wincodecs_private.h"
#include "wine/debug.h"
#include "wine/library.h"
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
typedef struct {
const IWICBitmapDecoderVtbl *lpVtbl;
const IWICBitmapFrameDecodeVtbl *lpFrameVtbl;
LONG ref;
} TgaDecoder;
static inline TgaDecoder *decoder_from_frame(IWICBitmapFrameDecode *iface)
{
return CONTAINING_RECORD(iface, TgaDecoder, lpFrameVtbl);
}
static HRESULT WINAPI TgaDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid,
void **ppv)
{
TgaDecoder *This = (TgaDecoder*)iface;
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
if (!ppv) return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IWICBitmapDecoder, iid))
{
*ppv = This;
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI TgaDecoder_AddRef(IWICBitmapDecoder *iface)
{
TgaDecoder *This = (TgaDecoder*)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) refcount=%u\n", iface, ref);
return ref;
}
static ULONG WINAPI TgaDecoder_Release(IWICBitmapDecoder *iface)
{
TgaDecoder *This = (TgaDecoder*)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) refcount=%u\n", iface, ref);
if (ref == 0)
{
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
static HRESULT WINAPI TgaDecoder_QueryCapability(IWICBitmapDecoder *iface, IStream *pIStream,
DWORD *pdwCapability)
{
FIXME("(%p,%p,%p): stub\n", iface, pIStream, pdwCapability);
return E_NOTIMPL;
}
static HRESULT WINAPI TgaDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream,
WICDecodeOptions cacheOptions)
{
FIXME("(%p,%p,%u): stub\n", iface, pIStream, cacheOptions);
return E_NOTIMPL;
}
static HRESULT WINAPI TgaDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
GUID *pguidContainerFormat)
{
memcpy(pguidContainerFormat, &GUID_WineContainerFormatTga, sizeof(GUID));
return S_OK;
}
static HRESULT WINAPI TgaDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
IWICBitmapDecoderInfo **ppIDecoderInfo)
{
FIXME("(%p,%p): stub\n", iface, ppIDecoderInfo);
return E_NOTIMPL;
}
static HRESULT WINAPI TgaDecoder_CopyPalette(IWICBitmapDecoder *iface,
IWICPalette *pIPalette)
{
FIXME("(%p,%p): stub\n", iface, pIPalette);
return E_NOTIMPL;
}
static HRESULT WINAPI TgaDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
IWICMetadataQueryReader **ppIMetadataQueryReader)
{
FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
return E_NOTIMPL;
}
static HRESULT WINAPI TgaDecoder_GetPreview(IWICBitmapDecoder *iface,
IWICBitmapSource **ppIBitmapSource)
{
FIXME("(%p,%p): stub\n", iface, ppIBitmapSource);
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI TgaDecoder_GetColorContexts(IWICBitmapDecoder *iface,
UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
{
FIXME("(%p,%u,%p,%p): stub\n", iface, cCount, ppIColorContexts, pcActualCount);
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI TgaDecoder_GetThumbnail(IWICBitmapDecoder *iface,
IWICBitmapSource **ppIThumbnail)
{
FIXME("(%p,%p): stub\n", iface, ppIThumbnail);
return WINCODEC_ERR_CODECNOTHUMBNAIL;
}
static HRESULT WINAPI TgaDecoder_GetFrameCount(IWICBitmapDecoder *iface,
UINT *pCount)
{
*pCount = 1;
return S_OK;
}
static HRESULT WINAPI TgaDecoder_GetFrame(IWICBitmapDecoder *iface,
UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
{
FIXME("(%p,%p): stub\n", iface, ppIBitmapFrame);
return E_NOTIMPL;
}
static const IWICBitmapDecoderVtbl TgaDecoder_Vtbl = {
TgaDecoder_QueryInterface,
TgaDecoder_AddRef,
TgaDecoder_Release,
TgaDecoder_QueryCapability,
TgaDecoder_Initialize,
TgaDecoder_GetContainerFormat,
TgaDecoder_GetDecoderInfo,
TgaDecoder_CopyPalette,
TgaDecoder_GetMetadataQueryReader,
TgaDecoder_GetPreview,
TgaDecoder_GetColorContexts,
TgaDecoder_GetThumbnail,
TgaDecoder_GetFrameCount,
TgaDecoder_GetFrame
};
static HRESULT WINAPI TgaDecoder_Frame_QueryInterface(IWICBitmapFrameDecode *iface, REFIID iid,
void **ppv)
{
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
if (!ppv) return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, iid) ||
IsEqualIID(&IID_IWICBitmapSource, iid) ||
IsEqualIID(&IID_IWICBitmapFrameDecode, iid))
{
*ppv = iface;
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI TgaDecoder_Frame_AddRef(IWICBitmapFrameDecode *iface)
{
TgaDecoder *This = decoder_from_frame(iface);
return IUnknown_AddRef((IUnknown*)This);
}
static ULONG WINAPI TgaDecoder_Frame_Release(IWICBitmapFrameDecode *iface)
{
TgaDecoder *This = decoder_from_frame(iface);
return IUnknown_Release((IUnknown*)This);
}
static HRESULT WINAPI TgaDecoder_Frame_GetSize(IWICBitmapFrameDecode *iface,
UINT *puiWidth, UINT *puiHeight)
{
FIXME("(%p)\n", iface);
return E_NOTIMPL;
}
static HRESULT WINAPI TgaDecoder_Frame_GetPixelFormat(IWICBitmapFrameDecode *iface,
WICPixelFormatGUID *pPixelFormat)
{
TRACE("(%p,%p): stub\n", iface, pPixelFormat);
return E_NOTIMPL;
}
static HRESULT WINAPI TgaDecoder_Frame_GetResolution(IWICBitmapFrameDecode *iface,
double *pDpiX, double *pDpiY)
{
FIXME("(%p,%p,%p): stub\n", iface, pDpiX, pDpiY);
return E_NOTIMPL;
}
static HRESULT WINAPI TgaDecoder_Frame_CopyPalette(IWICBitmapFrameDecode *iface,
IWICPalette *pIPalette)
{
FIXME("(%p,%p): stub\n", iface, pIPalette);
return E_NOTIMPL;
}
static HRESULT WINAPI TgaDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
{
FIXME("(%p,%p,%u,%u,%p):stub\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
return E_NOTIMPL;
}
static HRESULT WINAPI TgaDecoder_Frame_GetMetadataQueryReader(IWICBitmapFrameDecode *iface,
IWICMetadataQueryReader **ppIMetadataQueryReader)
{
FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI TgaDecoder_Frame_GetColorContexts(IWICBitmapFrameDecode *iface,
UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
{
FIXME("(%p,%u,%p,%p): stub\n", iface, cCount, ppIColorContexts, pcActualCount);
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI TgaDecoder_Frame_GetThumbnail(IWICBitmapFrameDecode *iface,
IWICBitmapSource **ppIThumbnail)
{
FIXME("(%p,%p): stub\n", iface, ppIThumbnail);
return WINCODEC_ERR_CODECNOTHUMBNAIL;
}
static const IWICBitmapFrameDecodeVtbl TgaDecoder_Frame_Vtbl = {
TgaDecoder_Frame_QueryInterface,
TgaDecoder_Frame_AddRef,
TgaDecoder_Frame_Release,
TgaDecoder_Frame_GetSize,
TgaDecoder_Frame_GetPixelFormat,
TgaDecoder_Frame_GetResolution,
TgaDecoder_Frame_CopyPalette,
TgaDecoder_Frame_CopyPixels,
TgaDecoder_Frame_GetMetadataQueryReader,
TgaDecoder_Frame_GetColorContexts,
TgaDecoder_Frame_GetThumbnail
};
HRESULT TgaDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
{
TgaDecoder *This;
HRESULT ret;
TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
*ppv = NULL;
if (pUnkOuter) return CLASS_E_NOAGGREGATION;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(TgaDecoder));
if (!This) return E_OUTOFMEMORY;
This->lpVtbl = &TgaDecoder_Vtbl;
This->lpFrameVtbl = &TgaDecoder_Frame_Vtbl;
This->ref = 1;
ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
IUnknown_Release((IUnknown*)This);
return ret;
}
......@@ -19,8 +19,12 @@
#ifndef WINCODECS_PRIVATE_H
#define WINCODECS_PRIVATE_H
DEFINE_GUID(CLSID_WineTgaDecoder, 0xb11fc79a,0x67cc,0x43e6,0xa9,0xce,0xe3,0xd5,0x49,0x45,0xd3,0x04);
DEFINE_GUID(CLSID_WICIcnsEncoder, 0x312fb6f1,0xb767,0x409d,0x8a,0x6d,0x0f,0xc1,0x54,0xd4,0xf0,0x5c);
DEFINE_GUID(GUID_WineContainerFormatTga, 0x0c44fda1,0xa5c5,0x4298,0x96,0x85,0x47,0x3f,0xc1,0x7c,0xd3,0x22);
DEFINE_GUID(GUID_VendorWine, 0xddf46da1,0x7dc1,0x404e,0x98,0xf2,0xef,0xa4,0x8d,0xfc,0x95,0x0a);
extern HRESULT FormatConverter_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv);
......@@ -37,6 +41,7 @@ extern HRESULT TiffDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void*
extern HRESULT IcnsEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv);
extern HRESULT IcoDibDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv);
extern HRESULT TgaDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv);
extern HRESULT FlipRotator_Create(IWICBitmapFlipRotator **fliprotator);
extern HRESULT PaletteImpl_Create(IWICPalette **palette);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment