oleaut32: Include minimal ungif source to remove dependency on libungif.
This commit is contained in:
parent
c8d4413068
commit
7aa893481e
|
@ -7659,7 +7659,6 @@ done
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for ac_header in \
|
||||
|
@ -7679,7 +7678,6 @@ for ac_header in \
|
|||
float.h \
|
||||
fontconfig/fontconfig.h \
|
||||
getopt.h \
|
||||
gif_lib.h \
|
||||
ieeefp.h \
|
||||
io.h \
|
||||
jack/jack.h \
|
||||
|
@ -14245,73 +14243,6 @@ fi
|
|||
fi
|
||||
|
||||
|
||||
if test "$ac_cv_header_gif_lib_h" = "yes"
|
||||
then
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include <gif_lib.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
static typeof(DGifOpen) * func;
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (ac_try="$ac_compile"
|
||||
case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_compile") 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
||||
{ (case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_try") 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest.$ac_objext'
|
||||
{ (case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_try") 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define HAVE_GIF 1
|
||||
_ACEOF
|
||||
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
|
||||
fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
fi
|
||||
|
||||
|
||||
EXTRACFLAGS=""
|
||||
|
||||
if test "x${GCC}" = "xyes"
|
||||
|
@ -18146,190 +18077,6 @@ cat >>confdefs.h <<_ACEOF
|
|||
#define SONAME_LIBJPEG "$ac_cv_lib_soname_jpeg"
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
{ echo "$as_me:$LINENO: checking for -lungif soname" >&5
|
||||
echo $ECHO_N "checking for -lungif soname... $ECHO_C" >&6; }
|
||||
if test "${ac_cv_lib_soname_ungif+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
ac_get_soname_save_LIBS=$LIBS
|
||||
LIBS="-lungif $LIBS"
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
|
||||
/* Override any GCC internal prototype to avoid an error.
|
||||
Use char because int might match the return type of a GCC
|
||||
builtin and then its argument prototype would still apply. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
char DGifOpen ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
return DGifOpen ();
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
if { (ac_try="$ac_link"
|
||||
case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_link") 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
||||
{ (case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_try") 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest$ac_exeext'
|
||||
{ (case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_try") 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
case "$LIBEXT" in
|
||||
dylib) ac_cv_lib_soname_ungif=`otool -L conftest$ac_exeext | grep libungif\\.[0-9A-Za-z.]*dylib | sed -e "s/^.*\/\(libungif\.[0-9A-Za-z.]*dylib\).*$/\1/"';2,$d'` ;;
|
||||
so) ac_cv_lib_soname_ungif=`$ac_cv_path_LDD conftest$ac_exeext | grep libungif\\.so | sed -e "s/^.*\(libungif\.so[^ ]*\).*$/\1/"';2,$d'` ;;
|
||||
esac
|
||||
if test "x$ac_cv_lib_soname_ungif" = "x"
|
||||
then
|
||||
ac_cv_lib_soname_ungif="libungif.$LIBEXT"
|
||||
fi
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_cv_lib_soname_ungif="libungif.$LIBEXT"
|
||||
fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
LIBS=$ac_get_soname_save_LIBS
|
||||
fi
|
||||
{ echo "$as_me:$LINENO: result: $ac_cv_lib_soname_ungif" >&5
|
||||
echo "${ECHO_T}$ac_cv_lib_soname_ungif" >&6; }
|
||||
if test "${ac_cv_lib_soname_ungif+set}" = set; then
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define SONAME_LIBUNGIF "$ac_cv_lib_soname_ungif"
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
{ echo "$as_me:$LINENO: checking for -lgif soname" >&5
|
||||
echo $ECHO_N "checking for -lgif soname... $ECHO_C" >&6; }
|
||||
if test "${ac_cv_lib_soname_gif+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
ac_get_soname_save_LIBS=$LIBS
|
||||
LIBS="-lgif $LIBS"
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
|
||||
/* Override any GCC internal prototype to avoid an error.
|
||||
Use char because int might match the return type of a GCC
|
||||
builtin and then its argument prototype would still apply. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
char DGifOpen ();
|
||||
int
|
||||
main ()
|
||||
{
|
||||
return DGifOpen ();
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
if { (ac_try="$ac_link"
|
||||
case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_link") 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
||||
{ (case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_try") 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest$ac_exeext'
|
||||
{ (case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_try") 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
case "$LIBEXT" in
|
||||
dylib) ac_cv_lib_soname_gif=`otool -L conftest$ac_exeext | grep libgif\\.[0-9A-Za-z.]*dylib | sed -e "s/^.*\/\(libgif\.[0-9A-Za-z.]*dylib\).*$/\1/"';2,$d'` ;;
|
||||
so) ac_cv_lib_soname_gif=`$ac_cv_path_LDD conftest$ac_exeext | grep libgif\\.so | sed -e "s/^.*\(libgif\.so[^ ]*\).*$/\1/"';2,$d'` ;;
|
||||
esac
|
||||
if test "x$ac_cv_lib_soname_gif" = "x"
|
||||
then
|
||||
ac_cv_lib_soname_gif="libgif.$LIBEXT"
|
||||
fi
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
ac_cv_lib_soname_gif="libgif.$LIBEXT"
|
||||
fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
LIBS=$ac_get_soname_save_LIBS
|
||||
fi
|
||||
{ echo "$as_me:$LINENO: result: $ac_cv_lib_soname_gif" >&5
|
||||
echo "${ECHO_T}$ac_cv_lib_soname_gif" >&6; }
|
||||
if test "${ac_cv_lib_soname_gif+set}" = set; then
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define SONAME_LIBGIF "$ac_cv_lib_soname_gif"
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
{ echo "$as_me:$LINENO: checking for -lcapi20 soname" >&5
|
||||
|
@ -25732,15 +25479,6 @@ echo "$as_me: Wine will be built without (n)curses support. (wineconsole.exe)" >
|
|||
echo "$as_me: libsane development files not found." >&6;}
|
||||
{ echo "$as_me:$LINENO: Wine will be built without Scanner support. (sane.ds/twain_32.dll)" >&5
|
||||
echo "$as_me: Wine will be built without Scanner support. (sane.ds/twain_32.dll)" >&6;}
|
||||
fi
|
||||
|
||||
if test "$ac_cv_header_gif_lib_h" != "yes"
|
||||
then
|
||||
echo >&2
|
||||
{ echo "$as_me:$LINENO: libungif development files not found." >&5
|
||||
echo "$as_me: libungif development files not found." >&6;}
|
||||
{ echo "$as_me:$LINENO: Wine will be built without GIF support. (oleaut32.dll)" >&5
|
||||
echo "$as_me: Wine will be built without GIF support. (oleaut32.dll)" >&6;}
|
||||
fi
|
||||
|
||||
if test "$have_x" = "yes"
|
||||
|
|
19
configure.ac
19
configure.ac
|
@ -166,7 +166,6 @@ AC_CHECK_HEADERS(\
|
|||
float.h \
|
||||
fontconfig/fontconfig.h \
|
||||
getopt.h \
|
||||
gif_lib.h \
|
||||
ieeefp.h \
|
||||
io.h \
|
||||
jack/jack.h \
|
||||
|
@ -878,14 +877,6 @@ then
|
|||
AC_CHECK_LIB(capi20,capi20_register,[AC_DEFINE(HAVE_CAPI4LINUX,1,[Define if you have capi4linux libs and headers])])
|
||||
fi
|
||||
|
||||
dnl **** Check for gif header usability ****
|
||||
|
||||
if test "$ac_cv_header_gif_lib_h" = "yes"
|
||||
then
|
||||
AC_TRY_COMPILE([#include <gif_lib.h>],[static typeof(DGifOpen) * func;],
|
||||
AC_DEFINE(HAVE_GIF, 1, [Define if you have usable GIF headers]))
|
||||
fi
|
||||
|
||||
dnl **** Check for gcc specific options ****
|
||||
|
||||
AC_SUBST(EXTRACFLAGS,"")
|
||||
|
@ -1170,8 +1161,6 @@ then
|
|||
WINE_GET_SONAME(ncurses,waddch)
|
||||
WINE_GET_SONAME(curses,waddch)
|
||||
WINE_GET_SONAME(jpeg,jpeg_start_decompress)
|
||||
WINE_GET_SONAME(ungif,DGifOpen)
|
||||
WINE_GET_SONAME(gif,DGifOpen)
|
||||
WINE_GET_SONAME(capi20,capi20_isinstalled)
|
||||
fi
|
||||
|
||||
|
@ -1889,14 +1878,6 @@ then
|
|||
AC_MSG_NOTICE([Wine will be built without Scanner support. (sane.ds/twain_32.dll)])
|
||||
fi
|
||||
|
||||
dnl **** libungif devel package ***
|
||||
if test "$ac_cv_header_gif_lib_h" != "yes"
|
||||
then
|
||||
echo >&2
|
||||
AC_MSG_NOTICE([libungif development files not found.])
|
||||
AC_MSG_NOTICE([Wine will be built without GIF support. (oleaut32.dll)])
|
||||
fi
|
||||
|
||||
dnl **** libX11-dev includes Xlib.h and Xutil.h and depends on ***
|
||||
dnl **** x11proto-input-dev (extensions/XInput.h) and x11proto-kb-dev (XKBlib.h) ***
|
||||
if test "$have_x" = "yes"
|
||||
|
|
|
@ -24,6 +24,7 @@ C_SRCS = \
|
|||
tmarshal.c \
|
||||
typelib.c \
|
||||
typelib2.c \
|
||||
ungif.c \
|
||||
usrmarshal.c \
|
||||
varformat.c \
|
||||
variant.c \
|
||||
|
|
|
@ -48,16 +48,6 @@
|
|||
/* Must be before wine includes, the header has things conflicting with
|
||||
* WINE headers.
|
||||
*/
|
||||
#ifdef HAVE_GIF_LIB_H
|
||||
# include <gif_lib.h>
|
||||
# ifndef SONAME_LIBUNGIF
|
||||
# define SONAME_LIBUNGIF "libungif.so"
|
||||
# endif
|
||||
# ifndef SONAME_LIBGIF
|
||||
# define SONAME_LIBGIF "libgif.so"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define COBJMACROS
|
||||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
|
@ -92,6 +82,8 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#include "ungif.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
||||
|
||||
#include "pshpack1.h"
|
||||
|
@ -989,41 +981,12 @@ static boolean _jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired) {
|
|||
static void _jpeg_term_source(j_decompress_ptr cinfo) { }
|
||||
#endif /* HAVE_JPEGLIB_H */
|
||||
|
||||
#ifdef HAVE_GIF
|
||||
|
||||
static void *libungif_handle;
|
||||
#define MAKE_FUNCPTR(f) static typeof(f) * p##f
|
||||
MAKE_FUNCPTR(DGifOpen);
|
||||
MAKE_FUNCPTR(DGifSlurp);
|
||||
MAKE_FUNCPTR(DGifCloseFile);
|
||||
#undef MAKE_FUNCPTR
|
||||
|
||||
struct gifdata {
|
||||
unsigned char *data;
|
||||
unsigned int curoff;
|
||||
unsigned int len;
|
||||
};
|
||||
|
||||
static void *load_libungif(void)
|
||||
{
|
||||
if(((libungif_handle = wine_dlopen(SONAME_LIBUNGIF, RTLD_NOW, NULL, 0)) != NULL) ||
|
||||
((libungif_handle = wine_dlopen(SONAME_LIBGIF , RTLD_NOW, NULL, 0)) != NULL)
|
||||
) {
|
||||
|
||||
#define LOAD_FUNCPTR(f) \
|
||||
if((p##f = wine_dlsym(libungif_handle, #f, NULL, 0)) == NULL) { \
|
||||
libungif_handle = NULL; \
|
||||
return NULL; \
|
||||
}
|
||||
|
||||
LOAD_FUNCPTR(DGifOpen);
|
||||
LOAD_FUNCPTR(DGifSlurp);
|
||||
LOAD_FUNCPTR(DGifCloseFile);
|
||||
#undef LOAD_FUNCPTR
|
||||
}
|
||||
return libungif_handle;
|
||||
}
|
||||
|
||||
static int _gif_inputfunc(GifFileType *gif, GifByteType *data, int len) {
|
||||
struct gifdata *gd = (struct gifdata*)gif->UserData;
|
||||
|
||||
|
@ -1036,12 +999,9 @@ static int _gif_inputfunc(GifFileType *gif, GifByteType *data, int len) {
|
|||
return len;
|
||||
}
|
||||
|
||||
#endif /* HAVE_GIF */
|
||||
|
||||
|
||||
static HRESULT OLEPictureImpl_LoadGif(OLEPictureImpl *This, BYTE *xbuf, ULONG xread)
|
||||
{
|
||||
#ifdef HAVE_GIF
|
||||
struct gifdata gd;
|
||||
GifFileType *gif;
|
||||
BITMAPINFO *bmi;
|
||||
|
@ -1055,18 +1015,11 @@ static HRESULT OLEPictureImpl_LoadGif(OLEPictureImpl *This, BYTE *xbuf, ULONG xr
|
|||
ExtensionBlock *eb;
|
||||
int padding;
|
||||
|
||||
if(!libungif_handle) {
|
||||
if(!load_libungif()) {
|
||||
FIXME("Failed reading GIF because unable to find %s/%s\n", SONAME_LIBUNGIF, SONAME_LIBGIF);
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
gd.data = xbuf;
|
||||
gd.curoff = 0;
|
||||
gd.len = xread;
|
||||
gif = pDGifOpen((void*)&gd, _gif_inputfunc);
|
||||
ret = pDGifSlurp(gif);
|
||||
gif = DGifOpen((void*)&gd, _gif_inputfunc);
|
||||
ret = DGifSlurp(gif);
|
||||
if (ret == GIF_ERROR) {
|
||||
FIXME("Failed reading GIF using libgif.\n");
|
||||
return E_FAIL;
|
||||
|
@ -1238,13 +1191,9 @@ static HRESULT OLEPictureImpl_LoadGif(OLEPictureImpl *This, BYTE *xbuf, ULONG xr
|
|||
DeleteDC(hdcref);
|
||||
This->desc.picType = PICTYPE_BITMAP;
|
||||
OLEPictureImpl_SetBitmap(This);
|
||||
pDGifCloseFile(gif);
|
||||
DGifCloseFile(gif);
|
||||
HeapFree(GetProcessHeap(),0,bytes);
|
||||
return S_OK;
|
||||
#else
|
||||
FIXME("Trying to load GIF, but no support for libgif/libungif compiled in.\n");
|
||||
return E_FAIL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static HRESULT OLEPictureImpl_LoadJpeg(OLEPictureImpl *This, BYTE *xbuf, ULONG xread)
|
||||
|
|
|
@ -0,0 +1,978 @@
|
|||
/*
|
||||
* Gif extracting routines - derived from libungif
|
||||
*
|
||||
* Portions Copyright 2006 Mike McCormack
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* Original copyright notice:
|
||||
*
|
||||
* The GIFLIB distribution is Copyright (c) 1997 Eric S. Raymond
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* "Gif-Lib" - Yet another gif library.
|
||||
*
|
||||
* Written by: Gershon Elber IBM PC Ver 1.1, Aug. 1990
|
||||
******************************************************************************
|
||||
* The kernel of the GIF Decoding process can be found here.
|
||||
******************************************************************************
|
||||
* History:
|
||||
* 16 Jun 89 - Version 1.0 by Gershon Elber.
|
||||
* 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names).
|
||||
*****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ungif.h"
|
||||
|
||||
#define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */
|
||||
#define LZ_BITS 12
|
||||
|
||||
#define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */
|
||||
|
||||
typedef struct GifFilePrivateType {
|
||||
GifWord BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */
|
||||
ClearCode, /* The CLEAR LZ code. */
|
||||
EOFCode, /* The EOF LZ code. */
|
||||
RunningCode, /* The next code algorithm can generate. */
|
||||
RunningBits, /* The number of bits required to represent RunningCode. */
|
||||
MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */
|
||||
LastCode, /* The code before the current code. */
|
||||
CrntCode, /* Current algorithm code. */
|
||||
StackPtr, /* For character stack (see below). */
|
||||
CrntShiftState; /* Number of bits in CrntShiftDWord. */
|
||||
unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */
|
||||
unsigned long PixelCount; /* Number of pixels in image. */
|
||||
InputFunc Read; /* function to read gif input (TVT) */
|
||||
GifByteType Buf[256]; /* Compressed input is buffered here. */
|
||||
GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */
|
||||
GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */
|
||||
GifPrefixType Prefix[LZ_MAX_CODE + 1];
|
||||
} GifFilePrivateType;
|
||||
|
||||
/* avoid extra function call in case we use fread (TVT) */
|
||||
#define READ(_gif,_buf,_len) \
|
||||
((GifFilePrivateType*)_gif->Private)->Read(_gif,_buf,_len)
|
||||
|
||||
static int DGifGetWord(GifFileType *GifFile, GifWord *Word);
|
||||
static int DGifSetupDecompress(GifFileType *GifFile);
|
||||
static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, int LineLen);
|
||||
static int DGifGetPrefixChar(GifPrefixType *Prefix, int Code, int ClearCode);
|
||||
static int DGifDecompressInput(GifFileType *GifFile, int *Code);
|
||||
static int DGifBufferedInput(GifFileType *GifFile, GifByteType *Buf,
|
||||
GifByteType *NextByte);
|
||||
|
||||
static int DGifGetExtensionNext(GifFileType * GifFile, GifByteType ** GifExtension);
|
||||
static int DGifGetCodeNext(GifFileType * GifFile, GifByteType ** GifCodeBlock);
|
||||
|
||||
/******************************************************************************
|
||||
* Miscellaneous utility functions
|
||||
*****************************************************************************/
|
||||
|
||||
/* return smallest bitfield size n will fit in */
|
||||
static int
|
||||
BitSize(int n) {
|
||||
|
||||
register int i;
|
||||
|
||||
for (i = 1; i <= 8; i++)
|
||||
if ((1 << i) >= n)
|
||||
break;
|
||||
return (i);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Color map object functions
|
||||
*****************************************************************************/
|
||||
|
||||
/*
|
||||
* Allocate a color map of given size; initialize with contents of
|
||||
* ColorMap if that pointer is non-NULL.
|
||||
*/
|
||||
static ColorMapObject *
|
||||
MakeMapObject(int ColorCount,
|
||||
const GifColorType * ColorMap) {
|
||||
|
||||
ColorMapObject *Object;
|
||||
|
||||
/*** FIXME: Our ColorCount has to be a power of two. Is it necessary to
|
||||
* make the user know that or should we automatically round up instead? */
|
||||
if (ColorCount != (1 << BitSize(ColorCount))) {
|
||||
return ((ColorMapObject *) NULL);
|
||||
}
|
||||
|
||||
Object = malloc(sizeof(ColorMapObject));
|
||||
if (Object == (ColorMapObject *) NULL) {
|
||||
return ((ColorMapObject *) NULL);
|
||||
}
|
||||
|
||||
Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType));
|
||||
if (Object->Colors == (GifColorType *) NULL) {
|
||||
return ((ColorMapObject *) NULL);
|
||||
}
|
||||
|
||||
Object->ColorCount = ColorCount;
|
||||
Object->BitsPerPixel = BitSize(ColorCount);
|
||||
|
||||
if (ColorMap) {
|
||||
memcpy(Object->Colors, ColorMap, ColorCount * sizeof(GifColorType));
|
||||
}
|
||||
|
||||
return (Object);
|
||||
}
|
||||
|
||||
/*
|
||||
* Free a color map object
|
||||
*/
|
||||
static void
|
||||
FreeMapObject(ColorMapObject * Object) {
|
||||
|
||||
if (Object != NULL) {
|
||||
free(Object->Colors);
|
||||
free(Object);
|
||||
/*** FIXME:
|
||||
* When we are willing to break API we need to make this function
|
||||
* FreeMapObject(ColorMapObject **Object)
|
||||
* and do this assignment to NULL here:
|
||||
* *Object = NULL;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
AddExtensionBlock(SavedImage * New,
|
||||
int Len,
|
||||
unsigned char ExtData[]) {
|
||||
|
||||
ExtensionBlock *ep;
|
||||
|
||||
if (New->ExtensionBlocks == NULL)
|
||||
New->ExtensionBlocks = malloc(sizeof(ExtensionBlock));
|
||||
else
|
||||
New->ExtensionBlocks = realloc(New->ExtensionBlocks,
|
||||
sizeof(ExtensionBlock) *
|
||||
(New->ExtensionBlockCount + 1));
|
||||
|
||||
if (New->ExtensionBlocks == NULL)
|
||||
return (GIF_ERROR);
|
||||
|
||||
ep = &New->ExtensionBlocks[New->ExtensionBlockCount++];
|
||||
|
||||
ep->ByteCount=Len;
|
||||
ep->Bytes = malloc(ep->ByteCount);
|
||||
if (ep->Bytes == NULL)
|
||||
return (GIF_ERROR);
|
||||
|
||||
if (ExtData) {
|
||||
memcpy(ep->Bytes, ExtData, Len);
|
||||
ep->Function = New->Function;
|
||||
}
|
||||
|
||||
return (GIF_OK);
|
||||
}
|
||||
|
||||
static void
|
||||
FreeExtension(SavedImage * Image)
|
||||
{
|
||||
ExtensionBlock *ep;
|
||||
|
||||
if ((Image == NULL) || (Image->ExtensionBlocks == NULL)) {
|
||||
return;
|
||||
}
|
||||
for (ep = Image->ExtensionBlocks;
|
||||
ep < (Image->ExtensionBlocks + Image->ExtensionBlockCount); ep++)
|
||||
free(ep->Bytes);
|
||||
free(Image->ExtensionBlocks);
|
||||
Image->ExtensionBlocks = NULL;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Image block allocation functions
|
||||
******************************************************************************/
|
||||
|
||||
static void
|
||||
FreeSavedImages(GifFileType * GifFile) {
|
||||
|
||||
SavedImage *sp;
|
||||
|
||||
if ((GifFile == NULL) || (GifFile->SavedImages == NULL)) {
|
||||
return;
|
||||
}
|
||||
for (sp = GifFile->SavedImages;
|
||||
sp < GifFile->SavedImages + GifFile->ImageCount; sp++) {
|
||||
if (sp->ImageDesc.ColorMap) {
|
||||
FreeMapObject(sp->ImageDesc.ColorMap);
|
||||
sp->ImageDesc.ColorMap = NULL;
|
||||
}
|
||||
|
||||
if (sp->RasterBits)
|
||||
free(sp->RasterBits);
|
||||
|
||||
if (sp->ExtensionBlocks)
|
||||
FreeExtension(sp);
|
||||
}
|
||||
free(GifFile->SavedImages);
|
||||
GifFile->SavedImages=NULL;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* This routine should be called before any other DGif calls. Note that
|
||||
* this routine is called automatically from DGif file open routines.
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifGetScreenDesc(GifFileType * GifFile) {
|
||||
|
||||
int i, BitsPerPixel;
|
||||
GifByteType Buf[3];
|
||||
|
||||
/* Put the screen descriptor into the file: */
|
||||
if (DGifGetWord(GifFile, &GifFile->SWidth) == GIF_ERROR ||
|
||||
DGifGetWord(GifFile, &GifFile->SHeight) == GIF_ERROR)
|
||||
return GIF_ERROR;
|
||||
|
||||
if (READ(GifFile, Buf, 3) != 3) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
GifFile->SColorResolution = (((Buf[0] & 0x70) + 1) >> 4) + 1;
|
||||
BitsPerPixel = (Buf[0] & 0x07) + 1;
|
||||
GifFile->SBackGroundColor = Buf[1];
|
||||
if (Buf[0] & 0x80) { /* Do we have global color map? */
|
||||
|
||||
GifFile->SColorMap = MakeMapObject(1 << BitsPerPixel, NULL);
|
||||
if (GifFile->SColorMap == NULL) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
|
||||
/* Get the global color map: */
|
||||
for (i = 0; i < GifFile->SColorMap->ColorCount; i++) {
|
||||
if (READ(GifFile, Buf, 3) != 3) {
|
||||
FreeMapObject(GifFile->SColorMap);
|
||||
GifFile->SColorMap = NULL;
|
||||
return GIF_ERROR;
|
||||
}
|
||||
GifFile->SColorMap->Colors[i].Red = Buf[0];
|
||||
GifFile->SColorMap->Colors[i].Green = Buf[1];
|
||||
GifFile->SColorMap->Colors[i].Blue = Buf[2];
|
||||
}
|
||||
} else {
|
||||
GifFile->SColorMap = NULL;
|
||||
}
|
||||
|
||||
return GIF_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* This routine should be called before any attempt to read an image.
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifGetRecordType(GifFileType * GifFile,
|
||||
GifRecordType * Type) {
|
||||
|
||||
GifByteType Buf;
|
||||
|
||||
if (READ(GifFile, &Buf, 1) != 1) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
|
||||
switch (Buf) {
|
||||
case ',':
|
||||
*Type = IMAGE_DESC_RECORD_TYPE;
|
||||
break;
|
||||
case '!':
|
||||
*Type = EXTENSION_RECORD_TYPE;
|
||||
break;
|
||||
case ';':
|
||||
*Type = TERMINATE_RECORD_TYPE;
|
||||
break;
|
||||
default:
|
||||
*Type = UNDEFINED_RECORD_TYPE;
|
||||
return GIF_ERROR;
|
||||
}
|
||||
|
||||
return GIF_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* This routine should be called before any attempt to read an image.
|
||||
* Note it is assumed the Image desc. header (',') has been read.
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifGetImageDesc(GifFileType * GifFile) {
|
||||
|
||||
int i, BitsPerPixel;
|
||||
GifByteType Buf[3];
|
||||
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
|
||||
SavedImage *sp;
|
||||
|
||||
if (DGifGetWord(GifFile, &GifFile->Image.Left) == GIF_ERROR ||
|
||||
DGifGetWord(GifFile, &GifFile->Image.Top) == GIF_ERROR ||
|
||||
DGifGetWord(GifFile, &GifFile->Image.Width) == GIF_ERROR ||
|
||||
DGifGetWord(GifFile, &GifFile->Image.Height) == GIF_ERROR)
|
||||
return GIF_ERROR;
|
||||
if (READ(GifFile, Buf, 1) != 1) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
BitsPerPixel = (Buf[0] & 0x07) + 1;
|
||||
GifFile->Image.Interlace = (Buf[0] & 0x40);
|
||||
if (Buf[0] & 0x80) { /* Does this image have local color map? */
|
||||
|
||||
/*** FIXME: Why do we check both of these in order to do this?
|
||||
* Why do we have both Image and SavedImages? */
|
||||
if (GifFile->Image.ColorMap && GifFile->SavedImages == NULL)
|
||||
FreeMapObject(GifFile->Image.ColorMap);
|
||||
|
||||
GifFile->Image.ColorMap = MakeMapObject(1 << BitsPerPixel, NULL);
|
||||
if (GifFile->Image.ColorMap == NULL) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
|
||||
/* Get the image local color map: */
|
||||
for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) {
|
||||
if (READ(GifFile, Buf, 3) != 3) {
|
||||
FreeMapObject(GifFile->Image.ColorMap);
|
||||
GifFile->Image.ColorMap = NULL;
|
||||
return GIF_ERROR;
|
||||
}
|
||||
GifFile->Image.ColorMap->Colors[i].Red = Buf[0];
|
||||
GifFile->Image.ColorMap->Colors[i].Green = Buf[1];
|
||||
GifFile->Image.ColorMap->Colors[i].Blue = Buf[2];
|
||||
}
|
||||
} else if (GifFile->Image.ColorMap) {
|
||||
FreeMapObject(GifFile->Image.ColorMap);
|
||||
GifFile->Image.ColorMap = NULL;
|
||||
}
|
||||
|
||||
if (GifFile->SavedImages) {
|
||||
if ((GifFile->SavedImages = realloc(GifFile->SavedImages,
|
||||
sizeof(SavedImage) *
|
||||
(GifFile->ImageCount + 1))) == NULL) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
} else {
|
||||
if ((GifFile->SavedImages = malloc(sizeof(SavedImage))) == NULL) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
sp = &GifFile->SavedImages[GifFile->ImageCount];
|
||||
memcpy(&sp->ImageDesc, &GifFile->Image, sizeof(GifImageDesc));
|
||||
if (GifFile->Image.ColorMap != NULL) {
|
||||
sp->ImageDesc.ColorMap = MakeMapObject(
|
||||
GifFile->Image.ColorMap->ColorCount,
|
||||
GifFile->Image.ColorMap->Colors);
|
||||
if (sp->ImageDesc.ColorMap == NULL) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
}
|
||||
sp->RasterBits = (unsigned char *)NULL;
|
||||
sp->ExtensionBlockCount = 0;
|
||||
sp->ExtensionBlocks = (ExtensionBlock *) NULL;
|
||||
|
||||
GifFile->ImageCount++;
|
||||
|
||||
Private->PixelCount = (long)GifFile->Image.Width *
|
||||
(long)GifFile->Image.Height;
|
||||
|
||||
DGifSetupDecompress(GifFile); /* Reset decompress algorithm parameters. */
|
||||
|
||||
return GIF_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Get one full scanned line (Line) of length LineLen from GIF file.
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifGetLine(GifFileType * GifFile,
|
||||
GifPixelType * Line,
|
||||
int LineLen) {
|
||||
|
||||
GifByteType *Dummy;
|
||||
GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
|
||||
|
||||
if (!LineLen)
|
||||
LineLen = GifFile->Image.Width;
|
||||
|
||||
if ((Private->PixelCount -= LineLen) > 0xffff0000UL) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
|
||||
if (DGifDecompressLine(GifFile, Line, LineLen) == GIF_OK) {
|
||||
if (Private->PixelCount == 0) {
|
||||
/* We probably would not be called any more, so lets clean
|
||||
* everything before we return: need to flush out all rest of
|
||||
* image until empty block (size 0) detected. We use GetCodeNext. */
|
||||
do
|
||||
if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR)
|
||||
return GIF_ERROR;
|
||||
while (Dummy != NULL) ;
|
||||
}
|
||||
return GIF_OK;
|
||||
} else
|
||||
return GIF_ERROR;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Get an extension block (see GIF manual) from gif file. This routine only
|
||||
* returns the first data block, and DGifGetExtensionNext should be called
|
||||
* after this one until NULL extension is returned.
|
||||
* The Extension should NOT be freed by the user (not dynamically allocated).
|
||||
* Note it is assumed the Extension desc. header ('!') has been read.
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifGetExtension(GifFileType * GifFile,
|
||||
int *ExtCode,
|
||||
GifByteType ** Extension) {
|
||||
|
||||
GifByteType Buf;
|
||||
|
||||
if (READ(GifFile, &Buf, 1) != 1) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
*ExtCode = Buf;
|
||||
|
||||
return DGifGetExtensionNext(GifFile, Extension);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Get a following extension block (see GIF manual) from gif file. This
|
||||
* routine should be called until NULL Extension is returned.
|
||||
* The Extension should NOT be freed by the user (not dynamically allocated).
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifGetExtensionNext(GifFileType * GifFile,
|
||||
GifByteType ** Extension) {
|
||||
|
||||
GifByteType Buf;
|
||||
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
|
||||
|
||||
if (READ(GifFile, &Buf, 1) != 1) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
if (Buf > 0) {
|
||||
*Extension = Private->Buf; /* Use private unused buffer. */
|
||||
(*Extension)[0] = Buf; /* Pascal strings notation (pos. 0 is len.). */
|
||||
if (READ(GifFile, &((*Extension)[1]), Buf) != Buf) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
} else
|
||||
*Extension = NULL;
|
||||
|
||||
return GIF_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Get 2 bytes (word) from the given file:
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifGetWord(GifFileType * GifFile,
|
||||
GifWord *Word) {
|
||||
|
||||
unsigned char c[2];
|
||||
|
||||
if (READ(GifFile, c, 2) != 2) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
|
||||
*Word = (((unsigned int)c[1]) << 8) + c[0];
|
||||
return GIF_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Continue to get the image code in compressed form. This routine should be
|
||||
* called until NULL block is returned.
|
||||
* The block should NOT be freed by the user (not dynamically allocated).
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifGetCodeNext(GifFileType * GifFile,
|
||||
GifByteType ** CodeBlock) {
|
||||
|
||||
GifByteType Buf;
|
||||
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
|
||||
|
||||
if (READ(GifFile, &Buf, 1) != 1) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
|
||||
if (Buf > 0) {
|
||||
*CodeBlock = Private->Buf; /* Use private unused buffer. */
|
||||
(*CodeBlock)[0] = Buf; /* Pascal strings notation (pos. 0 is len.). */
|
||||
if (READ(GifFile, &((*CodeBlock)[1]), Buf) != Buf) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
} else {
|
||||
*CodeBlock = NULL;
|
||||
Private->Buf[0] = 0; /* Make sure the buffer is empty! */
|
||||
Private->PixelCount = 0; /* And local info. indicate image read. */
|
||||
}
|
||||
|
||||
return GIF_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Setup the LZ decompression for this image:
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifSetupDecompress(GifFileType * GifFile) {
|
||||
|
||||
int i, BitsPerPixel;
|
||||
GifByteType CodeSize;
|
||||
GifPrefixType *Prefix;
|
||||
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
|
||||
|
||||
READ(GifFile, &CodeSize, 1); /* Read Code size from file. */
|
||||
BitsPerPixel = CodeSize;
|
||||
|
||||
Private->Buf[0] = 0; /* Input Buffer empty. */
|
||||
Private->BitsPerPixel = BitsPerPixel;
|
||||
Private->ClearCode = (1 << BitsPerPixel);
|
||||
Private->EOFCode = Private->ClearCode + 1;
|
||||
Private->RunningCode = Private->EOFCode + 1;
|
||||
Private->RunningBits = BitsPerPixel + 1; /* Number of bits per code. */
|
||||
Private->MaxCode1 = 1 << Private->RunningBits; /* Max. code + 1. */
|
||||
Private->StackPtr = 0; /* No pixels on the pixel stack. */
|
||||
Private->LastCode = NO_SUCH_CODE;
|
||||
Private->CrntShiftState = 0; /* No information in CrntShiftDWord. */
|
||||
Private->CrntShiftDWord = 0;
|
||||
|
||||
Prefix = Private->Prefix;
|
||||
for (i = 0; i <= LZ_MAX_CODE; i++)
|
||||
Prefix[i] = NO_SUCH_CODE;
|
||||
|
||||
return GIF_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* The LZ decompression routine:
|
||||
* This version decompress the given gif file into Line of length LineLen.
|
||||
* This routine can be called few times (one per scan line, for example), in
|
||||
* order the complete the whole image.
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifDecompressLine(GifFileType * GifFile,
|
||||
GifPixelType * Line,
|
||||
int LineLen) {
|
||||
|
||||
int i = 0;
|
||||
int j, CrntCode, EOFCode, ClearCode, CrntPrefix, LastCode, StackPtr;
|
||||
GifByteType *Stack, *Suffix;
|
||||
GifPrefixType *Prefix;
|
||||
GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private;
|
||||
|
||||
StackPtr = Private->StackPtr;
|
||||
Prefix = Private->Prefix;
|
||||
Suffix = Private->Suffix;
|
||||
Stack = Private->Stack;
|
||||
EOFCode = Private->EOFCode;
|
||||
ClearCode = Private->ClearCode;
|
||||
LastCode = Private->LastCode;
|
||||
|
||||
if (StackPtr != 0) {
|
||||
/* Let pop the stack off before continueing to read the gif file: */
|
||||
while (StackPtr != 0 && i < LineLen)
|
||||
Line[i++] = Stack[--StackPtr];
|
||||
}
|
||||
|
||||
while (i < LineLen) { /* Decode LineLen items. */
|
||||
if (DGifDecompressInput(GifFile, &CrntCode) == GIF_ERROR)
|
||||
return GIF_ERROR;
|
||||
|
||||
if (CrntCode == EOFCode) {
|
||||
/* Note however that usually we will not be here as we will stop
|
||||
* decoding as soon as we got all the pixel, or EOF code will
|
||||
* not be read at all, and DGifGetLine/Pixel clean everything. */
|
||||
if (i != LineLen - 1 || Private->PixelCount != 0) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
i++;
|
||||
} else if (CrntCode == ClearCode) {
|
||||
/* We need to start over again: */
|
||||
for (j = 0; j <= LZ_MAX_CODE; j++)
|
||||
Prefix[j] = NO_SUCH_CODE;
|
||||
Private->RunningCode = Private->EOFCode + 1;
|
||||
Private->RunningBits = Private->BitsPerPixel + 1;
|
||||
Private->MaxCode1 = 1 << Private->RunningBits;
|
||||
LastCode = Private->LastCode = NO_SUCH_CODE;
|
||||
} else {
|
||||
/* Its regular code - if in pixel range simply add it to output
|
||||
* stream, otherwise trace to codes linked list until the prefix
|
||||
* is in pixel range: */
|
||||
if (CrntCode < ClearCode) {
|
||||
/* This is simple - its pixel scalar, so add it to output: */
|
||||
Line[i++] = CrntCode;
|
||||
} else {
|
||||
/* Its a code to needed to be traced: trace the linked list
|
||||
* until the prefix is a pixel, while pushing the suffix
|
||||
* pixels on our stack. If we done, pop the stack in reverse
|
||||
* (thats what stack is good for!) order to output. */
|
||||
if (Prefix[CrntCode] == NO_SUCH_CODE) {
|
||||
/* Only allowed if CrntCode is exactly the running code:
|
||||
* In that case CrntCode = XXXCode, CrntCode or the
|
||||
* prefix code is last code and the suffix char is
|
||||
* exactly the prefix of last code! */
|
||||
if (CrntCode == Private->RunningCode - 2) {
|
||||
CrntPrefix = LastCode;
|
||||
Suffix[Private->RunningCode - 2] =
|
||||
Stack[StackPtr++] = DGifGetPrefixChar(Prefix,
|
||||
LastCode,
|
||||
ClearCode);
|
||||
} else {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
} else
|
||||
CrntPrefix = CrntCode;
|
||||
|
||||
/* Now (if image is O.K.) we should not get an NO_SUCH_CODE
|
||||
* During the trace. As we might loop forever, in case of
|
||||
* defective image, we count the number of loops we trace
|
||||
* and stop if we got LZ_MAX_CODE. obviously we can not
|
||||
* loop more than that. */
|
||||
j = 0;
|
||||
while (j++ <= LZ_MAX_CODE &&
|
||||
CrntPrefix > ClearCode && CrntPrefix <= LZ_MAX_CODE) {
|
||||
Stack[StackPtr++] = Suffix[CrntPrefix];
|
||||
CrntPrefix = Prefix[CrntPrefix];
|
||||
}
|
||||
if (j >= LZ_MAX_CODE || CrntPrefix > LZ_MAX_CODE) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
/* Push the last character on stack: */
|
||||
Stack[StackPtr++] = CrntPrefix;
|
||||
|
||||
/* Now lets pop all the stack into output: */
|
||||
while (StackPtr != 0 && i < LineLen)
|
||||
Line[i++] = Stack[--StackPtr];
|
||||
}
|
||||
if (LastCode != NO_SUCH_CODE) {
|
||||
Prefix[Private->RunningCode - 2] = LastCode;
|
||||
|
||||
if (CrntCode == Private->RunningCode - 2) {
|
||||
/* Only allowed if CrntCode is exactly the running code:
|
||||
* In that case CrntCode = XXXCode, CrntCode or the
|
||||
* prefix code is last code and the suffix char is
|
||||
* exactly the prefix of last code! */
|
||||
Suffix[Private->RunningCode - 2] =
|
||||
DGifGetPrefixChar(Prefix, LastCode, ClearCode);
|
||||
} else {
|
||||
Suffix[Private->RunningCode - 2] =
|
||||
DGifGetPrefixChar(Prefix, CrntCode, ClearCode);
|
||||
}
|
||||
}
|
||||
LastCode = CrntCode;
|
||||
}
|
||||
}
|
||||
|
||||
Private->LastCode = LastCode;
|
||||
Private->StackPtr = StackPtr;
|
||||
|
||||
return GIF_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Routine to trace the Prefixes linked list until we get a prefix which is
|
||||
* not code, but a pixel value (less than ClearCode). Returns that pixel value.
|
||||
* If image is defective, we might loop here forever, so we limit the loops to
|
||||
* the maximum possible if image O.k. - LZ_MAX_CODE times.
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifGetPrefixChar(GifPrefixType *Prefix,
|
||||
int Code,
|
||||
int ClearCode) {
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (Code > ClearCode && i++ <= LZ_MAX_CODE)
|
||||
Code = Prefix[Code];
|
||||
return Code;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* The LZ decompression input routine:
|
||||
* This routine is responsable for the decompression of the bit stream from
|
||||
* 8 bits (bytes) packets, into the real codes.
|
||||
* Returns GIF_OK if read succesfully.
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifDecompressInput(GifFileType * GifFile,
|
||||
int *Code) {
|
||||
|
||||
GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private;
|
||||
|
||||
GifByteType NextByte;
|
||||
static unsigned short CodeMasks[] = {
|
||||
0x0000, 0x0001, 0x0003, 0x0007,
|
||||
0x000f, 0x001f, 0x003f, 0x007f,
|
||||
0x00ff, 0x01ff, 0x03ff, 0x07ff,
|
||||
0x0fff
|
||||
};
|
||||
/* The image can't contain more than LZ_BITS per code. */
|
||||
if (Private->RunningBits > LZ_BITS) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
|
||||
while (Private->CrntShiftState < Private->RunningBits) {
|
||||
/* Needs to get more bytes from input stream for next code: */
|
||||
if (DGifBufferedInput(GifFile, Private->Buf, &NextByte) == GIF_ERROR) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
Private->CrntShiftDWord |=
|
||||
((unsigned long)NextByte) << Private->CrntShiftState;
|
||||
Private->CrntShiftState += 8;
|
||||
}
|
||||
*Code = Private->CrntShiftDWord & CodeMasks[Private->RunningBits];
|
||||
|
||||
Private->CrntShiftDWord >>= Private->RunningBits;
|
||||
Private->CrntShiftState -= Private->RunningBits;
|
||||
|
||||
/* If code cannot fit into RunningBits bits, must raise its size. Note
|
||||
* however that codes above 4095 are used for special signaling.
|
||||
* If we're using LZ_BITS bits already and we're at the max code, just
|
||||
* keep using the table as it is, don't increment Private->RunningCode.
|
||||
*/
|
||||
if (Private->RunningCode < LZ_MAX_CODE + 2 &&
|
||||
++Private->RunningCode > Private->MaxCode1 &&
|
||||
Private->RunningBits < LZ_BITS) {
|
||||
Private->MaxCode1 <<= 1;
|
||||
Private->RunningBits++;
|
||||
}
|
||||
return GIF_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* This routines read one gif data block at a time and buffers it internally
|
||||
* so that the decompression routine could access it.
|
||||
* The routine returns the next byte from its internal buffer (or read next
|
||||
* block in if buffer empty) and returns GIF_OK if succesful.
|
||||
*****************************************************************************/
|
||||
static int
|
||||
DGifBufferedInput(GifFileType * GifFile,
|
||||
GifByteType * Buf,
|
||||
GifByteType * NextByte) {
|
||||
|
||||
if (Buf[0] == 0) {
|
||||
/* Needs to read the next buffer - this one is empty: */
|
||||
if (READ(GifFile, Buf, 1) != 1) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
/* There shouldn't be any empty data blocks here as the LZW spec
|
||||
* says the LZW termination code should come first. Therefore we
|
||||
* shouldn't be inside this routine at that point.
|
||||
*/
|
||||
if (Buf[0] == 0) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
if (READ(GifFile, &Buf[1], Buf[0]) != Buf[0]) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
*NextByte = Buf[1];
|
||||
Buf[1] = 2; /* We use now the second place as last char read! */
|
||||
Buf[0]--;
|
||||
} else {
|
||||
*NextByte = Buf[Buf[1]++];
|
||||
Buf[0]--;
|
||||
}
|
||||
|
||||
return GIF_OK;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* This routine reads an entire GIF into core, hanging all its state info off
|
||||
* the GifFileType pointer. Call DGifOpenFileName() or DGifOpenFileHandle()
|
||||
* first to initialize I/O. Its inverse is EGifSpew().
|
||||
******************************************************************************/
|
||||
int
|
||||
DGifSlurp(GifFileType * GifFile) {
|
||||
|
||||
int ImageSize;
|
||||
GifRecordType RecordType;
|
||||
SavedImage *sp;
|
||||
GifByteType *ExtData;
|
||||
SavedImage temp_save;
|
||||
|
||||
temp_save.ExtensionBlocks = NULL;
|
||||
temp_save.ExtensionBlockCount = 0;
|
||||
|
||||
do {
|
||||
if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR)
|
||||
return (GIF_ERROR);
|
||||
|
||||
switch (RecordType) {
|
||||
case IMAGE_DESC_RECORD_TYPE:
|
||||
if (DGifGetImageDesc(GifFile) == GIF_ERROR)
|
||||
return (GIF_ERROR);
|
||||
|
||||
sp = &GifFile->SavedImages[GifFile->ImageCount - 1];
|
||||
ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height;
|
||||
|
||||
sp->RasterBits = malloc(ImageSize * sizeof(GifPixelType));
|
||||
if (sp->RasterBits == NULL) {
|
||||
return GIF_ERROR;
|
||||
}
|
||||
if (DGifGetLine(GifFile, sp->RasterBits, ImageSize) ==
|
||||
GIF_ERROR)
|
||||
return (GIF_ERROR);
|
||||
if (temp_save.ExtensionBlocks) {
|
||||
sp->ExtensionBlocks = temp_save.ExtensionBlocks;
|
||||
sp->ExtensionBlockCount = temp_save.ExtensionBlockCount;
|
||||
|
||||
temp_save.ExtensionBlocks = NULL;
|
||||
temp_save.ExtensionBlockCount = 0;
|
||||
|
||||
/* FIXME: The following is wrong. It is left in only for
|
||||
* backwards compatibility. Someday it should go away. Use
|
||||
* the sp->ExtensionBlocks->Function variable instead. */
|
||||
sp->Function = sp->ExtensionBlocks[0].Function;
|
||||
}
|
||||
break;
|
||||
|
||||
case EXTENSION_RECORD_TYPE:
|
||||
if (DGifGetExtension(GifFile, &temp_save.Function, &ExtData) ==
|
||||
GIF_ERROR)
|
||||
return (GIF_ERROR);
|
||||
while (ExtData != NULL) {
|
||||
|
||||
/* Create an extension block with our data */
|
||||
if (AddExtensionBlock(&temp_save, ExtData[0], &ExtData[1])
|
||||
== GIF_ERROR)
|
||||
return (GIF_ERROR);
|
||||
|
||||
if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR)
|
||||
return (GIF_ERROR);
|
||||
temp_save.Function = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case TERMINATE_RECORD_TYPE:
|
||||
break;
|
||||
|
||||
default: /* Should be trapped by DGifGetRecordType */
|
||||
break;
|
||||
}
|
||||
} while (RecordType != TERMINATE_RECORD_TYPE);
|
||||
|
||||
/* Just in case the Gif has an extension block without an associated
|
||||
* image... (Should we save this into a savefile structure with no image
|
||||
* instead? Have to check if the present writing code can handle that as
|
||||
* well.... */
|
||||
if (temp_save.ExtensionBlocks)
|
||||
FreeExtension(&temp_save);
|
||||
|
||||
return (GIF_OK);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* GifFileType constructor with user supplied input function (TVT)
|
||||
*****************************************************************************/
|
||||
GifFileType *
|
||||
DGifOpen(void *userData,
|
||||
InputFunc readFunc) {
|
||||
|
||||
unsigned char Buf[GIF_STAMP_LEN + 1];
|
||||
GifFileType *GifFile;
|
||||
GifFilePrivateType *Private;
|
||||
|
||||
GifFile = malloc(sizeof(GifFileType));
|
||||
if (GifFile == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset(GifFile, '\0', sizeof(GifFileType));
|
||||
|
||||
Private = malloc(sizeof(GifFilePrivateType));
|
||||
if (!Private) {
|
||||
free(GifFile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GifFile->Private = (void*)Private;
|
||||
|
||||
Private->Read = readFunc; /* TVT */
|
||||
GifFile->UserData = userData; /* TVT */
|
||||
|
||||
/* Lets see if this is a GIF file: */
|
||||
if (READ(GifFile, Buf, GIF_STAMP_LEN) != GIF_STAMP_LEN) {
|
||||
free(Private);
|
||||
free(GifFile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* The GIF Version number is ignored at this time. Maybe we should do
|
||||
* something more useful with it. */
|
||||
Buf[GIF_STAMP_LEN] = 0;
|
||||
if (memcmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) {
|
||||
free(Private);
|
||||
free(GifFile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (DGifGetScreenDesc(GifFile) == GIF_ERROR) {
|
||||
free(Private);
|
||||
free(GifFile);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return GifFile;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* This routine should be called last, to close the GIF file.
|
||||
*****************************************************************************/
|
||||
int
|
||||
DGifCloseFile(GifFileType * GifFile) {
|
||||
|
||||
GifFilePrivateType *Private;
|
||||
|
||||
if (GifFile == NULL)
|
||||
return GIF_ERROR;
|
||||
|
||||
Private = (GifFilePrivateType *) GifFile->Private;
|
||||
|
||||
if (GifFile->Image.ColorMap) {
|
||||
FreeMapObject(GifFile->Image.ColorMap);
|
||||
GifFile->Image.ColorMap = NULL;
|
||||
}
|
||||
|
||||
if (GifFile->SColorMap) {
|
||||
FreeMapObject(GifFile->SColorMap);
|
||||
GifFile->SColorMap = NULL;
|
||||
}
|
||||
|
||||
if (Private) {
|
||||
free(Private);
|
||||
Private = NULL;
|
||||
}
|
||||
|
||||
if (GifFile->SavedImages) {
|
||||
FreeSavedImages(GifFile);
|
||||
GifFile->SavedImages = NULL;
|
||||
}
|
||||
|
||||
free(GifFile);
|
||||
|
||||
return GIF_OK;
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* Gif extracting routines - derived from libungif
|
||||
*
|
||||
* Portions Copyright 2006 Mike McCormack
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* Original copyright notice:
|
||||
*
|
||||
* The GIFLIB distribution is Copyright (c) 1997 Eric S. Raymond
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* In order to make life a little bit easier when using the GIF file format,
|
||||
* this library was written, and which does all the dirty work...
|
||||
*
|
||||
* Written by Gershon Elber, Jun. 1989
|
||||
* Hacks by Eric S. Raymond, Sep. 1992
|
||||
******************************************************************************
|
||||
* History:
|
||||
* 14 Jun 89 - Version 1.0 by Gershon Elber.
|
||||
* 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names)
|
||||
* 15 Sep 90 - Version 2.0 by Eric S. Raymond (Changes to suoport GIF slurp)
|
||||
* 26 Jun 96 - Version 3.0 by Eric S. Raymond (Full GIF89 support)
|
||||
* 17 Dec 98 - Version 4.0 by Toshio Kuratomi (Fix extension writing code)
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _UNGIF_H_
|
||||
#define _UNGIF_H_ 1
|
||||
|
||||
#define GIF_ERROR 0
|
||||
#define GIF_OK 1
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif /* TRUE */
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif /* FALSE */
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif /* NULL */
|
||||
|
||||
#define GIF_STAMP "GIFVER" /* First chars in file - GIF stamp. */
|
||||
#define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1
|
||||
#define GIF_VERSION_POS 3 /* Version first character in stamp. */
|
||||
#define GIF87_STAMP "GIF87a" /* First chars in file - GIF stamp. */
|
||||
#define GIF89_STAMP "GIF89a" /* First chars in file - GIF stamp. */
|
||||
|
||||
#define GIF_FILE_BUFFER_SIZE 16384 /* Files uses bigger buffers than usual. */
|
||||
|
||||
typedef int GifBooleanType;
|
||||
typedef unsigned char GifPixelType;
|
||||
typedef unsigned char *GifRowType;
|
||||
typedef unsigned char GifByteType;
|
||||
typedef unsigned int GifPrefixType;
|
||||
typedef int GifWord;
|
||||
|
||||
typedef struct GifColorType {
|
||||
GifByteType Red, Green, Blue;
|
||||
} GifColorType;
|
||||
|
||||
typedef struct ColorMapObject {
|
||||
int ColorCount;
|
||||
int BitsPerPixel;
|
||||
GifColorType *Colors; /* on malloc(3) heap */
|
||||
} ColorMapObject;
|
||||
|
||||
typedef struct GifImageDesc {
|
||||
GifWord Left, Top, Width, Height, /* Current image dimensions. */
|
||||
Interlace; /* Sequential/Interlaced lines. */
|
||||
ColorMapObject *ColorMap; /* The local color map */
|
||||
} GifImageDesc;
|
||||
|
||||
typedef struct GifFileType {
|
||||
GifWord SWidth, SHeight, /* Screen dimensions. */
|
||||
SColorResolution, /* How many colors can we generate? */
|
||||
SBackGroundColor; /* I hope you understand this one... */
|
||||
ColorMapObject *SColorMap; /* NULL if not exists. */
|
||||
int ImageCount; /* Number of current image */
|
||||
GifImageDesc Image; /* Block describing current image */
|
||||
struct SavedImage *SavedImages; /* Use this to accumulate file state */
|
||||
void *UserData; /* hook to attach user data (TVT) */
|
||||
void *Private; /* Don't mess with this! */
|
||||
} GifFileType;
|
||||
|
||||
typedef enum {
|
||||
UNDEFINED_RECORD_TYPE,
|
||||
SCREEN_DESC_RECORD_TYPE,
|
||||
IMAGE_DESC_RECORD_TYPE, /* Begin with ',' */
|
||||
EXTENSION_RECORD_TYPE, /* Begin with '!' */
|
||||
TERMINATE_RECORD_TYPE /* Begin with ';' */
|
||||
} GifRecordType;
|
||||
|
||||
/* func type to read gif data from arbitrary sources (TVT) */
|
||||
typedef int (*InputFunc) (GifFileType *, GifByteType *, int);
|
||||
|
||||
/* GIF89 extension function codes */
|
||||
|
||||
#define COMMENT_EXT_FUNC_CODE 0xfe /* comment */
|
||||
#define GRAPHICS_EXT_FUNC_CODE 0xf9 /* graphics control */
|
||||
#define PLAINTEXT_EXT_FUNC_CODE 0x01 /* plaintext */
|
||||
#define APPLICATION_EXT_FUNC_CODE 0xff /* application block */
|
||||
|
||||
/* public interface to ungif.c */
|
||||
int DGifSlurp(GifFileType * GifFile);
|
||||
GifFileType *DGifOpen(void *userPtr, InputFunc readFunc);
|
||||
int DGifCloseFile(GifFileType * GifFile);
|
||||
|
||||
#define D_GIF_ERR_OPEN_FAILED 101 /* And DGif possible errors. */
|
||||
#define D_GIF_ERR_READ_FAILED 102
|
||||
#define D_GIF_ERR_NOT_GIF_FILE 103
|
||||
#define D_GIF_ERR_NO_SCRN_DSCR 104
|
||||
#define D_GIF_ERR_NO_IMAG_DSCR 105
|
||||
#define D_GIF_ERR_NO_COLOR_MAP 106
|
||||
#define D_GIF_ERR_WRONG_RECORD 107
|
||||
#define D_GIF_ERR_DATA_TOO_BIG 108
|
||||
#define D_GIF_ERR_NOT_ENOUGH_MEM 109
|
||||
#define D_GIF_ERR_CLOSE_FAILED 110
|
||||
#define D_GIF_ERR_NOT_READABLE 111
|
||||
#define D_GIF_ERR_IMAGE_DEFECT 112
|
||||
#define D_GIF_ERR_EOF_TOO_SOON 113
|
||||
|
||||
/******************************************************************************
|
||||
* Support for the in-core structures allocation (slurp mode).
|
||||
*****************************************************************************/
|
||||
|
||||
/* This is the in-core version of an extension record */
|
||||
typedef struct {
|
||||
int ByteCount;
|
||||
char *Bytes; /* on malloc(3) heap */
|
||||
int Function; /* Holds the type of the Extension block. */
|
||||
} ExtensionBlock;
|
||||
|
||||
/* This holds an image header, its unpacked raster bits, and extensions */
|
||||
typedef struct SavedImage {
|
||||
GifImageDesc ImageDesc;
|
||||
unsigned char *RasterBits; /* on malloc(3) heap */
|
||||
int Function; /* DEPRECATED: Use ExtensionBlocks[x].Function instead */
|
||||
int ExtensionBlockCount;
|
||||
ExtensionBlock *ExtensionBlocks; /* on malloc(3) heap */
|
||||
} SavedImage;
|
||||
|
||||
#endif /* _UNGIF_H_ */
|
|
@ -212,12 +212,6 @@
|
|||
/* Define to 1 if you have the `getuid' function. */
|
||||
#undef HAVE_GETUID
|
||||
|
||||
/* Define if you have usable GIF headers */
|
||||
#undef HAVE_GIF
|
||||
|
||||
/* Define to 1 if you have the <gif_lib.h> header file. */
|
||||
#undef HAVE_GIF_LIB_H
|
||||
|
||||
/* Define to 1 if you have the <GL/glext.h> header file. */
|
||||
#undef HAVE_GL_GLEXT_H
|
||||
|
||||
|
@ -992,9 +986,6 @@
|
|||
/* Define to the soname of the libfreetype library. */
|
||||
#undef SONAME_LIBFREETYPE
|
||||
|
||||
/* Define to the soname of the libgif library. */
|
||||
#undef SONAME_LIBGIF
|
||||
|
||||
/* Define to the soname of the libGL library. */
|
||||
#undef SONAME_LIBGL
|
||||
|
||||
|
@ -1016,9 +1007,6 @@
|
|||
/* Define to the soname of the libtxc_dxtn library. */
|
||||
#undef SONAME_LIBTXC_DXTN
|
||||
|
||||
/* Define to the soname of the libungif library. */
|
||||
#undef SONAME_LIBUNGIF
|
||||
|
||||
/* Define to the soname of the libX11 library. */
|
||||
#undef SONAME_LIBX11
|
||||
|
||||
|
|
Loading…
Reference in New Issue