mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 17:54:32 +03:00
noop core.merge
This commit is contained in:
parent
5f5ac09158
commit
91b08b7daa
|
@ -2612,11 +2612,9 @@ def merge(mode, bands):
|
||||||
raise ValueError("mode mismatch")
|
raise ValueError("mode mismatch")
|
||||||
if im.size != bands[0].size:
|
if im.size != bands[0].size:
|
||||||
raise ValueError("size mismatch")
|
raise ValueError("size mismatch")
|
||||||
im = core.new(mode, bands[0].size)
|
for band in bands:
|
||||||
for i in range(getmodebands(mode)):
|
band.load()
|
||||||
bands[i].load()
|
return bands[0]._new(core.merge(mode, *[b.im for b in bands]))
|
||||||
im.putband(bands[i].im, i)
|
|
||||||
return bands[0]._new(im)
|
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
24
_imaging.c
24
_imaging.c
|
@ -1905,6 +1905,29 @@ _putband(ImagingObject* self, PyObject* args)
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
_merge(PyObject* self, PyObject* args)
|
||||||
|
{
|
||||||
|
char* mode;
|
||||||
|
ImagingObject *band0 = NULL;
|
||||||
|
ImagingObject *band1 = NULL;
|
||||||
|
ImagingObject *band2 = NULL;
|
||||||
|
ImagingObject *band3 = NULL;
|
||||||
|
Imaging bands[4] = {NULL, NULL, NULL, NULL};
|
||||||
|
|
||||||
|
if (!PyArg_ParseTuple(args, "sO!|O!O!O!", &mode,
|
||||||
|
&Imaging_Type, &band0, &Imaging_Type, &band1,
|
||||||
|
&Imaging_Type, &band2, &Imaging_Type, &band3))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (band0) bands[0] = band0->image;
|
||||||
|
if (band1) bands[1] = band1->image;
|
||||||
|
if (band2) bands[2] = band2->image;
|
||||||
|
if (band3) bands[3] = band3->image;
|
||||||
|
|
||||||
|
return PyImagingNew(ImagingMerge(mode, bands));
|
||||||
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef WITH_IMAGECHOPS
|
#ifdef WITH_IMAGECHOPS
|
||||||
|
@ -3316,6 +3339,7 @@ static PyMethodDef functions[] = {
|
||||||
{"blend", (PyCFunction)_blend, 1},
|
{"blend", (PyCFunction)_blend, 1},
|
||||||
{"fill", (PyCFunction)_fill, 1},
|
{"fill", (PyCFunction)_fill, 1},
|
||||||
{"new", (PyCFunction)_new, 1},
|
{"new", (PyCFunction)_new, 1},
|
||||||
|
{"merge", (PyCFunction)_merge, 1},
|
||||||
|
|
||||||
{"getcount", (PyCFunction)_getcount, 1},
|
{"getcount", (PyCFunction)_getcount, 1},
|
||||||
|
|
||||||
|
|
|
@ -127,3 +127,42 @@ ImagingFillBand(Imaging imOut, int band, int color)
|
||||||
|
|
||||||
return imOut;
|
return imOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Imaging
|
||||||
|
ImagingMerge(const char* mode, Imaging bands[4])
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int bandsCount = 0;
|
||||||
|
Imaging imOut;
|
||||||
|
Imaging firstBand;
|
||||||
|
|
||||||
|
firstBand = bands[0];
|
||||||
|
if ( ! firstBand) {
|
||||||
|
return (Imaging) ImagingError_ValueError("At least one band required");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < 4; ++i) {
|
||||||
|
if ( ! bands[i]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (bands[i]->bands != 1 || bands[i]->type != IMAGING_TYPE_UINT8) {
|
||||||
|
return (Imaging) ImagingError_ModeError();
|
||||||
|
}
|
||||||
|
if (bands[i]->xsize != firstBand->xsize
|
||||||
|
|| bands[i]->ysize != firstBand->ysize) {
|
||||||
|
return (Imaging) ImagingError_Mismatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bandsCount = i;
|
||||||
|
|
||||||
|
imOut = ImagingNew(mode, firstBand->xsize, firstBand->ysize);
|
||||||
|
if ( ! imOut)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (imOut->bands != bandsCount) {
|
||||||
|
ImagingDelete(imOut);
|
||||||
|
return (Imaging) ImagingError_ValueError("wrong number of bands");
|
||||||
|
}
|
||||||
|
|
||||||
|
return imOut;
|
||||||
|
}
|
||||||
|
|
|
@ -267,6 +267,7 @@ extern Imaging ImagingFlipTopBottom(Imaging imOut, Imaging imIn);
|
||||||
extern Imaging ImagingGaussianBlur(Imaging imOut, Imaging imIn, float radius,
|
extern Imaging ImagingGaussianBlur(Imaging imOut, Imaging imIn, float radius,
|
||||||
int passes);
|
int passes);
|
||||||
extern Imaging ImagingGetBand(Imaging im, int band);
|
extern Imaging ImagingGetBand(Imaging im, int band);
|
||||||
|
extern Imaging ImagingMerge(const char* mode, Imaging bands[4]);
|
||||||
extern int ImagingGetBBox(Imaging im, int bbox[4]);
|
extern int ImagingGetBBox(Imaging im, int bbox[4]);
|
||||||
typedef struct { int x, y; INT32 count; INT32 pixel; } ImagingColorItem;
|
typedef struct { int x, y; INT32 count; INT32 pixel; } ImagingColorItem;
|
||||||
extern ImagingColorItem* ImagingGetColors(Imaging im, int maxcolors,
|
extern ImagingColorItem* ImagingGetColors(Imaging im, int maxcolors,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user