gd_intern: unify the min/max/clamp macros some more
parent
f538eedc7c
commit
e1f02d2833
6
src/gd.c
6
src/gd.c
|
@ -499,12 +499,6 @@ BGD_DECLARE(int) gdImageColorClosestAlpha (gdImagePtr im, int r, int g, int b, i
|
||||||
#define HWB_UNDEFINED -1
|
#define HWB_UNDEFINED -1
|
||||||
#define SETUP_RGB(s, r, g, b) {s.R = r/255.0; s.G = g/255.0; s.B = b/255.0;}
|
#define SETUP_RGB(s, r, g, b) {s.R = r/255.0; s.G = g/255.0; s.B = b/255.0;}
|
||||||
|
|
||||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
|
||||||
#define MIN3(a,b,c) ((a)<(b)?(MIN(a,c)):(MIN(b,c)))
|
|
||||||
#define MAX(a,b) ((a)<(b)?(b):(a))
|
|
||||||
#define MAX3(a,b,c) ((a)<(b)?(MAX(b,c)):(MAX(a,c)))
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms. Pure
|
* Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms. Pure
|
||||||
* red always maps to 6 in this implementation. Therefore UNDEFINED can be
|
* red always maps to 6 in this implementation. Therefore UNDEFINED can be
|
||||||
|
|
|
@ -30,8 +30,6 @@
|
||||||
typedef int (BGD_STDCALL *FuncPtr)(gdImagePtr, int, int);
|
typedef int (BGD_STDCALL *FuncPtr)(gdImagePtr, int, int);
|
||||||
|
|
||||||
#define GET_PIXEL_FUNCTION(src)(src->trueColor?gdImageGetTrueColorPixel:gdImageGetPixel)
|
#define GET_PIXEL_FUNCTION(src)(src->trueColor?gdImageGetTrueColorPixel:gdImageGetPixel)
|
||||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
|
||||||
#define MAX(a,b) ((a)<(b)?(b):(a))
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# define GD_SCATTER_SEED() (unsigned int)(time(0) * GetCurrentProcessId())
|
# define GD_SCATTER_SEED() (unsigned int)(time(0) * GetCurrentProcessId())
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/* Internal header for random common utility functions. */
|
||||||
|
|
||||||
#ifndef GD_INTERN_H
|
#ifndef GD_INTERN_H
|
||||||
#define GD_INTERN_H
|
#define GD_INTERN_H
|
||||||
|
|
||||||
|
@ -29,15 +31,11 @@
|
||||||
|
|
||||||
#include "gd.h"
|
#include "gd.h"
|
||||||
|
|
||||||
#ifndef MIN
|
|
||||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||||
#endif
|
|
||||||
#define MIN3(a,b,c) ((a)<(b)?(MIN(a,c)):(MIN(b,c)))
|
#define MIN3(a,b,c) ((a)<(b)?(MIN(a,c)):(MIN(b,c)))
|
||||||
#ifndef MAX
|
|
||||||
#define MAX(a,b) ((a)<(b)?(b):(a))
|
#define MAX(a,b) ((a)<(b)?(b):(a))
|
||||||
#endif
|
|
||||||
#define MAX3(a,b,c) ((a)<(b)?(MAX(b,c)):(MAX(a,c)))
|
#define MAX3(a,b,c) ((a)<(b)?(MAX(b,c)):(MAX(a,c)))
|
||||||
|
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
HORIZONTAL,
|
HORIZONTAL,
|
||||||
|
|
|
@ -93,9 +93,6 @@ static gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src,
|
||||||
static gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees,
|
static gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees,
|
||||||
const int bgColor);
|
const int bgColor);
|
||||||
|
|
||||||
|
|
||||||
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
|
|
||||||
|
|
||||||
/* only used here, let do a generic fixed point integers later if required by other
|
/* only used here, let do a generic fixed point integers later if required by other
|
||||||
part of GD */
|
part of GD */
|
||||||
typedef long gdFixed;
|
typedef long gdFixed;
|
||||||
|
|
|
@ -71,10 +71,6 @@
|
||||||
#define GD_INDEXED 4
|
#define GD_INDEXED 4
|
||||||
#define GD_RGB 5
|
#define GD_RGB 5
|
||||||
|
|
||||||
#define MIN(a,b) (a < b) ? a : b;
|
|
||||||
#define MAX(a,b) (a > b) ? a : b;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct tiff_handle {
|
typedef struct tiff_handle {
|
||||||
int size;
|
int size;
|
||||||
int pos;
|
int pos;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "gd.h"
|
#include "gd.h"
|
||||||
#include "gd_errors.h"
|
#include "gd_errors.h"
|
||||||
|
#include "gd_intern.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
/* In tests this is sufficient to prevent obvious artifacts */
|
/* In tests this is sufficient to prevent obvious artifacts */
|
||||||
|
@ -12,9 +13,6 @@
|
||||||
#define PI 3.141592
|
#define PI 3.141592
|
||||||
#define DEG2RAD(x) ((x)*PI/180.)
|
#define DEG2RAD(x) ((x)*PI/180.)
|
||||||
|
|
||||||
#define MAX(x,y) ((x) > (y) ? (x) : (y))
|
|
||||||
#define MIN(x,y) ((x) < (y) ? (x) : (y))
|
|
||||||
|
|
||||||
#define MAX4(x,y,z,w) \
|
#define MAX4(x,y,z,w) \
|
||||||
((MAX((x),(y))) > (MAX((z),(w))) ? (MAX((x),(y))) : (MAX((z),(w))))
|
((MAX((x),(y))) > (MAX((z),(w))) ? (MAX((x),(y))) : (MAX((z),(w))))
|
||||||
#define MIN4(x,y,z,w) \
|
#define MIN4(x,y,z,w) \
|
||||||
|
|
|
@ -3,15 +3,13 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gd.h"
|
#include "gd.h"
|
||||||
|
#include "gd_intern.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define PI 3.141592
|
#define PI 3.141592
|
||||||
#define DEG2RAD(x) ((x)*PI/180.)
|
#define DEG2RAD(x) ((x)*PI/180.)
|
||||||
|
|
||||||
#define MAX(x,y) ((x) > (y) ? (x) : (y))
|
|
||||||
#define MIN(x,y) ((x) < (y) ? (x) : (y))
|
|
||||||
|
|
||||||
#define MAX4(x,y,z,w) \
|
#define MAX4(x,y,z,w) \
|
||||||
((MAX((x),(y))) > (MAX((z),(w))) ? (MAX((x),(y))) : (MAX((z),(w))))
|
((MAX((x),(y))) > (MAX((z),(w))) ? (MAX((x),(y))) : (MAX((z),(w))))
|
||||||
#define MIN4(x,y,z,w) \
|
#define MIN4(x,y,z,w) \
|
||||||
|
|
Loading…
Reference in New Issue