mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +03:00
Merge pull request #2686 from uploadcare/new-dirty
Use ImagingNewDirty when possible
This commit is contained in:
commit
1f61c4efd4
|
@ -84,7 +84,7 @@ ImagingSplit(Imaging imIn, Imaging bands[4])
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < imIn->bands; i++) {
|
for (i = 0; i < imIn->bands; i++) {
|
||||||
bands[i] = ImagingNew("L", imIn->xsize, imIn->ysize);
|
bands[i] = ImagingNewDirty("L", imIn->xsize, imIn->ysize);
|
||||||
if ( ! bands[i]) {
|
if ( ! bands[i]) {
|
||||||
for (j = 0; j < i; ++j) {
|
for (j = 0; j < i; ++j) {
|
||||||
ImagingDelete(bands[j]);
|
ImagingDelete(bands[j]);
|
||||||
|
|
|
@ -72,7 +72,7 @@ create(Imaging im1, Imaging im2, char* mode)
|
||||||
xsize = (im1->xsize < im2->xsize) ? im1->xsize : im2->xsize;
|
xsize = (im1->xsize < im2->xsize) ? im1->xsize : im2->xsize;
|
||||||
ysize = (im1->ysize < im2->ysize) ? im1->ysize : im2->ysize;
|
ysize = (im1->ysize < im2->ysize) ? im1->ysize : im2->ysize;
|
||||||
|
|
||||||
return ImagingNew(im1->mode, xsize, ysize);
|
return ImagingNewDirty(im1->mode, xsize, ysize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Imaging
|
Imaging
|
||||||
|
|
|
@ -37,7 +37,7 @@ ImagingEffectMandelbrot(int xsize, int ysize, double extent[4], int quality)
|
||||||
if (width < 0.0 || height < 0.0 || quality < 2)
|
if (width < 0.0 || height < 0.0 || quality < 2)
|
||||||
return (Imaging) ImagingError_ValueError(NULL);
|
return (Imaging) ImagingError_ValueError(NULL);
|
||||||
|
|
||||||
im = ImagingNew("L", xsize, ysize);
|
im = ImagingNewDirty("L", xsize, ysize);
|
||||||
if (!im)
|
if (!im)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ ImagingEffectNoise(int xsize, int ysize, float sigma)
|
||||||
int nextok;
|
int nextok;
|
||||||
double this, next;
|
double this, next;
|
||||||
|
|
||||||
imOut = ImagingNew("L", xsize, ysize);
|
imOut = ImagingNewDirty("L", xsize, ysize);
|
||||||
if (!imOut)
|
if (!imOut)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -121,14 +121,14 @@ ImagingEffectSpread(Imaging imIn, int distance)
|
||||||
Imaging imOut;
|
Imaging imOut;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
imOut = ImagingNew(imIn->mode, imIn->xsize, imIn->ysize);
|
imOut = ImagingNewDirty(imIn->mode, imIn->xsize, imIn->ysize);
|
||||||
|
|
||||||
if (!imOut)
|
if (!imOut)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#define SPREAD(type, image)\
|
#define SPREAD(type, image)\
|
||||||
for (y = 0; y < imIn->ysize; y++)\
|
for (y = 0; y < imOut->ysize; y++)\
|
||||||
for (x = 0; x < imIn->xsize; x++) {\
|
for (x = 0; x < imOut->xsize; x++) {\
|
||||||
int xx = x + (rand() % distance) - distance/2;\
|
int xx = x + (rand() % distance) - distance/2;\
|
||||||
int yy = y + (rand() % distance) - distance/2;\
|
int yy = y + (rand() % distance) - distance/2;\
|
||||||
if (xx >= 0 && xx < imIn->xsize && yy >= 0 && yy < imIn->ysize) {\
|
if (xx >= 0 && xx < imIn->xsize && yy >= 0 && yy < imIn->ysize) {\
|
||||||
|
|
|
@ -28,7 +28,7 @@ ImagingModeFilter(Imaging im, int size)
|
||||||
if (!im || im->bands != 1 || im->type != IMAGING_TYPE_UINT8)
|
if (!im || im->bands != 1 || im->type != IMAGING_TYPE_UINT8)
|
||||||
return (Imaging) ImagingError_ModeError();
|
return (Imaging) ImagingError_ModeError();
|
||||||
|
|
||||||
imOut = ImagingNew(im->mode, im->xsize, im->ysize);
|
imOut = ImagingNewDirty(im->mode, im->xsize, im->ysize);
|
||||||
if (!imOut)
|
if (!imOut)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -1642,11 +1642,11 @@ ImagingQuantize(Imaging im, int colors, int mode, int kmeans)
|
||||||
ImagingSectionLeave(&cookie);
|
ImagingSectionLeave(&cookie);
|
||||||
|
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
imOut = ImagingNew("P", im->xsize, im->ysize);
|
imOut = ImagingNewDirty("P", im->xsize, im->ysize);
|
||||||
ImagingSectionEnter(&cookie);
|
ImagingSectionEnter(&cookie);
|
||||||
|
|
||||||
for (i = y = 0; y < im->ysize; y++)
|
for (i = y = 0; y < im->ysize; y++)
|
||||||
for (x=0; x < im->xsize; x++)
|
for (x = 0; x < im->xsize; x++)
|
||||||
imOut->image8[y][x] = (unsigned char) newData[i++];
|
imOut->image8[y][x] = (unsigned char) newData[i++];
|
||||||
|
|
||||||
free(newData);
|
free(newData);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user