mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-28 14:38:21 +01:00
Merge "wicdec: silence some warnings"
This commit is contained in:
commit
1262f81e37
@ -70,10 +70,10 @@ typedef enum {
|
|||||||
|
|
||||||
#define IFS(fn) \
|
#define IFS(fn) \
|
||||||
do { \
|
do { \
|
||||||
if (SUCCEEDED(hr)) { \
|
if (SUCCEEDED(hr)) { \
|
||||||
hr = (fn); \
|
hr = (fn); \
|
||||||
if (FAILED(hr)) fprintf(stderr, #fn " failed %08x\n", hr); \
|
if (FAILED(hr)) fprintf(stderr, #fn " failed %08lx\n", hr); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -86,8 +86,10 @@ static HRESULT CreateOutputStream(const char* out_file_name,
|
|||||||
IStream** ppStream) {
|
IStream** ppStream) {
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
IFS(SHCreateStreamOnFileA(out_file_name, STGM_WRITE | STGM_CREATE, ppStream));
|
IFS(SHCreateStreamOnFileA(out_file_name, STGM_WRITE | STGM_CREATE, ppStream));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr)) {
|
||||||
fprintf(stderr, "Error opening output file %s (%08x)\n", out_file_name, hr);
|
fprintf(stderr, "Error opening output file %s (%08lx)\n",
|
||||||
|
out_file_name, hr);
|
||||||
|
}
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@
|
|||||||
|
|
||||||
#define IFS(fn) \
|
#define IFS(fn) \
|
||||||
do { \
|
do { \
|
||||||
if (SUCCEEDED(hr)) { \
|
if (SUCCEEDED(hr)) { \
|
||||||
hr = (fn); \
|
hr = (fn); \
|
||||||
if (FAILED(hr)) fprintf(stderr, #fn " failed %08x\n", hr); \
|
if (FAILED(hr)) fprintf(stderr, #fn " failed %08lx\n", hr); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
// modified version of DEFINE_GUID from guiddef.h.
|
// modified version of DEFINE_GUID from guiddef.h.
|
||||||
@ -57,11 +57,15 @@ typedef struct WICFormatImporter {
|
|||||||
static HRESULT OpenInputStream(const char* filename, IStream** ppStream) {
|
static HRESULT OpenInputStream(const char* filename, IStream** ppStream) {
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
IFS(SHCreateStreamOnFileA(filename, STGM_READ, ppStream));
|
IFS(SHCreateStreamOnFileA(filename, STGM_READ, ppStream));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr)) {
|
||||||
fprintf(stderr, "Error opening input file %s (%08x)\n", filename, hr);
|
fprintf(stderr, "Error opening input file %s (%08lx)\n", filename, hr);
|
||||||
|
}
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Metadata processing
|
||||||
|
|
||||||
// Stores the first non-zero sized color profile from 'pFrame' to 'iccp'.
|
// Stores the first non-zero sized color profile from 'pFrame' to 'iccp'.
|
||||||
// Returns an HRESULT to indicate success or failure. The caller is responsible
|
// Returns an HRESULT to indicate success or failure. The caller is responsible
|
||||||
// for freeing 'iccp->bytes' in either case.
|
// for freeing 'iccp->bytes' in either case.
|
||||||
@ -129,9 +133,14 @@ static HRESULT ExtractMetadata(IWICImagingFactory* const pFactory,
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
int ReadPictureWithWIC(const char* const filename,
|
int ReadPictureWithWIC(const char* const filename,
|
||||||
WebPPicture* const pic, int keep_alpha,
|
WebPPicture* const pic, int keep_alpha,
|
||||||
Metadata* const metadata) {
|
Metadata* const metadata) {
|
||||||
|
// From Microsoft SDK 6.0a -- ks.h
|
||||||
|
// Define a local copy to avoid link errors under mingw.
|
||||||
|
WEBP_DEFINE_GUID(GUID_NULL_, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||||
// From Microsoft SDK 7.0a -- wincodec.h
|
// From Microsoft SDK 7.0a -- wincodec.h
|
||||||
// Create local copies for compatibility when building against earlier
|
// Create local copies for compatibility when building against earlier
|
||||||
// versions of the SDK.
|
// versions of the SDK.
|
||||||
@ -166,16 +175,17 @@ int ReadPictureWithWIC(const char* const filename,
|
|||||||
UINT frameCount = 0;
|
UINT frameCount = 0;
|
||||||
UINT width = 0, height = 0;
|
UINT width = 0, height = 0;
|
||||||
BYTE* rgb = NULL;
|
BYTE* rgb = NULL;
|
||||||
WICPixelFormatGUID srcPixelFormat = { 0 };
|
WICPixelFormatGUID srcPixelFormat = GUID_WICPixelFormatUndefined;
|
||||||
const WICFormatImporter* importer = NULL;
|
const WICFormatImporter* importer = NULL;
|
||||||
GUID srcContainerFormat = { 0 };
|
GUID srcContainerFormat = GUID_NULL_;
|
||||||
const GUID* alphaContainers[] = {
|
const GUID* alphaContainers[] = {
|
||||||
&GUID_ContainerFormatBmp,
|
&GUID_ContainerFormatBmp,
|
||||||
&GUID_ContainerFormatPng,
|
&GUID_ContainerFormatPng,
|
||||||
&GUID_ContainerFormatTiff
|
&GUID_ContainerFormatTiff,
|
||||||
|
NULL
|
||||||
};
|
};
|
||||||
int has_alpha = 0;
|
int has_alpha = 0;
|
||||||
int i, stride;
|
int stride;
|
||||||
|
|
||||||
IFS(CoInitialize(NULL));
|
IFS(CoInitialize(NULL));
|
||||||
IFS(CoCreateInstance(MAKE_REFGUID(CLSID_WICImagingFactory), NULL,
|
IFS(CoCreateInstance(MAKE_REFGUID(CLSID_WICImagingFactory), NULL,
|
||||||
@ -201,11 +211,9 @@ int ReadPictureWithWIC(const char* const filename,
|
|||||||
IFS(IWICBitmapDecoder_GetContainerFormat(pDecoder, &srcContainerFormat));
|
IFS(IWICBitmapDecoder_GetContainerFormat(pDecoder, &srcContainerFormat));
|
||||||
|
|
||||||
if (keep_alpha) {
|
if (keep_alpha) {
|
||||||
for (i = 0;
|
const GUID** guid;
|
||||||
i < sizeof(alphaContainers) / sizeof(alphaContainers[0]);
|
for (guid = alphaContainers; *guid != NULL; ++guid) {
|
||||||
++i) {
|
if (IsEqualGUID(MAKE_REFGUID(srcContainerFormat), MAKE_REFGUID(**guid))) {
|
||||||
if (IsEqualGUID(MAKE_REFGUID(srcContainerFormat),
|
|
||||||
MAKE_REFGUID(*alphaContainers[i]))) {
|
|
||||||
has_alpha =
|
has_alpha =
|
||||||
IsEqualGUID(MAKE_REFGUID(srcPixelFormat),
|
IsEqualGUID(MAKE_REFGUID(srcPixelFormat),
|
||||||
MAKE_REFGUID(GUID_WICPixelFormat32bppRGBA_)) ||
|
MAKE_REFGUID(GUID_WICPixelFormat32bppRGBA_)) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user