windowscodecs: Add stub JPEG encoder.

This commit is contained in:
Vincent Povirk 2011-06-10 14:17:17 -05:00 committed by Alexandre Julliard
parent cdc2c53158
commit 2e2b045db0
5 changed files with 193 additions and 0 deletions

View File

@ -53,6 +53,7 @@ static classinfo wic_classes[] = {
{&CLSID_WICGifDecoder, GifDecoder_CreateInstance}, {&CLSID_WICGifDecoder, GifDecoder_CreateInstance},
{&CLSID_WICIcoDecoder, IcoDecoder_CreateInstance}, {&CLSID_WICIcoDecoder, IcoDecoder_CreateInstance},
{&CLSID_WICJpegDecoder, JpegDecoder_CreateInstance}, {&CLSID_WICJpegDecoder, JpegDecoder_CreateInstance},
{&CLSID_WICJpegEncoder, JpegEncoder_CreateInstance},
{&CLSID_WICTiffDecoder, TiffDecoder_CreateInstance}, {&CLSID_WICTiffDecoder, TiffDecoder_CreateInstance},
{&CLSID_WICTiffEncoder, TiffEncoder_CreateInstance}, {&CLSID_WICTiffEncoder, TiffEncoder_CreateInstance},
{&CLSID_WICIcnsEncoder, IcnsEncoder_CreateInstance}, {&CLSID_WICIcnsEncoder, IcnsEncoder_CreateInstance},

View File

@ -697,6 +697,175 @@ HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
return ret; return ret;
} }
typedef struct JpegEncoder {
IWICBitmapEncoder IWICBitmapEncoder_iface;
LONG ref;
} JpegEncoder;
static inline JpegEncoder *impl_from_IWICBitmapEncoder(IWICBitmapEncoder *iface)
{
return CONTAINING_RECORD(iface, JpegEncoder, IWICBitmapEncoder_iface);
}
static HRESULT WINAPI JpegEncoder_QueryInterface(IWICBitmapEncoder *iface, REFIID iid,
void **ppv)
{
JpegEncoder *This = impl_from_IWICBitmapEncoder(iface);
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
if (!ppv) return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, iid) ||
IsEqualIID(&IID_IWICBitmapEncoder, iid))
{
*ppv = This;
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
static ULONG WINAPI JpegEncoder_AddRef(IWICBitmapEncoder *iface)
{
JpegEncoder *This = impl_from_IWICBitmapEncoder(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) refcount=%u\n", iface, ref);
return ref;
}
static ULONG WINAPI JpegEncoder_Release(IWICBitmapEncoder *iface)
{
JpegEncoder *This = impl_from_IWICBitmapEncoder(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 JpegEncoder_Initialize(IWICBitmapEncoder *iface,
IStream *pIStream, WICBitmapEncoderCacheOption cacheOption)
{
FIXME("(%p,%p,%u): stub\n", iface, pIStream, cacheOption);
return E_NOTIMPL;
}
static HRESULT WINAPI JpegEncoder_GetContainerFormat(IWICBitmapEncoder *iface,
GUID *pguidContainerFormat)
{
FIXME("(%p,%s): stub\n", iface, debugstr_guid(pguidContainerFormat));
return E_NOTIMPL;
}
static HRESULT WINAPI JpegEncoder_GetEncoderInfo(IWICBitmapEncoder *iface,
IWICBitmapEncoderInfo **ppIEncoderInfo)
{
FIXME("(%p,%p): stub\n", iface, ppIEncoderInfo);
return E_NOTIMPL;
}
static HRESULT WINAPI JpegEncoder_SetColorContexts(IWICBitmapEncoder *iface,
UINT cCount, IWICColorContext **ppIColorContext)
{
FIXME("(%p,%u,%p): stub\n", iface, cCount, ppIColorContext);
return E_NOTIMPL;
}
static HRESULT WINAPI JpegEncoder_SetPalette(IWICBitmapEncoder *iface, IWICPalette *pIPalette)
{
TRACE("(%p,%p)\n", iface, pIPalette);
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI JpegEncoder_SetThumbnail(IWICBitmapEncoder *iface, IWICBitmapSource *pIThumbnail)
{
TRACE("(%p,%p)\n", iface, pIThumbnail);
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI JpegEncoder_SetPreview(IWICBitmapEncoder *iface, IWICBitmapSource *pIPreview)
{
TRACE("(%p,%p)\n", iface, pIPreview);
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI JpegEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
IWICBitmapFrameEncode **ppIFrameEncode, IPropertyBag2 **ppIEncoderOptions)
{
FIXME("(%p,%p,%p): stub\n", iface, ppIFrameEncode, ppIEncoderOptions);
return E_NOTIMPL;
}
static HRESULT WINAPI JpegEncoder_Commit(IWICBitmapEncoder *iface)
{
FIXME("(%p): stub\n", iface);
return E_NOTIMPL;
}
static HRESULT WINAPI JpegEncoder_GetMetadataQueryWriter(IWICBitmapEncoder *iface,
IWICMetadataQueryWriter **ppIMetadataQueryWriter)
{
FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryWriter);
return E_NOTIMPL;
}
static const IWICBitmapEncoderVtbl JpegEncoder_Vtbl = {
JpegEncoder_QueryInterface,
JpegEncoder_AddRef,
JpegEncoder_Release,
JpegEncoder_Initialize,
JpegEncoder_GetContainerFormat,
JpegEncoder_GetEncoderInfo,
JpegEncoder_SetColorContexts,
JpegEncoder_SetPalette,
JpegEncoder_SetThumbnail,
JpegEncoder_SetPreview,
JpegEncoder_CreateNewFrame,
JpegEncoder_Commit,
JpegEncoder_GetMetadataQueryWriter
};
HRESULT JpegEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
{
JpegEncoder *This;
HRESULT ret;
TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv);
*ppv = NULL;
if (pUnkOuter) return CLASS_E_NOAGGREGATION;
if (!libjpeg_handle && !load_libjpeg())
{
ERR("Failed writing JPEG because unable to find %s\n",SONAME_LIBJPEG);
return E_FAIL;
}
This = HeapAlloc(GetProcessHeap(), 0, sizeof(JpegEncoder));
if (!This) return E_OUTOFMEMORY;
This->IWICBitmapEncoder_iface.lpVtbl = &JpegEncoder_Vtbl;
This->ref = 1;
ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
IUnknown_Release((IUnknown*)This);
return ret;
}
#else /* !defined(SONAME_LIBJPEG) */ #else /* !defined(SONAME_LIBJPEG) */
HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
@ -705,4 +874,10 @@ HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
return E_FAIL; return E_FAIL;
} }
HRESULT JpegEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
{
ERR("Trying to save JPEG picture, but JPEG support is not compiled in.\n");
return E_FAIL;
}
#endif #endif

View File

@ -937,6 +937,15 @@ static struct regsvr_encoder const encoder_list[] = {
".bmp,.dib,.rle", ".bmp,.dib,.rle",
bmp_encode_formats bmp_encode_formats
}, },
{ &CLSID_WICJpegEncoder,
"The Wine Project",
"JPEG Encoder",
"1.0.0.0",
&GUID_VendorMicrosoft,
"image/jpeg",
".jpg;.jpeg;.jfif",
jpeg_formats
},
{ &CLSID_WICPngEncoder, { &CLSID_WICPngEncoder,
"The Wine Project", "The Wine Project",
"PNG Encoder", "PNG Encoder",

View File

@ -37,6 +37,7 @@ extern HRESULT DibDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void**
extern HRESULT GifDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv) DECLSPEC_HIDDEN; extern HRESULT GifDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv) DECLSPEC_HIDDEN;
extern HRESULT IcoDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) DECLSPEC_HIDDEN; extern HRESULT IcoDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) DECLSPEC_HIDDEN;
extern HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) DECLSPEC_HIDDEN; extern HRESULT JpegDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) DECLSPEC_HIDDEN;
extern HRESULT JpegEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) DECLSPEC_HIDDEN;
extern HRESULT TiffDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) DECLSPEC_HIDDEN; extern HRESULT TiffDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) DECLSPEC_HIDDEN;
extern HRESULT TiffEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) DECLSPEC_HIDDEN; extern HRESULT TiffEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) DECLSPEC_HIDDEN;
extern HRESULT IcnsEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) DECLSPEC_HIDDEN; extern HRESULT IcnsEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) DECLSPEC_HIDDEN;

View File

@ -80,6 +80,13 @@ coclass WICIcoDecoder { interface IWICBitmapDecoder; }
] ]
coclass WICJpegDecoder { interface IWICBitmapDecoder; } coclass WICJpegDecoder { interface IWICBitmapDecoder; }
[
helpstring("WIC JPEG Encoder"),
threading(both),
uuid(1a34f5c1-4a5a-46dc-b644-1f4567e7a676)
]
coclass WICJpegEncoder { interface IWICBitmapEncoder; }
[ [
helpstring("WIC TIFF Decoder"), helpstring("WIC TIFF Decoder"),
threading(both), threading(both),