use mode structs in _imaging.c

This commit is contained in:
Yay295 2024-04-20 21:07:57 -05:00
parent 1f2126bd9f
commit cb62dbbd24
2 changed files with 118 additions and 75 deletions

View File

@ -285,7 +285,7 @@ ImagingError_Clear(void) {
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
static int static int
getbands(const char *mode) { getbands(const Mode *mode) {
Imaging im; Imaging im;
int bands; int bands;
@ -580,7 +580,11 @@ getink(PyObject *color, Imaging im, char *ink) {
memcpy(ink, &ftmp, sizeof(ftmp)); memcpy(ink, &ftmp, sizeof(ftmp));
return ink; return ink;
case IMAGING_TYPE_SPECIAL: case IMAGING_TYPE_SPECIAL:
if (strncmp(im->mode, "I;16", 4) == 0) { if (im->mode == IMAGING_MODE_I_16
|| im->mode == IMAGING_MODE_I_16L
|| im->mode == IMAGING_MODE_I_16B
|| im->mode == IMAGING_MODE_I_16N
) {
ink[0] = (UINT8)r; ink[0] = (UINT8)r;
ink[1] = (UINT8)(r >> 8); ink[1] = (UINT8)(r >> 8);
ink[2] = ink[3] = 0; ink[2] = ink[3] = 0;
@ -599,7 +603,7 @@ getink(PyObject *color, Imaging im, char *ink) {
} else if (!PyArg_ParseTuple(color, "iiL", &b, &g, &r)) { } else if (!PyArg_ParseTuple(color, "iiL", &b, &g, &r)) {
return NULL; return NULL;
} }
if (!strcmp(im->mode, "BGR;15")) { if (im->mode == IMAGING_MODE_BGR_15) {
UINT16 v = ((((UINT16)r) << 7) & 0x7c00) + UINT16 v = ((((UINT16)r) << 7) & 0x7c00) +
((((UINT16)g) << 2) & 0x03e0) + ((((UINT16)g) << 2) & 0x03e0) +
((((UINT16)b) >> 3) & 0x001f); ((((UINT16)b) >> 3) & 0x001f);
@ -608,7 +612,7 @@ getink(PyObject *color, Imaging im, char *ink) {
ink[1] = (UINT8)(v >> 8); ink[1] = (UINT8)(v >> 8);
ink[2] = ink[3] = 0; ink[2] = ink[3] = 0;
return ink; return ink;
} else if (!strcmp(im->mode, "BGR;16")) { } else if (im->mode == IMAGING_MODE_BGR_16) {
UINT16 v = ((((UINT16)r) << 8) & 0xf800) + UINT16 v = ((((UINT16)r) << 8) & 0xf800) +
((((UINT16)g) << 3) & 0x07e0) + ((((UINT16)g) << 3) & 0x07e0) +
((((UINT16)b) >> 3) & 0x001f); ((((UINT16)b) >> 3) & 0x001f);
@ -616,7 +620,7 @@ getink(PyObject *color, Imaging im, char *ink) {
ink[1] = (UINT8)(v >> 8); ink[1] = (UINT8)(v >> 8);
ink[2] = ink[3] = 0; ink[2] = ink[3] = 0;
return ink; return ink;
} else if (!strcmp(im->mode, "BGR;24")) { } else if (im->mode == IMAGING_MODE_BGR_24) {
ink[0] = (UINT8)b; ink[0] = (UINT8)b;
ink[1] = (UINT8)g; ink[1] = (UINT8)g;
ink[2] = (UINT8)r; ink[2] = (UINT8)r;
@ -636,7 +640,7 @@ getink(PyObject *color, Imaging im, char *ink) {
static PyObject * static PyObject *
_fill(PyObject *self, PyObject *args) { _fill(PyObject *self, PyObject *args) {
char *mode; char *mode_name;
int xsize, ysize; int xsize, ysize;
PyObject *color; PyObject *color;
char buffer[4]; char buffer[4];
@ -645,10 +649,12 @@ _fill(PyObject *self, PyObject *args) {
xsize = ysize = 256; xsize = ysize = 256;
color = NULL; color = NULL;
if (!PyArg_ParseTuple(args, "s|(ii)O", &mode, &xsize, &ysize, &color)) { if (!PyArg_ParseTuple(args, "s|(ii)O", &mode_name, &xsize, &ysize, &color)) {
return NULL; return NULL;
} }
const Mode * const mode = findMode(mode_name);
im = ImagingNewDirty(mode, xsize, ysize); im = ImagingNewDirty(mode, xsize, ysize);
if (!im) { if (!im) {
return NULL; return NULL;
@ -669,47 +675,55 @@ _fill(PyObject *self, PyObject *args) {
static PyObject * static PyObject *
_new(PyObject *self, PyObject *args) { _new(PyObject *self, PyObject *args) {
char *mode; char *mode_name;
int xsize, ysize; int xsize, ysize;
if (!PyArg_ParseTuple(args, "s(ii)", &mode, &xsize, &ysize)) { if (!PyArg_ParseTuple(args, "s(ii)", &mode_name, &xsize, &ysize)) {
return NULL; return NULL;
} }
const Mode * const mode = findMode(mode_name);
return PyImagingNew(ImagingNew(mode, xsize, ysize)); return PyImagingNew(ImagingNew(mode, xsize, ysize));
} }
static PyObject * static PyObject *
_new_block(PyObject *self, PyObject *args) { _new_block(PyObject *self, PyObject *args) {
char *mode; char *mode_name;
int xsize, ysize; int xsize, ysize;
if (!PyArg_ParseTuple(args, "s(ii)", &mode, &xsize, &ysize)) { if (!PyArg_ParseTuple(args, "s(ii)", &mode_name, &xsize, &ysize)) {
return NULL; return NULL;
} }
const Mode * const mode = findMode(mode_name);
return PyImagingNew(ImagingNewBlock(mode, xsize, ysize)); return PyImagingNew(ImagingNewBlock(mode, xsize, ysize));
} }
static PyObject * static PyObject *
_linear_gradient(PyObject *self, PyObject *args) { _linear_gradient(PyObject *self, PyObject *args) {
char *mode; char *mode_name;
if (!PyArg_ParseTuple(args, "s", &mode)) { if (!PyArg_ParseTuple(args, "s", &mode_name)) {
return NULL; return NULL;
} }
const Mode * const mode = findMode(mode_name);
return PyImagingNew(ImagingFillLinearGradient(mode)); return PyImagingNew(ImagingFillLinearGradient(mode));
} }
static PyObject * static PyObject *
_radial_gradient(PyObject *self, PyObject *args) { _radial_gradient(PyObject *self, PyObject *args) {
char *mode; char *mode_name;
if (!PyArg_ParseTuple(args, "s", &mode)) { if (!PyArg_ParseTuple(args, "s", &mode_name)) {
return NULL; return NULL;
} }
const Mode * const mode = findMode(mode_name);
return PyImagingNew(ImagingFillRadialGradient(mode)); return PyImagingNew(ImagingFillRadialGradient(mode));
} }
@ -849,7 +863,7 @@ _prepare_lut_table(PyObject *table, Py_ssize_t table_size) {
static PyObject * static PyObject *
_color_lut_3d(ImagingObject *self, PyObject *args) { _color_lut_3d(ImagingObject *self, PyObject *args) {
char *mode; char *mode_name;
int filter; int filter;
int table_channels; int table_channels;
int size1D, size2D, size3D; int size1D, size2D, size3D;
@ -861,7 +875,7 @@ _color_lut_3d(ImagingObject *self, PyObject *args) {
if (!PyArg_ParseTuple( if (!PyArg_ParseTuple(
args, args,
"siiiiiO:color_lut_3d", "siiiiiO:color_lut_3d",
&mode, &mode_name,
&filter, &filter,
&table_channels, &table_channels,
&size1D, &size1D,
@ -872,6 +886,8 @@ _color_lut_3d(ImagingObject *self, PyObject *args) {
return NULL; return NULL;
} }
const Mode * const mode = findMode(mode_name);
/* actually, it is trilinear */ /* actually, it is trilinear */
if (filter != IMAGING_TRANSFORM_BILINEAR) { if (filter != IMAGING_TRANSFORM_BILINEAR) {
PyErr_SetString(PyExc_ValueError, "Only LINEAR filter is supported."); PyErr_SetString(PyExc_ValueError, "Only LINEAR filter is supported.");
@ -918,11 +934,11 @@ _color_lut_3d(ImagingObject *self, PyObject *args) {
static PyObject * static PyObject *
_convert(ImagingObject *self, PyObject *args) { _convert(ImagingObject *self, PyObject *args) {
char *mode; char *mode_name;
int dither = 0; int dither = 0;
ImagingObject *paletteimage = NULL; ImagingObject *paletteimage = NULL;
if (!PyArg_ParseTuple(args, "s|iO", &mode, &dither, &paletteimage)) { if (!PyArg_ParseTuple(args, "s|iO", &mode_name, &dither, &paletteimage)) {
return NULL; return NULL;
} }
if (paletteimage != NULL) { if (paletteimage != NULL) {
@ -939,6 +955,8 @@ _convert(ImagingObject *self, PyObject *args) {
} }
} }
const Mode * const mode = findMode(mode_name);
return PyImagingNew(ImagingConvert( return PyImagingNew(ImagingConvert(
self->image, mode, paletteimage ? paletteimage->image->palette : NULL, dither self->image, mode, paletteimage ? paletteimage->image->palette : NULL, dither
)); ));
@ -964,14 +982,14 @@ _convert2(ImagingObject *self, PyObject *args) {
static PyObject * static PyObject *
_convert_matrix(ImagingObject *self, PyObject *args) { _convert_matrix(ImagingObject *self, PyObject *args) {
char *mode; char *mode_name;
float m[12]; float m[12];
if (!PyArg_ParseTuple(args, "s(ffff)", &mode, m + 0, m + 1, m + 2, m + 3)) { if (!PyArg_ParseTuple(args, "s(ffff)", &mode_name, m + 0, m + 1, m + 2, m + 3)) {
PyErr_Clear(); PyErr_Clear();
if (!PyArg_ParseTuple( if (!PyArg_ParseTuple(
args, args,
"s(ffffffffffff)", "s(ffffffffffff)",
&mode, &mode_name,
m + 0, m + 0,
m + 1, m + 1,
m + 2, m + 2,
@ -989,18 +1007,22 @@ _convert_matrix(ImagingObject *self, PyObject *args) {
} }
} }
const Mode * const mode = findMode(mode_name);
return PyImagingNew(ImagingConvertMatrix(self->image, mode, m)); return PyImagingNew(ImagingConvertMatrix(self->image, mode, m));
} }
static PyObject * static PyObject *
_convert_transparent(ImagingObject *self, PyObject *args) { _convert_transparent(ImagingObject *self, PyObject *args) {
char *mode; char *mode_name;
int r, g, b; int r, g, b;
if (PyArg_ParseTuple(args, "s(iii)", &mode, &r, &g, &b)) { if (PyArg_ParseTuple(args, "s(iii)", &mode_name, &r, &g, &b)) {
const Mode * const mode = findMode(mode_name);
return PyImagingNew(ImagingConvertTransparent(self->image, mode, r, g, b)); return PyImagingNew(ImagingConvertTransparent(self->image, mode, r, g, b));
} }
PyErr_Clear(); PyErr_Clear();
if (PyArg_ParseTuple(args, "si", &mode, &r)) { if (PyArg_ParseTuple(args, "si", &mode_name, &r)) {
const Mode * const mode = findMode(mode_name);
return PyImagingNew(ImagingConvertTransparent(self->image, mode, r, 0, 0)); return PyImagingNew(ImagingConvertTransparent(self->image, mode, r, 0, 0));
} }
return NULL; return NULL;
@ -1103,9 +1125,9 @@ _getpalette(ImagingObject *self, PyObject *args) {
int bits; int bits;
ImagingShuffler pack; ImagingShuffler pack;
char *mode = "RGB"; char *mode_name = "RGB";
char *rawmode = "RGB"; char *rawmode_name = "RGB";
if (!PyArg_ParseTuple(args, "|ss", &mode, &rawmode)) { if (!PyArg_ParseTuple(args, "|ss", &mode_name, &rawmode_name)) {
return NULL; return NULL;
} }
@ -1114,6 +1136,9 @@ _getpalette(ImagingObject *self, PyObject *args) {
return NULL; return NULL;
} }
const Mode * const mode = findMode(mode_name);
const RawMode * const rawmode = findRawMode(rawmode_name);
pack = ImagingFindPacker(mode, rawmode, &bits); pack = ImagingFindPacker(mode, rawmode, &bits);
if (!pack) { if (!pack) {
PyErr_SetString(PyExc_ValueError, wrong_raw_mode); PyErr_SetString(PyExc_ValueError, wrong_raw_mode);
@ -1140,7 +1165,7 @@ _getpalettemode(ImagingObject *self) {
return NULL; return NULL;
} }
return PyUnicode_FromString(self->image->palette->mode); return PyUnicode_FromString(self->image->palette->mode->name);
} }
static inline int static inline int
@ -1423,12 +1448,14 @@ _point(ImagingObject *self, PyObject *args) {
Imaging im; Imaging im;
PyObject *list; PyObject *list;
char *mode; char *mode_name;
if (!PyArg_ParseTuple(args, "Oz", &list, &mode)) { if (!PyArg_ParseTuple(args, "Oz", &list, &mode_name)) {
return NULL; return NULL;
} }
if (mode && !strcmp(mode, "F")) { const Mode * const mode = findMode(mode_name);
if (mode == IMAGING_MODE_F) {
FLOAT32 *data; FLOAT32 *data;
/* map from 8-bit data to floating point */ /* map from 8-bit data to floating point */
@ -1439,8 +1466,7 @@ _point(ImagingObject *self, PyObject *args) {
} }
im = ImagingPoint(self->image, mode, (void *)data); im = ImagingPoint(self->image, mode, (void *)data);
free(data); free(data);
} else if (self->image->mode == IMAGING_MODE_I && mode == IMAGING_MODE_L) {
} else if (!strcmp(self->image->mode, "I") && mode && !strcmp(mode, "L")) {
UINT8 *data; UINT8 *data;
/* map from 16-bit subset of 32-bit data to 8-bit */ /* map from 16-bit subset of 32-bit data to 8-bit */
@ -1452,7 +1478,6 @@ _point(ImagingObject *self, PyObject *args) {
} }
im = ImagingPoint(self->image, mode, (void *)data); im = ImagingPoint(self->image, mode, (void *)data);
free(data); free(data);
} else { } else {
INT32 *data; INT32 *data;
UINT8 lut[1024]; UINT8 lut[1024];
@ -1473,7 +1498,7 @@ _point(ImagingObject *self, PyObject *args) {
return NULL; return NULL;
} }
if (mode && !strcmp(mode, "I")) { if (mode == IMAGING_MODE_I) {
im = ImagingPoint(self->image, mode, (void *)data); im = ImagingPoint(self->image, mode, (void *)data);
} else if (mode && bands > 1) { } else if (mode && bands > 1) {
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
@ -1579,9 +1604,9 @@ _putdata(ImagingObject *self, PyObject *args) {
int bigendian = 0; int bigendian = 0;
if (image->type == IMAGING_TYPE_SPECIAL) { if (image->type == IMAGING_TYPE_SPECIAL) {
// I;16* // I;16*
if (strcmp(image->mode, "I;16B") == 0 if (image->mode == IMAGING_MODE_I_16B
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
|| strcmp(image->mode, "I;16N") == 0 || image->mode == IMAGING_MODE_I_16N
#endif #endif
) { ) {
bigendian = 1; bigendian = 1;
@ -1699,7 +1724,7 @@ _quantize(ImagingObject *self, PyObject *args) {
if (!self->image->xsize || !self->image->ysize) { if (!self->image->xsize || !self->image->ysize) {
/* no content; return an empty image */ /* no content; return an empty image */
return PyImagingNew(ImagingNew("P", self->image->xsize, self->image->ysize)); return PyImagingNew(ImagingNew(IMAGING_MODE_P, self->image->xsize, self->image->ysize));
} }
return PyImagingNew(ImagingQuantize(self->image, colours, method, kmeans)); return PyImagingNew(ImagingQuantize(self->image, colours, method, kmeans));
@ -1710,21 +1735,33 @@ _putpalette(ImagingObject *self, PyObject *args) {
ImagingShuffler unpack; ImagingShuffler unpack;
int bits; int bits;
char *palette_mode, *rawmode; char *palette_mode_name, *rawmode_name;
UINT8 *palette; UINT8 *palette;
Py_ssize_t palettesize; Py_ssize_t palettesize;
if (!PyArg_ParseTuple( if (!PyArg_ParseTuple(
args, "ssy#", &palette_mode, &rawmode, &palette, &palettesize args, "ssy#", &palette_mode_name, &rawmode_name, &palette, &palettesize
)) { )) {
return NULL; return NULL;
} }
if (strcmp(self->image->mode, "L") && strcmp(self->image->mode, "LA") && if (self->image->mode != IMAGING_MODE_L && self->image->mode != IMAGING_MODE_LA &&
strcmp(self->image->mode, "P") && strcmp(self->image->mode, "PA")) { self->image->mode != IMAGING_MODE_P && self->image->mode != IMAGING_MODE_PA) {
PyErr_SetString(PyExc_ValueError, wrong_mode); PyErr_SetString(PyExc_ValueError, wrong_mode);
return NULL; return NULL;
} }
const Mode * const palette_mode = findMode(palette_mode_name);
if (palette_mode == NULL) {
PyErr_SetString(PyExc_ValueError, wrong_mode);
return NULL;
}
const RawMode * const rawmode = findRawMode(rawmode_name);
if (rawmode == NULL) {
PyErr_SetString(PyExc_ValueError, wrong_raw_mode);
return NULL;
}
unpack = ImagingFindUnpacker(palette_mode, rawmode, &bits); unpack = ImagingFindUnpacker(palette_mode, rawmode, &bits);
if (!unpack) { if (!unpack) {
PyErr_SetString(PyExc_ValueError, wrong_raw_mode); PyErr_SetString(PyExc_ValueError, wrong_raw_mode);
@ -1738,7 +1775,7 @@ _putpalette(ImagingObject *self, PyObject *args) {
ImagingPaletteDelete(self->image->palette); ImagingPaletteDelete(self->image->palette);
strcpy(self->image->mode, strlen(self->image->mode) == 2 ? "PA" : "P"); self->image->mode = strlen(self->image->mode->name) == 2 ? IMAGING_MODE_PA : IMAGING_MODE_P;
self->image->palette = ImagingPaletteNew(palette_mode); self->image->palette = ImagingPaletteNew(palette_mode);
@ -1767,7 +1804,7 @@ _putpalettealpha(ImagingObject *self, PyObject *args) {
return NULL; return NULL;
} }
strcpy(self->image->palette->mode, "RGBA"); self->image->palette->mode = IMAGING_MODE_RGBA;
self->image->palette->palette[index * 4 + 3] = (UINT8)alpha; self->image->palette->palette[index * 4 + 3] = (UINT8)alpha;
Py_INCREF(Py_None); Py_INCREF(Py_None);
@ -1793,7 +1830,7 @@ _putpalettealphas(ImagingObject *self, PyObject *args) {
return NULL; return NULL;
} }
strcpy(self->image->palette->mode, "RGBA"); self->image->palette->mode = IMAGING_MODE_RGBA;
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
self->image->palette->palette[i * 4 + 3] = (UINT8)values[i]; self->image->palette->palette[i * 4 + 3] = (UINT8)values[i];
} }
@ -1963,8 +2000,10 @@ _reduce(ImagingObject *self, PyObject *args) {
return PyImagingNew(imOut); return PyImagingNew(imOut);
} }
#define IS_RGB(mode) \ static int
(!strcmp(mode, "RGB") || !strcmp(mode, "RGBA") || !strcmp(mode, "RGBX")) isRGB(const Mode * const mode) {
return mode == IMAGING_MODE_RGB || mode == IMAGING_MODE_RGBA || mode == IMAGING_MODE_RGBX;
}
static PyObject * static PyObject *
im_setmode(ImagingObject *self, PyObject *args) { im_setmode(ImagingObject *self, PyObject *args) {
@ -1972,23 +2011,25 @@ im_setmode(ImagingObject *self, PyObject *args) {
Imaging im; Imaging im;
char *mode; char *mode_name;
Py_ssize_t modelen; Py_ssize_t modelen;
if (!PyArg_ParseTuple(args, "s#:setmode", &mode, &modelen)) { if (!PyArg_ParseTuple(args, "s#:setmode", &mode_name, &modelen)) {
return NULL; return NULL;
} }
const Mode * const mode = findMode(mode_name);
im = self->image; im = self->image;
/* move all logic in here to the libImaging primitive */ /* move all logic in here to the libImaging primitive */
if (!strcmp(im->mode, mode)) { if (im->mode == mode) {
; /* same mode; always succeeds */ ; /* same mode; always succeeds */
} else if (IS_RGB(im->mode) && IS_RGB(mode)) { } else if (isRGB(im->mode) && isRGB(mode)) {
/* color to color */ /* color to color */
strcpy(im->mode, mode); im->mode = mode;
im->bands = modelen; im->bands = modelen;
if (!strcmp(mode, "RGBA")) { if (mode == IMAGING_MODE_RGBA) {
(void)ImagingFillBand(im, 3, 255); (void)ImagingFillBand(im, 3, 255);
} }
} else { } else {
@ -2270,7 +2311,7 @@ _getextrema(ImagingObject *self) {
case IMAGING_TYPE_FLOAT32: case IMAGING_TYPE_FLOAT32:
return Py_BuildValue("dd", extrema.f[0], extrema.f[1]); return Py_BuildValue("dd", extrema.f[0], extrema.f[1]);
case IMAGING_TYPE_SPECIAL: case IMAGING_TYPE_SPECIAL:
if (strcmp(self->image->mode, "I;16") == 0) { if (self->image->mode == IMAGING_MODE_I_16) {
return Py_BuildValue("HH", extrema.s[0], extrema.s[1]); return Py_BuildValue("HH", extrema.s[0], extrema.s[1]);
} }
} }
@ -2362,7 +2403,7 @@ _putband(ImagingObject *self, PyObject *args) {
static PyObject * static PyObject *
_merge(PyObject *self, PyObject *args) { _merge(PyObject *self, PyObject *args) {
char *mode; char *mode_name;
ImagingObject *band0 = NULL; ImagingObject *band0 = NULL;
ImagingObject *band1 = NULL; ImagingObject *band1 = NULL;
ImagingObject *band2 = NULL; ImagingObject *band2 = NULL;
@ -2372,7 +2413,7 @@ _merge(PyObject *self, PyObject *args) {
if (!PyArg_ParseTuple( if (!PyArg_ParseTuple(
args, args,
"sO!|O!O!O!", "sO!|O!O!O!",
&mode, &mode_name,
&Imaging_Type, &Imaging_Type,
&band0, &band0,
&Imaging_Type, &Imaging_Type,
@ -2385,6 +2426,8 @@ _merge(PyObject *self, PyObject *args) {
return NULL; return NULL;
} }
const Mode * const mode = findMode(mode_name);
if (band0) { if (band0) {
bands[0] = band0->image; bands[0] = band0->image;
} }
@ -3685,7 +3728,7 @@ static struct PyMethodDef methods[] = {
static PyObject * static PyObject *
_getattr_mode(ImagingObject *self, void *closure) { _getattr_mode(ImagingObject *self, void *closure) {
return PyUnicode_FromString(self->image->mode); return PyUnicode_FromString(self->image->mode->name);
} }
static PyObject * static PyObject *

View File

@ -173,21 +173,21 @@ extern void
ImagingMemoryClearCache(ImagingMemoryArena arena, int new_size); ImagingMemoryClearCache(ImagingMemoryArena arena, int new_size);
extern Imaging extern Imaging
ImagingNew(const char *mode, int xsize, int ysize); ImagingNew(const Mode *mode, int xsize, int ysize);
extern Imaging extern Imaging
ImagingNewDirty(const char *mode, int xsize, int ysize); ImagingNewDirty(const Mode *mode, int xsize, int ysize);
extern Imaging extern Imaging
ImagingNew2Dirty(const char *mode, Imaging imOut, Imaging imIn); ImagingNew2Dirty(const Mode *mode, Imaging imOut, Imaging imIn);
extern void extern void
ImagingDelete(Imaging im); ImagingDelete(Imaging im);
extern Imaging extern Imaging
ImagingNewBlock(const char *mode, int xsize, int ysize); ImagingNewBlock(const Mode *mode, int xsize, int ysize);
extern Imaging extern Imaging
ImagingNewPrologue(const char *mode, int xsize, int ysize); ImagingNewPrologue(const Mode *mode, int xsize, int ysize);
extern Imaging extern Imaging
ImagingNewPrologueSubtype(const char *mode, int xsize, int ysize, int structure_size); ImagingNewPrologueSubtype(const Mode *mode, int xsize, int ysize, int structure_size);
extern void extern void
ImagingCopyPalette(Imaging destination, Imaging source); ImagingCopyPalette(Imaging destination, Imaging source);
@ -204,7 +204,7 @@ _ImagingAccessDelete(Imaging im, ImagingAccess access);
#define ImagingAccessDelete(im, access) /* nop, for now */ #define ImagingAccessDelete(im, access) /* nop, for now */
extern ImagingPalette extern ImagingPalette
ImagingPaletteNew(const char *mode); ImagingPaletteNew(const Mode *mode);
extern ImagingPalette extern ImagingPalette
ImagingPaletteNewBrowser(void); ImagingPaletteNewBrowser(void);
extern ImagingPalette extern ImagingPalette
@ -280,13 +280,13 @@ ImagingBlend(Imaging imIn1, Imaging imIn2, float alpha);
extern Imaging extern Imaging
ImagingCopy(Imaging im); ImagingCopy(Imaging im);
extern Imaging extern Imaging
ImagingConvert(Imaging im, const char *mode, ImagingPalette palette, int dither); ImagingConvert(Imaging im, const Mode *mode, ImagingPalette palette, int dither);
extern Imaging extern Imaging
ImagingConvertInPlace(Imaging im, const char *mode); ImagingConvertInPlace(Imaging im, const Mode *mode);
extern Imaging extern Imaging
ImagingConvertMatrix(Imaging im, const char *mode, float m[]); ImagingConvertMatrix(Imaging im, const Mode *mode, float m[]);
extern Imaging extern Imaging
ImagingConvertTransparent(Imaging im, const char *mode, int r, int g, int b); ImagingConvertTransparent(Imaging im, const Mode *mode, int r, int g, int b);
extern Imaging extern Imaging
ImagingCrop(Imaging im, int x0, int y0, int x1, int y1); ImagingCrop(Imaging im, int x0, int y0, int x1, int y1);
extern Imaging extern Imaging
@ -300,9 +300,9 @@ ImagingFill2(
extern Imaging extern Imaging
ImagingFillBand(Imaging im, int band, int color); ImagingFillBand(Imaging im, int band, int color);
extern Imaging extern Imaging
ImagingFillLinearGradient(const char *mode); ImagingFillLinearGradient(const Mode *mode);
extern Imaging extern Imaging
ImagingFillRadialGradient(const char *mode); ImagingFillRadialGradient(const Mode *mode);
extern Imaging extern Imaging
ImagingFilter(Imaging im, int xsize, int ysize, const FLOAT32 *kernel, FLOAT32 offset); ImagingFilter(Imaging im, int xsize, int ysize, const FLOAT32 *kernel, FLOAT32 offset);
extern Imaging extern Imaging
@ -316,7 +316,7 @@ ImagingGaussianBlur(
extern Imaging extern Imaging
ImagingGetBand(Imaging im, int band); ImagingGetBand(Imaging im, int band);
extern Imaging extern Imaging
ImagingMerge(const char *mode, Imaging bands[4]); ImagingMerge(const Mode *mode, Imaging bands[4]);
extern int extern int
ImagingSplit(Imaging im, Imaging bands[4]); ImagingSplit(Imaging im, Imaging bands[4]);
extern int extern int
@ -343,7 +343,7 @@ ImagingOffset(Imaging im, int xoffset, int yoffset);
extern int extern int
ImagingPaste(Imaging into, Imaging im, Imaging mask, int x0, int y0, int x1, int y1); ImagingPaste(Imaging into, Imaging im, Imaging mask, int x0, int y0, int x1, int y1);
extern Imaging extern Imaging
ImagingPoint(Imaging im, const char *tablemode, const void *table); ImagingPoint(Imaging im, const Mode *tablemode, const void *table);
extern Imaging extern Imaging
ImagingPointTransform(Imaging imIn, double scale, double offset); ImagingPointTransform(Imaging imIn, double scale, double offset);
extern Imaging extern Imaging
@ -671,9 +671,9 @@ extern void
ImagingConvertYCbCr2RGB(UINT8 *out, const UINT8 *in, int pixels); ImagingConvertYCbCr2RGB(UINT8 *out, const UINT8 *in, int pixels);
extern ImagingShuffler extern ImagingShuffler
ImagingFindUnpacker(const char *mode, const char *rawmode, int *bits_out); ImagingFindUnpacker(const Mode *mode, const RawMode *rawmode, int *bits_out);
extern ImagingShuffler extern ImagingShuffler
ImagingFindPacker(const char *mode, const char *rawmode, int *bits_out); ImagingFindPacker(const Mode *mode, const RawMode *rawmode, int *bits_out);
struct ImagingCodecStateInstance { struct ImagingCodecStateInstance {
int count; int count;