diff --git a/Makefile.am b/Makefile.am index 61fa2f3..59b37c6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,6 +3,6 @@ SUBDIRS = pipi src genethumb examples test pipi-sharp ThePimp DIST_SUBDIRS = $(SUBDIRS) win32 -EXTRA_DIST = bootstrap build-win32 common.h NOTES +EXTRA_DIST = bootstrap build-win32 NOTES AUTOMAKE_OPTIONS = dist-bzip2 diff --git a/configure.ac b/configure.ac index 017672f..1e8b793 100644 --- a/configure.ac +++ b/configure.ac @@ -67,6 +67,21 @@ fi AM_CONDITIONAL(NEED_GETOPT_LONG, test "$ac_cv_have_getopt_long" = "no") AC_SUBST(GETOPT_LIBS) +# How to get the C99 types. See pipi/pipi_types.h.in for details about +# the PIPI_TYPES variable +if test "${ac_cv_my_have_vga}" = "yes"; then + PIPI_TYPES=0 +else + AC_CHECK_HEADERS(stdint.h, + [PIPI_TYPES=1], + [AC_CHECK_HEADERS(inttypes.h, + [PIPI_TYPES=2], + [AC_CHECK_HEADERS(windows.h, + [PIPI_TYPES=3], + [PIPI_TYPES=0])])]) +fi +AC_SUBST(PIPI_TYPES) + # Optimizations CFLAGS="${CFLAGS} -g -O2 -fno-strength-reduce -fomit-frame-pointer" # Code qui fait des warnings == code de porc == deux baffes dans ta gueule @@ -174,6 +189,7 @@ AC_CONFIG_FILES([ win32/Makefile ]) AC_CONFIG_FILES([ + pipi/pipi_types.h pipi/pipi.pc pipi-sharp/pipi-sharp.pc pipi-sharp/pipi-sharp.dll.config diff --git a/examples/bezier.c b/examples/bezier.c index ed0ada7..aba2acf 100644 --- a/examples/bezier.c +++ b/examples/bezier.c @@ -1,5 +1,4 @@ #include "config.h" -#include "common.h" #include #include diff --git a/examples/edd.c b/examples/edd.c index 4ed621d..5fdc852 100644 --- a/examples/edd.c +++ b/examples/edd.c @@ -23,7 +23,6 @@ * are not entirely black and white. */ #include "config.h" -#include "common.h" #include #include diff --git a/examples/floodfill.c b/examples/floodfill.c index 141c029..1ba505b 100644 --- a/examples/floodfill.c +++ b/examples/floodfill.c @@ -1,5 +1,4 @@ #include "config.h" -#include "common.h" #include #include diff --git a/examples/histogram.c b/examples/histogram.c index 9f6726d..d6b2893 100644 --- a/examples/histogram.c +++ b/examples/histogram.c @@ -1,5 +1,4 @@ #include "config.h" -#include "common.h" #include #include diff --git a/examples/img2rubik.c b/examples/img2rubik.c index 3c7e0ea..c4c46af 100644 --- a/examples/img2rubik.c +++ b/examples/img2rubik.c @@ -1,5 +1,4 @@ #include "config.h" -#include "common.h" #include #include diff --git a/examples/line.c b/examples/line.c index 775c445..e8f532e 100644 --- a/examples/line.c +++ b/examples/line.c @@ -1,5 +1,4 @@ #include "config.h" -#include "common.h" #include #include diff --git a/examples/sharpen.c b/examples/sharpen.c index 3218e3e..88f7f30 100644 --- a/examples/sharpen.c +++ b/examples/sharpen.c @@ -1,5 +1,4 @@ #include "config.h" -#include "common.h" #include #include diff --git a/genethumb/genethumb.c b/genethumb/genethumb.c index 3a97bc5..1c76257 100644 --- a/genethumb/genethumb.c +++ b/genethumb/genethumb.c @@ -1,5 +1,4 @@ #include "config.h" -#include "common.h" #if !defined HAVE_GETOPT_LONG # include "mygetopt.h" diff --git a/pipi/Makefile.am b/pipi/Makefile.am index 308cd62..e774c01 100644 --- a/pipi/Makefile.am +++ b/pipi/Makefile.am @@ -1,6 +1,6 @@ # $Id$ -EXTRA_DIST = pipi.pc.in +EXTRA_DIST = pipi_types.h.in pipi.pc.in DISTCLEANFILES = pipi.pc AM_CPPFLAGS = -I$(top_srcdir) @@ -8,14 +8,16 @@ AM_CPPFLAGS = -I$(top_srcdir) pkgconfig_DATA = pipi.pc pkgconfigdir = $(libdir)/pkgconfig -include_HEADERS = pipi.h +include_HEADERS = pipi.h pipi_types.h # The main library lib_LTLIBRARIES = libpipi.la libpipi_la_SOURCES = \ pipi.c \ pipi.h \ + pipi_types.h \ pipi_internals.h \ + pipi_stubs.h \ pipi_template.h \ context.c \ pixels.c \ diff --git a/pipi/accessors.c b/pipi/accessors.c index 55cdf45..8ec3fae 100644 --- a/pipi/accessors.c +++ b/pipi/accessors.c @@ -18,7 +18,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/codec.c b/pipi/codec.c index 2dd6eac..5684499 100644 --- a/pipi/codec.c +++ b/pipi/codec.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/codec/coreimage.h b/pipi/codec/coreimage.h index 77395ba..c838775 100644 --- a/pipi/codec/coreimage.h +++ b/pipi/codec/coreimage.h @@ -20,8 +20,6 @@ #include "config.h" #ifdef USE_COCOA -#include "common.h" - #include #include #include @@ -31,4 +29,4 @@ #include "pipi.h" #include "pipi_internals.h" -#endif \ No newline at end of file +#endif diff --git a/pipi/codec/gdi.c b/pipi/codec/gdi.c index fa21126..7d0cc14 100644 --- a/pipi/codec/gdi.c +++ b/pipi/codec/gdi.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/codec/imlib.c b/pipi/codec/imlib.c index 404d43d..712df36 100644 --- a/pipi/codec/imlib.c +++ b/pipi/codec/imlib.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/codec/opencv.c b/pipi/codec/opencv.c index f55e645..c6c605f 100644 --- a/pipi/codec/opencv.c +++ b/pipi/codec/opencv.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/codec/oric.c b/pipi/codec/oric.c index 6ae5f25..28c4be4 100644 --- a/pipi/codec/oric.c +++ b/pipi/codec/oric.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/codec/sdl.c b/pipi/codec/sdl.c index d9d4d8c..983daaa 100644 --- a/pipi/codec/sdl.c +++ b/pipi/codec/sdl.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/colorstring.c b/pipi/colorstring.c index e46915a..d359f8e 100644 --- a/pipi/colorstring.c +++ b/pipi/colorstring.c @@ -1,25 +1,3 @@ -/* - * libpipi Pathetic image processing interface library - * Copyright (c) 2004-2008 Sam Hocevar - * 2008 Jean-Yves Lamoureux @@ -40,12 +18,10 @@ */ #include "config.h" -#include "common.h" #include #include #include -#include #include #include "pipi.h" diff --git a/pipi/combine/mean.c b/pipi/combine/mean.c index b684510..7bd09e2 100644 --- a/pipi/combine/mean.c +++ b/pipi/combine/mean.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include "pipi.h" #include "pipi_internals.h" diff --git a/pipi/combine/minmax.c b/pipi/combine/minmax.c index d01fa08..874ad9f 100644 --- a/pipi/combine/minmax.c +++ b/pipi/combine/minmax.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include "pipi.h" #include "pipi_internals.h" diff --git a/pipi/combine/mulscreen.c b/pipi/combine/mulscreen.c index 6bb20a5..f53300c 100644 --- a/pipi/combine/mulscreen.c +++ b/pipi/combine/mulscreen.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include "pipi.h" #include "pipi_internals.h" diff --git a/pipi/combine/rgb.c b/pipi/combine/rgb.c index f79d648..509c086 100644 --- a/pipi/combine/rgb.c +++ b/pipi/combine/rgb.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include "pipi.h" #include "pipi_internals.h" diff --git a/pipi/combine/subadd.c b/pipi/combine/subadd.c index 47b9a56..88fd95e 100644 --- a/pipi/combine/subadd.c +++ b/pipi/combine/subadd.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include diff --git a/pipi/context.c b/pipi/context.c index 9af6d5c..eb302ad 100644 --- a/pipi/context.c +++ b/pipi/context.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/dither.c b/pipi/dither.c index 89918af..d6c179d 100644 --- a/pipi/dither.c +++ b/pipi/dither.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/dither/dbs.c b/pipi/dither/dbs.c index c3b9f61..520a8c3 100644 --- a/pipi/dither/dbs.c +++ b/pipi/dither/dbs.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/dither/ediff.c b/pipi/dither/ediff.c index a8e1a7e..4b20977 100644 --- a/pipi/dither/ediff.c +++ b/pipi/dither/ediff.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include "pipi.h" #include "pipi_internals.h" diff --git a/pipi/dither/ordered.c b/pipi/dither/ordered.c index 6579c4e..d5ed125 100644 --- a/pipi/dither/ordered.c +++ b/pipi/dither/ordered.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/dither/ostromoukhov.c b/pipi/dither/ostromoukhov.c index 8a8f1e3..0396daa 100644 --- a/pipi/dither/ostromoukhov.c +++ b/pipi/dither/ostromoukhov.c @@ -25,7 +25,6 @@ */ #include "config.h" -#include "common.h" #include "pipi.h" #include "pipi_internals.h" diff --git a/pipi/dither/random.c b/pipi/dither/random.c index a86d204..3417ac2 100644 --- a/pipi/dither/random.c +++ b/pipi/dither/random.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include "pipi.h" #include "pipi_internals.h" diff --git a/pipi/filter/autocontrast.c b/pipi/filter/autocontrast.c index 800b95e..4b9f4d1 100644 --- a/pipi/filter/autocontrast.c +++ b/pipi/filter/autocontrast.c @@ -19,7 +19,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/filter/blur.c b/pipi/filter/blur.c index 26eb507..3400c14 100644 --- a/pipi/filter/blur.c +++ b/pipi/filter/blur.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/filter/color.c b/pipi/filter/color.c index 2417acb..beff471 100644 --- a/pipi/filter/color.c +++ b/pipi/filter/color.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/filter/convolution.c b/pipi/filter/convolution.c index 337df63..6fe9ae7 100644 --- a/pipi/filter/convolution.c +++ b/pipi/filter/convolution.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/filter/dilate.c b/pipi/filter/dilate.c index 02f5cca..01cbbc4 100644 --- a/pipi/filter/dilate.c +++ b/pipi/filter/dilate.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/filter/median.c b/pipi/filter/median.c index 08da126..884a3c2 100644 --- a/pipi/filter/median.c +++ b/pipi/filter/median.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/filter/transform.c b/pipi/filter/transform.c index 1d2b0c9..dafd837 100644 --- a/pipi/filter/transform.c +++ b/pipi/filter/transform.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/histogram/histogram.c b/pipi/histogram/histogram.c index 3787115..f35cdfa 100644 --- a/pipi/histogram/histogram.c +++ b/pipi/histogram/histogram.c @@ -18,7 +18,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/measure.c b/pipi/measure.c index ca0b08d..3231d05 100644 --- a/pipi/measure.c +++ b/pipi/measure.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include diff --git a/pipi/paint/bezier.c b/pipi/paint/bezier.c index 0e9cfb9..3ddc223 100644 --- a/pipi/paint/bezier.c +++ b/pipi/paint/bezier.c @@ -18,7 +18,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/paint/floodfill.c b/pipi/paint/floodfill.c index abadc49..20d4bbd 100644 --- a/pipi/paint/floodfill.c +++ b/pipi/paint/floodfill.c @@ -18,7 +18,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/paint/line.c b/pipi/paint/line.c index 116ac00..0ccf145 100644 --- a/pipi/paint/line.c +++ b/pipi/paint/line.c @@ -18,7 +18,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/paint/tile.c b/pipi/paint/tile.c index d2da561..fd13711 100644 --- a/pipi/paint/tile.c +++ b/pipi/paint/tile.c @@ -17,9 +17,8 @@ */ #include "config.h" -#include "common.h" -#include +#include #include "pipi.h" #include "pipi_internals.h" diff --git a/pipi/pipi.c b/pipi/pipi.c index aa2a214..fae732a 100644 --- a/pipi/pipi.c +++ b/pipi/pipi.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/pipi.h b/pipi/pipi.h index fe417bf..624fbb8 100644 --- a/pipi/pipi.h +++ b/pipi/pipi.h @@ -20,9 +20,15 @@ #ifndef __PIPI_H__ #define __PIPI_H__ -#include -#include -#include +#include + +#undef __extern +#if defined(_DOXYGEN_SKIP_ME) +#elif defined(_WIN32) && defined(__LIBPIPI__) +# define __extern extern __declspec(dllexport) +#else +# define __extern extern +#endif #ifdef __cplusplus extern "C" @@ -112,103 +118,102 @@ typedef struct } pipi_command_t; -extern pipi_pixel_t *pipi_get_color_from_string(const char* s); +__extern pipi_pixel_t *pipi_get_color_from_string(const char* s); char const * pipi_get_version(void); -extern pipi_context_t *pipi_create_context(void); -extern void pipi_destroy_context(pipi_context_t *); -extern pipi_command_t const *pipi_get_command_list(void); -extern int pipi_command(pipi_context_t *, char const *, ...); - -extern pipi_image_t *pipi_load(char const *); -extern pipi_image_t *pipi_load_stock(char const *); -extern pipi_image_t *pipi_new(int, int); -extern pipi_image_t *pipi_copy(pipi_image_t *); -extern void pipi_free(pipi_image_t *); -extern int pipi_save(pipi_image_t *, const char *); - -extern void pipi_set_gamma(double); -extern pipi_pixels_t *pipi_getpixels(pipi_image_t *, pipi_format_t); -extern int pipi_get_image_width(pipi_image_t *img); -extern int pipi_get_image_height(pipi_image_t *img); -extern int pipi_get_image_pitch(pipi_image_t *img); -extern int pipi_get_image_last_modified(pipi_image_t *img); -extern const char* pipi_get_format_name(int format); - - -extern double pipi_measure_msd(pipi_image_t *, pipi_image_t *); -extern double pipi_measure_rmsd(pipi_image_t *, pipi_image_t *); - -extern pipi_image_t *pipi_resize(pipi_image_t *, int, int); - -extern pipi_image_t *pipi_render_random(int, int); -extern pipi_image_t *pipi_render_bayer(int, int); -extern pipi_image_t *pipi_render_halftone(int, int); - -extern pipi_image_t *pipi_rgb(pipi_image_t *, pipi_image_t *, pipi_image_t *); -extern pipi_image_t *pipi_red(pipi_image_t *); -extern pipi_image_t *pipi_green(pipi_image_t *); -extern pipi_image_t *pipi_blue(pipi_image_t *); -extern pipi_image_t *pipi_mean(pipi_image_t *, pipi_image_t *); -extern pipi_image_t *pipi_min(pipi_image_t *, pipi_image_t *); -extern pipi_image_t *pipi_max(pipi_image_t *, pipi_image_t *); -extern pipi_image_t *pipi_add(pipi_image_t *, pipi_image_t *); -extern pipi_image_t *pipi_sub(pipi_image_t *, pipi_image_t *); -extern pipi_image_t *pipi_difference(pipi_image_t *, pipi_image_t *); -extern pipi_image_t *pipi_multiply(pipi_image_t *, pipi_image_t *); -extern pipi_image_t *pipi_divide(pipi_image_t *, pipi_image_t *); -extern pipi_image_t *pipi_screen(pipi_image_t *, pipi_image_t *); -extern pipi_image_t *pipi_overlay(pipi_image_t *, pipi_image_t *); - -extern pipi_image_t *pipi_convolution(pipi_image_t *, int, int, double[]); -extern pipi_image_t *pipi_gaussian_blur(pipi_image_t *, float); -extern pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *, +__extern pipi_context_t *pipi_create_context(void); +__extern void pipi_destroy_context(pipi_context_t *); +__extern pipi_command_t const *pipi_get_command_list(void); +__extern int pipi_command(pipi_context_t *, char const *, ...); + +__extern pipi_image_t *pipi_load(char const *); +__extern pipi_image_t *pipi_load_stock(char const *); +__extern pipi_image_t *pipi_new(int, int); +__extern pipi_image_t *pipi_copy(pipi_image_t *); +__extern void pipi_free(pipi_image_t *); +__extern int pipi_save(pipi_image_t *, const char *); + +__extern void pipi_set_gamma(double); +__extern pipi_pixels_t *pipi_getpixels(pipi_image_t *, pipi_format_t); +__extern int pipi_get_image_width(pipi_image_t *img); +__extern int pipi_get_image_height(pipi_image_t *img); +__extern int pipi_get_image_pitch(pipi_image_t *img); +__extern int pipi_get_image_last_modified(pipi_image_t *img); +__extern const char* pipi_get_format_name(int format); + + +__extern double pipi_measure_msd(pipi_image_t *, pipi_image_t *); +__extern double pipi_measure_rmsd(pipi_image_t *, pipi_image_t *); + +__extern pipi_image_t *pipi_resize(pipi_image_t *, int, int); + +__extern pipi_image_t *pipi_render_random(int, int); +__extern pipi_image_t *pipi_render_bayer(int, int); +__extern pipi_image_t *pipi_render_halftone(int, int); + +__extern pipi_image_t *pipi_rgb(pipi_image_t *, pipi_image_t *, pipi_image_t *); +__extern pipi_image_t *pipi_red(pipi_image_t *); +__extern pipi_image_t *pipi_green(pipi_image_t *); +__extern pipi_image_t *pipi_blue(pipi_image_t *); +__extern pipi_image_t *pipi_mean(pipi_image_t *, pipi_image_t *); +__extern pipi_image_t *pipi_min(pipi_image_t *, pipi_image_t *); +__extern pipi_image_t *pipi_max(pipi_image_t *, pipi_image_t *); +__extern pipi_image_t *pipi_add(pipi_image_t *, pipi_image_t *); +__extern pipi_image_t *pipi_sub(pipi_image_t *, pipi_image_t *); +__extern pipi_image_t *pipi_difference(pipi_image_t *, pipi_image_t *); +__extern pipi_image_t *pipi_multiply(pipi_image_t *, pipi_image_t *); +__extern pipi_image_t *pipi_divide(pipi_image_t *, pipi_image_t *); +__extern pipi_image_t *pipi_screen(pipi_image_t *, pipi_image_t *); +__extern pipi_image_t *pipi_overlay(pipi_image_t *, pipi_image_t *); + +__extern pipi_image_t *pipi_convolution(pipi_image_t *, int, int, double[]); +__extern pipi_image_t *pipi_gaussian_blur(pipi_image_t *, float); +__extern pipi_image_t *pipi_gaussian_blur_ext(pipi_image_t *, float, float, float, float, float); -extern pipi_image_t *pipi_box_blur(pipi_image_t *, int); -extern pipi_image_t *pipi_box_blur_ext(pipi_image_t *, int, int); -extern pipi_image_t *pipi_brightness(pipi_image_t *, double); -extern pipi_image_t *pipi_contrast(pipi_image_t *, double); -extern pipi_image_t *pipi_autocontrast(pipi_image_t *); -extern pipi_image_t *pipi_invert(pipi_image_t *); -extern pipi_image_t *pipi_threshold(pipi_image_t *, double); -extern pipi_image_t *pipi_hflip(pipi_image_t *); -extern pipi_image_t *pipi_vflip(pipi_image_t *); -extern pipi_image_t *pipi_rotate90(pipi_image_t *); -extern pipi_image_t *pipi_rotate180(pipi_image_t *); -extern pipi_image_t *pipi_rotate270(pipi_image_t *); -extern pipi_image_t *pipi_median(pipi_image_t *, int); -extern pipi_image_t *pipi_median_ext(pipi_image_t *, int, int); -extern pipi_image_t *pipi_dilate(pipi_image_t *); -extern pipi_image_t *pipi_erode(pipi_image_t *); - -extern pipi_image_t *pipi_order(pipi_image_t *); - -extern pipi_image_t *pipi_tile(pipi_image_t *, int, int); -extern int pipi_flood_fill(pipi_image_t *, +__extern pipi_image_t *pipi_box_blur(pipi_image_t *, int); +__extern pipi_image_t *pipi_box_blur_ext(pipi_image_t *, int, int); +__extern pipi_image_t *pipi_brightness(pipi_image_t *, double); +__extern pipi_image_t *pipi_contrast(pipi_image_t *, double); +__extern pipi_image_t *pipi_autocontrast(pipi_image_t *); +__extern pipi_image_t *pipi_invert(pipi_image_t *); +__extern pipi_image_t *pipi_threshold(pipi_image_t *, double); +__extern pipi_image_t *pipi_hflip(pipi_image_t *); +__extern pipi_image_t *pipi_vflip(pipi_image_t *); +__extern pipi_image_t *pipi_rotate90(pipi_image_t *); +__extern pipi_image_t *pipi_rotate180(pipi_image_t *); +__extern pipi_image_t *pipi_rotate270(pipi_image_t *); +__extern pipi_image_t *pipi_median(pipi_image_t *, int); +__extern pipi_image_t *pipi_median_ext(pipi_image_t *, int, int); +__extern pipi_image_t *pipi_dilate(pipi_image_t *); +__extern pipi_image_t *pipi_erode(pipi_image_t *); + +__extern pipi_image_t *pipi_order(pipi_image_t *); + +__extern pipi_image_t *pipi_tile(pipi_image_t *, int, int); +__extern int pipi_flood_fill(pipi_image_t *, int, int, float, float, float, float); -extern int pipi_draw_line(pipi_image_t *, int, int, int, int, uint32_t, int); -extern int pipi_draw_polyline(pipi_image_t *, int const[], int const[], +__extern int pipi_draw_line(pipi_image_t *, int, int, int, int, uint32_t, int); +__extern int pipi_draw_polyline(pipi_image_t *, int const[], int const[], int , uint32_t, int); -extern int pipi_draw_bezier4(pipi_image_t *,int, int, int, int, int, int, int, int, uint32_t, int, int); -extern pipi_image_t *pipi_reduce(pipi_image_t *, int, double const *); +__extern int pipi_draw_bezier4(pipi_image_t *,int, int, int, int, int, int, int, int, uint32_t, int, int); +__extern pipi_image_t *pipi_reduce(pipi_image_t *, int, double const *); -extern pipi_image_t *pipi_dither_ediff(pipi_image_t *, pipi_image_t *, +__extern pipi_image_t *pipi_dither_ediff(pipi_image_t *, pipi_image_t *, pipi_scan_t); -extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *); -extern pipi_image_t *pipi_dither_ordered_ext(pipi_image_t *, pipi_image_t *, +__extern pipi_image_t *pipi_dither_ordered(pipi_image_t *, pipi_image_t *); +__extern pipi_image_t *pipi_dither_ordered_ext(pipi_image_t *, pipi_image_t *, double, double); -extern pipi_image_t *pipi_dither_halftone(pipi_image_t *, double, double); -extern pipi_image_t *pipi_dither_random(pipi_image_t *); -extern pipi_image_t *pipi_dither_ostromoukhov(pipi_image_t *, pipi_scan_t); -extern pipi_image_t *pipi_dither_dbs(pipi_image_t *); -extern void pipi_dither_24to16(pipi_image_t *); - -extern pipi_histogram_t* pipi_new_histogram(void); -extern int pipi_get_image_histogram(pipi_image_t *, pipi_histogram_t *, int); -extern int pipi_free_histogram(pipi_histogram_t*); -extern int pipi_render_histogram(pipi_image_t *, pipi_histogram_t*, int); - +__extern pipi_image_t *pipi_dither_halftone(pipi_image_t *, double, double); +__extern pipi_image_t *pipi_dither_random(pipi_image_t *); +__extern pipi_image_t *pipi_dither_ostromoukhov(pipi_image_t *, pipi_scan_t); +__extern pipi_image_t *pipi_dither_dbs(pipi_image_t *); +__extern void pipi_dither_24to16(pipi_image_t *); + +__extern pipi_histogram_t* pipi_new_histogram(void); +__extern int pipi_get_image_histogram(pipi_image_t *, pipi_histogram_t *, int); +__extern int pipi_free_histogram(pipi_histogram_t*); +__extern int pipi_render_histogram(pipi_image_t *, pipi_histogram_t*, int); #ifdef __cplusplus } diff --git a/pipi/pipi_internals.h b/pipi/pipi_internals.h index 01df7ec..73012f8 100644 --- a/pipi/pipi_internals.h +++ b/pipi/pipi_internals.h @@ -19,6 +19,8 @@ #ifndef __PIPI_INTERNALS_H__ #define __PIPI_INTERNALS_H__ +#include "pipi_stubs.h" + #define SET_FLAG_GRAY 0x00000001 #define SET_FLAG_WRAP 0x00000002 #define SET_FLAG_8BIT 0x00000004 diff --git a/common.h b/pipi/pipi_stubs.h similarity index 53% rename from common.h rename to pipi/pipi_stubs.h index 171d57e..55e7c9b 100644 --- a/common.h +++ b/pipi/pipi_stubs.h @@ -1,14 +1,13 @@ /* * libpipi Pathetic image processing interface library - * Copyright (c) 2004-2008 Sam Hocevar + * Copyright (c) 2006 Sam Hocevar * All Rights Reserved * * $Id$ * - * This library is free software. It comes without any warranty, to - * the extent permitted by applicable law. You can redistribute it - * and/or modify it under the terms of the Do What The Fuck You Want - * To Public License, Version 2, as published by Sam Hocevar. See + * This library is free software; you can redistribute it and/or + * modify it under the terms of the Do What The Fuck You Want To + * Public License, Version 2, as published by Sam Hocevar. See * http://sam.zoy.org/wtfpl/COPYING for more details. */ @@ -17,30 +16,41 @@ * function prototypes that are sometimes missing. */ -#ifndef __COMMON_H__ -#define __COMMON_H__ +#ifndef __PIPI_STUBS_H__ +#define __PIPI_STUBS_H__ -/* C99 types */ -#if defined HAVE_INTTYPES_H && !defined __KERNEL__ -# include +/* errno handling */ +#if defined HAVE_ERRNO_H && !defined __KERNEL__ +# include +static inline void seterrno(int e) { errno = e; } +static inline int geterrno(void) { return errno; } #else -typedef signed char int8_t; -typedef signed short int16_t; -typedef signed long int int32_t; - -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned long int uint32_t; +# define seterrno(x) do { (void)(x); } while(0) +# define geterrno(x) 0 +#endif -typedef long int intptr_t; -typedef unsigned long int uintptr_t; +/* debug messages */ +#if defined DEBUG && !defined __KERNEL__ +# include +# include +static inline void debug(const char *format, ...) +{ + int saved_errno = geterrno(); + va_list args; + va_start(args, format); + fprintf(stderr, "** libpipi debug ** "); + vfprintf(stderr, format, args); + fprintf(stderr, "\n"); + va_end(args); + seterrno(saved_errno); +} +#else +# define debug(format, ...) do {} while(0) #endif /* hton16() and hton32() */ -#if defined HAVE_HTONS -# if defined __KERNEL__ - /* Nothing to do */ -# elif defined HAVE_ARPA_INET_H +#if defined HAVE_HTONS && !defined __KERNEL__ +# if defined HAVE_ARPA_INET_H # include # elif defined HAVE_NETINET_IN_H # include @@ -48,7 +58,9 @@ typedef unsigned long int uintptr_t; # define hton16 htons # define hton32 htonl #else -# if defined HAVE_ENDIAN_H +# if defined __KERNEL__ + /* Nothing to do */ +# elif defined HAVE_ENDIAN_H # include # endif static inline uint16_t hton16(uint16_t x) @@ -81,5 +93,5 @@ static inline uint32_t hton32(uint32_t x) } #endif -#endif /* __COMMON_H__ */ +#endif /* __PIPI_STUBS_H__ */ diff --git a/pipi/pipi_types.h.in b/pipi/pipi_types.h.in new file mode 100644 index 0000000..bc3454d --- /dev/null +++ b/pipi/pipi_types.h.in @@ -0,0 +1,100 @@ +/* + * libpipi Pathetic image processing interface library + * Copyright (c) 2008 Sam Hocevar + * All Rights Reserved + * + * $Id$ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the Do What The Fuck You Want To + * Public License, Version 2, as published by Sam Hocevar. See + * http://sam.zoy.org/wtfpl/COPYING for more details. + */ + +/* + * This file contains definitions for the C99 integer types. + */ + +#ifndef __PIPI_TYPES_H__ +#define __PIPI_TYPES_H__ + +#ifndef PIPI_TYPES +# define PIPI_TYPES @PIPI_TYPES@ +#endif + +/* mode 1: standard header is present, just include it */ +#if PIPI_TYPES == 1 +# include +# include + +/* mode 2: standard header is present, just include it */ +#elif PIPI_TYPES == 2 +# include +# include + +/* mode 3: indicates Win32, only (u)intptr_t is present + * FIXME: Win64 probably doesn't work that way */ +#elif PIPI_TYPES == 3 +#include + +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed long int int32_t; +typedef signed long long int int64_t; + +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned long int uint32_t; +typedef unsigned long long int uint64_t; + +typedef int ssize_t; +typedef unsigned int size_t; + +/* fallback: nothing is known, we assume the platform is 32-bit and + * sizeof(long) == sizeof(void *). We don't typedef directly because we + * have no idea what other typedefs have already been made. */ +#else +typedef signed char _pipi_int8_t; +typedef signed short _pipi_int16_t; +typedef signed long int _pipi_int32_t; +typedef signed long long int _pipi_int64_t; +# undef int8_t +# define int8_t _pipi_int8_t +# undef int16_t +# define int16_t _pipi_int16_t +# undef int32_t +# define int32_t _pipi_int32_t +# undef int64_t +# define int64_t _pipi_int64_t + +typedef unsigned char _pipi_uint8_t; +typedef unsigned short _pipi_uint16_t; +typedef unsigned long int _pipi_uint32_t; +typedef unsigned long long int _pipi_uint64_t; +# undef uint8_t +# define uint8_t _pipi_uint8_t +# undef uint16_t +# define uint16_t _pipi_uint16_t +# undef uint32_t +# define uint32_t _pipi_uint32_t +# undef uint64_t +# define uint64_t _pipi_uint64_t + +typedef long int _pipi_intptr_t; +typedef unsigned long int _pipi_uintptr_t; +# undef intptr_t +# define intptr_t _pipi_intptr_t +# undef uintptr_t +# define uintptr_t _pipi_uintptr_t + +typedef int _pipi_ssize_t; +typedef unsigned int _pipi_size_t; +# undef ssize_t +# define ssize_t _pipi_ssize_t +# undef size_t +# define size_t _pipi_size_t + +#endif + +#endif /* __PIPI_TYPES_H__ */ + diff --git a/pipi/pixels.c b/pipi/pixels.c index fc09a19..56b1928 100644 --- a/pipi/pixels.c +++ b/pipi/pixels.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/quantize/reduce.c b/pipi/quantize/reduce.c index b783d3d..c512c1d 100644 --- a/pipi/quantize/reduce.c +++ b/pipi/quantize/reduce.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/render/noise.c b/pipi/render/noise.c index 4086d16..aaa03cd 100644 --- a/pipi/render/noise.c +++ b/pipi/render/noise.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/render/screen.c b/pipi/render/screen.c index f79d6b2..c670ae1 100644 --- a/pipi/render/screen.c +++ b/pipi/render/screen.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/resize.c b/pipi/resize.c index 434cbd4..f9bb409 100644 --- a/pipi/resize.c +++ b/pipi/resize.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/pipi/stock.c b/pipi/stock.c index 78f0e9c..9c6c8f6 100644 --- a/pipi/stock.c +++ b/pipi/stock.c @@ -17,7 +17,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/src/pipi.c b/src/pipi.c index b8ed6d9..426b42c 100644 --- a/src/pipi.c +++ b/src/pipi.c @@ -1,5 +1,4 @@ #include "config.h" -#include "common.h" #include #include diff --git a/test/u8tof32tou8.c b/test/u8tof32tou8.c index 7df70d5..e13a124 100644 --- a/test/u8tof32tou8.c +++ b/test/u8tof32tou8.c @@ -18,7 +18,6 @@ */ #include "config.h" -#include "common.h" #include #include diff --git a/win32/Makefile.am b/win32/Makefile.am index 4ea4d99..bd20792 100644 --- a/win32/Makefile.am +++ b/win32/Makefile.am @@ -1,4 +1,4 @@ # $Id$ -EXTRA_DIST = config.h +EXTRA_DIST = config.h pipi_types.h diff --git a/win32/pipi_types.h b/win32/pipi_types.h new file mode 100644 index 0000000..921b496 --- /dev/null +++ b/win32/pipi_types.h @@ -0,0 +1,2 @@ +#define PIPI_TYPES 3 +#include "../pipi/pipi_types.h.in"