mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-18 12:00:31 +01:00
wrlib: Added support for webp image
This patch is adding support for google webp image format, if you don't know it a quick recap is to say that according to their tests they claim it is better than png and jpeg. Follow the link below for some more details: https://developers.google.com/speed/webp/ Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
This commit is contained in:
committed by
Carlos R. Mafra
parent
de1421394c
commit
050cae3bd2
24
wrlib/load.c
24
wrlib/load.c
@@ -3,6 +3,7 @@
|
||||
* Raster graphics library
|
||||
*
|
||||
* Copyright (c) 1997-2003 Alfredo K. Kojima
|
||||
* Copyright (c) 2014 Window Maker Team
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
@@ -93,6 +94,9 @@ char **RSupportedFileFormats(void)
|
||||
#endif
|
||||
#ifdef USE_GIF
|
||||
tmp[i++] = "GIF";
|
||||
#endif
|
||||
#ifdef USE_WEBP
|
||||
tmp[i++] = "WEBP";
|
||||
#endif
|
||||
tmp[i] = NULL;
|
||||
|
||||
@@ -192,6 +196,12 @@ RImage *RLoadImage(RContext * context, const char *file, int index)
|
||||
break;
|
||||
#endif /* USE_GIF */
|
||||
|
||||
#ifdef USE_WEBP
|
||||
case IM_WEBP:
|
||||
image = RLoadWEBP(file);
|
||||
break;
|
||||
#endif /* USE_WEBP */
|
||||
|
||||
case IM_PPM:
|
||||
image = RLoadPPM(file);
|
||||
break;
|
||||
@@ -266,6 +276,11 @@ char *RGetImageFileFormat(const char *file)
|
||||
return "GIF";
|
||||
#endif /* USE_GIF */
|
||||
|
||||
#ifdef USE_WEBP
|
||||
case IM_WEBP:
|
||||
return "WEBP";
|
||||
#endif /* USE_WEBP */
|
||||
|
||||
case IM_PPM:
|
||||
return "PPM";
|
||||
|
||||
@@ -329,5 +344,14 @@ static WRImgFormat identFile(const char *path)
|
||||
(buffer[4] == '7' || buffer[4] == '9') && buffer[5] == 'a')
|
||||
return IM_GIF;
|
||||
|
||||
/* check for WEBP */
|
||||
if (buffer[ 0] == 'R' && buffer[ 1] == 'I' && buffer[ 2] == 'F' && buffer[ 3] == 'F' &&
|
||||
buffer[ 8] == 'W' && buffer[ 9] == 'E' && buffer[10] == 'B' && buffer[11] == 'P' &&
|
||||
buffer[12] == 'V' && buffer[13] == 'P' && buffer[14] == '8' &&
|
||||
(buffer[15] == ' ' /* Simple File Format (Lossy) */
|
||||
|| buffer[15] == 'L' /* Simple File Format (Lossless) */
|
||||
|| buffer[15] == 'X')) /* Extended File Format */
|
||||
return IM_WEBP;
|
||||
|
||||
return IM_UNKNOWN;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user