1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

Moved declaration of format-specific image Load functions to dedicated header

The functions are declared in different files but they were called
in another file which re-declared the prototypes. This is dangerous
as it can lead to misaligned prototypes when functions changes.

They are now grouped in the library internal header 'imgformat.h'
This commit is contained in:
Christophe CURIS
2013-05-01 20:26:29 +02:00
committed by Carlos R. Mafra
parent cacc04d4a2
commit 883cda48e3
10 changed files with 79 additions and 27 deletions

View File

@@ -19,6 +19,7 @@ bin_SCRIPTS = get-wraster-flags
include_HEADERS = wraster.h
libwraster_la_SOURCES = \
imgformat.h \
raster.c \
alpha_combine.c \
draw.c \

View File

@@ -31,6 +31,7 @@
#include <gif_lib.h>
#include "wraster.h"
#include "imgformat.h"
static int InterlacedOffset[] = { 0, 4, 2, 1 };
static int InterlacedJumps[] = { 8, 8, 4, 2 };

70
wrlib/imgformat.h Normal file
View File

@@ -0,0 +1,70 @@
/*
* Raster graphics library
*
* Copyright (c) 1997-2003 Alfredo K. Kojima
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library 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.
*/
/*
* Functions to load and save RImage from/to file in a specific file format
*
* These functions are for WRaster library's internal use only, please use
* the RLoadImage function defined in 'wraster.h'
*/
#ifndef IMGFORMAT_INTERNAL_H
#define IMGFORMAT_INTERNAL_H
#define IM_ERROR -1
#define IM_UNKNOWN 0
#define IM_XPM 1
#define IM_TIFF 2
#define IM_PNG 3
#define IM_PPM 4
#define IM_JPEG 5
#define IM_GIF 6
/* How many image types we have. */
/* Increase this when adding new image types! */
#define IM_TYPES 6
/*
* Function for Loading in a specific format
*/
RImage *RLoadPPM(char *file_name);
RImage *RLoadXPM(RContext *context, char *file);
#ifdef USE_TIFF
RImage *RLoadTIFF(char *file, int index);
#endif
#ifdef USE_PNG
RImage *RLoadPNG(RContext *context, char *file);
#endif
#ifdef USE_JPEG
RImage *RLoadJPEG(RContext *context, char *file);
#endif
#ifdef USE_GIF
RImage *RLoadGIF(char *file, int index);
#endif
#endif

View File

@@ -34,6 +34,7 @@
#include <jpeglib.h>
#include "wraster.h"
#include "imgformat.h"
/*
* <setjmp.h> is used for the optional error recovery mechanism shown in

View File

@@ -38,6 +38,7 @@
#endif
#include "wraster.h"
#include "imgformat.h"
#define RETRY( x ) do { \
x; \
@@ -66,36 +67,9 @@ static int RImageCacheMaxImage = -1; /* 0 = any size */
static RCachedImage *RImageCache;
#define IM_ERROR -1
#define IM_UNKNOWN 0
#define IM_XPM 1
#define IM_TIFF 2
#define IM_PNG 3
#define IM_PPM 4
#define IM_JPEG 5
#define IM_GIF 6
/* How many image types do we have. */
/* Increase this when adding new image types! */
#define IM_TYPES 6
static int identFile(char *path);
extern RImage *RLoadPPM(char *file_name);
extern RImage *RLoadXPM(RContext * context, char *file);
#ifdef USE_TIFF
extern RImage *RLoadTIFF(char *file, int index);
#endif
#ifdef USE_PNG
extern RImage *RLoadPNG(RContext * context, char *file);
#endif
#ifdef USE_JPEG
extern RImage *RLoadJPEG(RContext * context, char *file_name);
#endif
#ifdef USE_GIF
extern RImage *RLoadGIF(char *file_name, int index);
#endif
char **RSupportedFileFormats(void)
{

View File

@@ -29,6 +29,7 @@
#include <errno.h>
#include "wraster.h"
#include "imgformat.h"
/*
* Restricted support for XPM images.

View File

@@ -31,6 +31,7 @@
#include <png.h>
#include "wraster.h"
#include "imgformat.h"
RImage *RLoadPNG(RContext * context, char *file)
{

View File

@@ -28,6 +28,7 @@
#include <string.h>
#include "wraster.h"
#include "imgformat.h"
static RImage *load_graymap(FILE * file, int w, int h, int max, int raw)
{

View File

@@ -32,6 +32,7 @@
#include <tiffio.h>
#include "wraster.h"
#include "imgformat.h"
RImage *RLoadTIFF(char *file, int index)
{

View File

@@ -31,6 +31,7 @@
#include <X11/xpm.h>
#include "wraster.h"
#include "imgformat.h"
RImage *RGetImageFromXPMData(RContext * context, char **xpmData)
{