skeleton to support WebP file

This commit is contained in:
Vincent Wei
2021-10-19 16:39:24 +08:00
parent 894d0f64a2
commit 5e43b76753
5 changed files with 132 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.60)
AC_INIT(libminigui, 5.0.7)
AC_INIT(libminigui, 5.0.8)
AC_CONFIG_SRCDIR(src/main/main.c)
dnl Set various version strings - taken gratefully from the SDL sources
@@ -16,9 +16,9 @@ dnl Set various version strings - taken gratefully from the SDL sources
#
MINIGUI_MAJOR_VERSION=5
MINIGUI_MINOR_VERSION=0
MINIGUI_MICRO_VERSION=7
MINIGUI_INTERFACE_AGE=1
MINIGUI_BINARY_AGE=1
MINIGUI_MICRO_VERSION=8
MINIGUI_INTERFACE_AGE=2
MINIGUI_BINARY_AGE=2
MINIGUI_VERSION=$MINIGUI_MAJOR_VERSION.$MINIGUI_MINOR_VERSION.$MINIGUI_MICRO_VERSION
AC_SUBST(MINIGUI_MAJOR_VERSION)
@@ -222,6 +222,7 @@ build_save_bitmap="yes"
build_gif_support="yes"
build_jpg_support="yes"
build_png_support="yes"
build_webp_support="yes"
build_pcx_support="no"
build_lbm_support="no"
build_tga_support="no"
@@ -727,6 +728,10 @@ AC_ARG_ENABLE(pngsupport,
[ --enable-pngsupport include PNG file support <default=yes>],
build_png_support=$enableval)
AC_ARG_ENABLE(webpsupport,
[ --enable-webpsupport include WebP file support <default=yes>],
build_webp_support=$enableval)
AC_ARG_ENABLE(menu,
[ --enable-menu include menu support <default=yes>],
build_menu=$enableval)
@@ -1438,6 +1443,12 @@ case "$libpng_version" in
;;
esac
dnl Check for WebP library.
if test "x$build_webp_support" = "xyes"; then
PKG_CHECK_MODULES([WEBP], [libwebp >= 0.6.0], [foo=bar],
[build_webp_support="no; support WebP file requires libwebp 0.6.0 or later."])
fi
AC_DEFINE_UNQUOTED(MINIGUI_MAJOR_VERSION, $MINIGUI_MAJOR_VERSION,
[Major version of MiniGUI])
AC_DEFINE_UNQUOTED(MINIGUI_MINOR_VERSION, $MINIGUI_MINOR_VERSION,
@@ -2436,16 +2447,30 @@ fi
if test "x$build_jpg_support" = "xyes"; then
AC_DEFINE(_MGIMAGE_JPG, 1,
[Define if support JPEG bmp file format])
[Define if support JPEG file format])
fi
if test "x$build_png_support" = "xyes"; then
AC_DEFINE(_MGIMAGE_PNG, 1,
[Define if support PNG bmp file format])
[Define if support PNG file format])
AC_DEFINE_UNQUOTED(_MGLIBPNG_VER, $libpng_version,
[Define version of libpng])
fi
if test "x$build_webp_support" = "xyes"; then
AC_DEFINE(_MGIMAGE_WEBP, 1,
[Define if support WebP file format])
AC_ARG_WITH(webp_includes,
[ --with-webp-includes=DIR where the libwebp includes are])
if test "x$with_webp_includes" != "x"; then
WEBP_CFLAGS="-I$with_webp_includes"
fi
DEP_LIBS="$DEP_LIBS $WEBP_LIBS"
AC_SUBST(WEBP_CFLAGS)
fi
if test "x$build_menu" = "xyes"; then
AC_DEFINE(_MGHAVE_MENU, 1,
[Define if support menu])
@@ -2774,6 +2799,7 @@ AC_MSG_NOTICE([
## Other Features:
* JPEG: ${build_jpg_support}
* PNG: ${build_png_support}
* WebP: ${build_webp_support}
* Unicode: ${build_unicode_support}
* Complex Scripts: ${build_complex_scripts}
@@ -2782,6 +2808,7 @@ AC_MSG_NOTICE([
* CPP flags: ${CPPFLAGS}
* CC flags: ${CFLAGS}
* CXX flags: ${CXXFLAGS}
* LibWebP includes: ${WEBP_CFLAGS}
* Pixman includes: ${PIXMAN_CFLAGS}
* FreeType2 includes: ${FT2_INC_DIR}
* HarfBuzz includes: ${HB_INC_DIR}

View File

@@ -138,6 +138,14 @@ int __mg_save_png (MG_RWops* fp, MYBITMAP* bmp, RGB* pal);
BOOL __mg_check_png (MG_RWops* fp);
#endif
#ifdef _MGIMAGE_WEBP
void* __mg_init_webp (MG_RWops* fp, MYBITMAP *png, RGB *pal);
int __mg_load_webp (MG_RWops* fp, void* init_info, MYBITMAP *png, CB_ONE_SCANLINE cb, void* context);
void __mg_cleanup_webp (void* init_info);
int __mg_save_webp (MG_RWops* fp, MYBITMAP* bmp, RGB* pal);
BOOL __mg_check_webp (MG_RWops* fp);
#endif
int __mg_bmp_compute_pitch (int bpp, Uint32 width, Uint32 *pitch, BOOL does_round);
#define fp_getc(fp) MGUI_RWgetc(fp)

View File

@@ -1,8 +1,9 @@
AM_CPPFLAGS = -I$(abs_top_srcdir)/src/include -I$(abs_top_srcdir)/include
AM_CPPFLAGS = $(WEBP_CFLAGS)
AM_CPPFLAGS += -I$(abs_top_srcdir)/src/include -I$(abs_top_srcdir)/include
noinst_LTLIBRARIES = libmybmp.la
SRC_FILES = mybmp.c winbmp.c gif.c jpeg.c png12.c png16.c lbm.c pcx.c tga.c
SRC_FILES = mybmp.c winbmp.c gif.c jpeg.c png12.c png16.c webp.c lbm.c pcx.c tga.c
libmybmp_la_SOURCES = $(SRC_FILES)

View File

@@ -98,6 +98,9 @@ static BITMAP_TYPE_INFO bitmap_types [MAX_BITMAP_TYPES] =
#ifdef _MGIMAGE_PNG
{ "png", __mg_init_png, __mg_load_png, __mg_cleanup_png, NULL, __mg_check_png },
#endif
#ifdef _MGIMAGE_WEBP
{ "webp", __mg_init_webp, __mg_load_webp, __mg_cleanup_webp, NULL, __mg_check_webp },
#endif
};
/*

85
src/mybmp/webp.c Normal file
View File

@@ -0,0 +1,85 @@
///////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT NOTICE
//
// The following open source license statement does not apply to any
// entity in the Exception List published by FMSoft.
//
// For more information, please visit:
//
// https://www.fmsoft.cn/exception-list
//
//////////////////////////////////////////////////////////////////////////////
/*
* This file is part of MiniGUI, a mature cross-platform windowing
* and Graphics User Interface (GUI) support system for embedded systems
* and smart IoT devices.
*
* Copyright (C) 2002~2021, Beijing FMSoft Technologies Co., Ltd.
* Copyright (C) 1998~2002, WEI Yongming
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Or,
*
* As this program is a library, any link to this program must follow
* GNU General Public License version 3 (GPLv3). If you cannot accept
* GPLv3, you need to be licensed from FMSoft.
*
* If you have got a commercial license of this program, please use it
* under the terms and conditions of the commercial license.
*
* For more information about the commercial license, please refer to
* <http://www.minigui.com/blog/minigui-licensing-policy/>.
*/
/*
** webp.c: Low-level WebP file read routines (based on LibWebP 0.6)
**
** Current maintainer: Wei Yongming
**
** Create date: 2021/10/19
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "common.h"
#ifdef _MGIMAGE_WEBP
#include "gdi.h"
#include <webp/decode.h>
void* __mg_init_webp(MG_RWops *fp, MYBITMAP *mybmp, RGB *pal)
{
return NULL;
}
void __mg_cleanup_webp(void *init_info)
{
}
int __mg_load_webp (MG_RWops *fp, void *init_info, MYBITMAP *my_bmp,
CB_ONE_SCANLINE cb, void *context)
{
return ERR_BMP_OK;
}
BOOL __mg_check_webp (MG_RWops* fp)
{
}
#endif /* _MGIMAGE_WEBP */