mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-25 21:28:22 +01:00
configure: mingw32 targets: test for WIC support
Replace usage of _WIN32 in examples as this does not guarantee the presence of wincodec.h. mingw-w64 notably includes wincodec.h, though other releases do not. Under cygwin the following can be used for a WIC enabled binary: ./configure --target=i686-pc-mingw32 CC=i686-w64-mingw32-gcc.exe Change-Id: Ica6a714c3356a8eaf88486a1c3f5aa6adde394c0
This commit is contained in:
parent
e29072a8ce
commit
31f9dc6fdd
@ -35,7 +35,8 @@ PLATFORM_LDFLAGS = /SAFESEH
|
||||
MT = mt.exe
|
||||
CCNODBG = cl.exe /nologo /O2 /DNDEBUG
|
||||
CCDEBUG = cl.exe /nologo /Od /Gm /Zi /D_DEBUG /RTC1
|
||||
CFLAGS = /Isrc /nologo /W3 /EHsc /DWIN32 /FD /c /GS /D_CRT_SECURE_NO_WARNINGS
|
||||
CFLAGS = /Isrc /nologo /W3 /EHsc /FD /c /GS
|
||||
CFLAGS = $(CFLAGS) /DWIN32 /D_CRT_SECURE_NO_WARNINGS /DHAVE_WINCODEC_H
|
||||
LDFLAGS = /LARGEADDRESSAWARE /MANIFEST /NXCOMPAT /DYNAMICBASE $(PLATFORM_LDFLAGS)
|
||||
CFLAGSLIB = /DLIBWEBP_STATICLIB
|
||||
LNKDLL = link.exe /DLL
|
||||
|
44
configure.ac
44
configure.ac
@ -1,4 +1,5 @@
|
||||
AC_INIT([webpdecode], [0.1])
|
||||
AC_CANONICAL_TARGET
|
||||
AM_INIT_AUTOMAKE([-Wall foreign subdir-objects])
|
||||
AC_PROG_LIBTOOL
|
||||
AM_PROG_CC_C_O
|
||||
@ -74,6 +75,49 @@ AC_CHECK_HEADER(jpeglib.h,
|
||||
AC_SUBST(JPEG_LIBS)
|
||||
AC_SUBST(JPEG_INCLUDES)
|
||||
|
||||
dnl === check for WIC support ===
|
||||
|
||||
if test "$target_os" = "mingw32"; then
|
||||
AC_CHECK_HEADERS([wincodec.h shlwapi.h windows.h])
|
||||
if test "$ac_cv_header_wincodec_h" = "yes"; then
|
||||
AC_MSG_CHECKING(for Windows Imaging Component support)
|
||||
saved_LIBS=$LIBS
|
||||
LIBS="-lshlwapi -lole32 $LIBS"
|
||||
# match include structure from [cd]webp.c
|
||||
wic_headers="
|
||||
#define INITGUID
|
||||
#define CINTERFACE
|
||||
#define COBJMACROS
|
||||
#define _WIN32_IE 0x500
|
||||
|
||||
#include <shlwapi.h>
|
||||
#include <windows.h>
|
||||
#include <wincodec.h>
|
||||
"
|
||||
# test for functions from each lib and the GUID is created properly
|
||||
wic_main="
|
||||
int main(void) {
|
||||
CLSID_WICImagingFactory;
|
||||
CoInitialize(NULL);
|
||||
SHCreateStreamOnFile(NULL, 0, NULL);
|
||||
return 0;
|
||||
}
|
||||
"
|
||||
AC_LANG_PUSH(C)
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_SOURCE([
|
||||
$wic_headers
|
||||
$wic_main])],
|
||||
[wic_support=yes],
|
||||
[wic_support=no]
|
||||
)
|
||||
AC_LANG_POP
|
||||
|
||||
test "$wic_support" = "yes" || LIBS=$saved_LIBS
|
||||
AC_MSG_RESULT(${wic_support-no})
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl === If --enable-experimental is defined, add the flag WEBP_EXPERIMENTAL_FEATURES
|
||||
|
||||
USE_EXPERIMENTAL_CODE=""
|
||||
|
@ -14,6 +14,10 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef WEBP_HAVE_PNG
|
||||
#include <png.h>
|
||||
#endif
|
||||
@ -23,7 +27,10 @@
|
||||
#include <jpeglib.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef HAVE_WINCODEC_H
|
||||
#ifdef __MINGW32__
|
||||
#define INITGUID // Without this GUIDs are declared extern and fail to link
|
||||
#endif
|
||||
#define CINTERFACE
|
||||
#define COBJMACROS
|
||||
#define _WIN32_IE 0x500 // Workaround bug in shlwapi.h when compiling C++
|
||||
@ -31,7 +38,13 @@
|
||||
#include <shlwapi.h>
|
||||
#include <windows.h>
|
||||
#include <wincodec.h>
|
||||
|
||||
#ifndef GUID_WICPixelFormat24bppRGB
|
||||
// From Microsoft SDK 7.0a
|
||||
DEFINE_GUID(GUID_WICPixelFormat24bppRGB,
|
||||
0x6fddc324, 0x4e03, 0x4bfe, 0xb1, 0x85, 0x3d, 0x77, 0x76, 0x8d, 0xc9, 0x0d);
|
||||
#endif
|
||||
#endif /* HAVE_WINCODEC_H */
|
||||
|
||||
|
||||
#include "webp/encode.h"
|
||||
@ -69,7 +82,7 @@ static int ReadYUV(FILE* in_file, WebPPicture* const pic) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef HAVE_WINCODEC_H
|
||||
|
||||
#define IFS(fn) \
|
||||
do { \
|
||||
@ -183,7 +196,7 @@ static int ReadPicture(const char* const filename, WebPPicture* const pic,
|
||||
return ok;
|
||||
}
|
||||
|
||||
#else // !_WIN32
|
||||
#else // !HAVE_WINCODEC_H
|
||||
|
||||
#ifdef WEBP_HAVE_JPEG
|
||||
struct my_error_mgr {
|
||||
@ -425,7 +438,7 @@ static int ReadPicture(const char* const filename, WebPPicture* const pic,
|
||||
return ok;
|
||||
}
|
||||
|
||||
#endif // !_WIN32
|
||||
#endif // !HAVE_WINCODEC_H
|
||||
|
||||
static void AllocExtraInfo(WebPPicture* const pic) {
|
||||
const int mb_w = (pic->width + 15) / 16;
|
||||
@ -589,7 +602,7 @@ static void HelpLong(void) {
|
||||
printf(" cwebp [-preset <...>] [options] in_file [-o out_file]\n\n");
|
||||
printf("If input size (-s) for an image is not specified, "
|
||||
"it is assumed to be a PNG or JPEG file.\n");
|
||||
#ifdef _WIN32
|
||||
#ifdef HAVE_WINCODEC_H
|
||||
printf("Windows builds can take as input any of the files handled by WIC\n");
|
||||
#endif
|
||||
printf("options:\n");
|
||||
|
@ -17,11 +17,18 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef WEBP_HAVE_PNG
|
||||
#include <png.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef HAVE_WINCODEC_H
|
||||
#ifdef __MINGW32__
|
||||
#define INITGUID // Without this GUIDs are declared extern and fail to link
|
||||
#endif
|
||||
#define CINTERFACE
|
||||
#define COBJMACROS
|
||||
#define _WIN32_IE 0x500 // Workaround bug in shlwapi.h when compiling C++
|
||||
@ -42,7 +49,7 @@ extern "C" {
|
||||
|
||||
static int verbose = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef HAVE_WINCODEC_H
|
||||
|
||||
#define IFS(fn) \
|
||||
do { \
|
||||
@ -116,7 +123,7 @@ static int WritePNG(const char* out_file_name, unsigned char* rgb, int stride,
|
||||
height));
|
||||
}
|
||||
|
||||
#elif defined(WEBP_HAVE_PNG) // !WIN32
|
||||
#elif defined(WEBP_HAVE_PNG) // !HAVE_WINCODEC_H
|
||||
static void PNGAPI error_function(png_structp png, png_const_charp dummy) {
|
||||
(void)dummy; // remove variable-unused warning
|
||||
longjmp(png_jmpbuf(png), 1);
|
||||
@ -156,7 +163,7 @@ static int WritePNG(FILE* out_file, unsigned char* rgb, int stride,
|
||||
png_destroy_write_struct(&png, &info);
|
||||
return 1;
|
||||
}
|
||||
#else // !WIN32 && !WEBP_HAVE_PNG
|
||||
#else // !HAVE_WINCODEC_H && !WEBP_HAVE_PNG
|
||||
|
||||
typedef uint32_t png_uint_32;
|
||||
|
||||
@ -359,7 +366,7 @@ int main(int argc, const char *argv[]) {
|
||||
if (!needs_open_file || fout) {
|
||||
int ok = 1;
|
||||
if (format == PNG) {
|
||||
#ifdef _WIN32
|
||||
#ifdef HAVE_WINCODEC_H
|
||||
ok &= WritePNG(out_file, out, stride, width, height, has_alpha);
|
||||
#else
|
||||
ok &= WritePNG(fout, out, stride, width, height, has_alpha);
|
||||
|
Loading…
Reference in New Issue
Block a user