mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +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++) {
|
||||
bands[i] = ImagingNew("L", imIn->xsize, imIn->ysize);
|
||||
bands[i] = ImagingNewDirty("L", imIn->xsize, imIn->ysize);
|
||||
if ( ! bands[i]) {
|
||||
for (j = 0; j < i; ++j) {
|
||||
ImagingDelete(bands[j]);
|
||||
|
|
|
@ -19,41 +19,41 @@
|
|||
|
||||
#include "Imaging.h"
|
||||
|
||||
#define CHOP(operation, mode)\
|
||||
#define CHOP(operation, mode)\
|
||||
int x, y;\
|
||||
Imaging imOut;\
|
||||
imOut = create(imIn1, imIn2, mode);\
|
||||
if (!imOut)\
|
||||
return NULL;\
|
||||
return NULL;\
|
||||
for (y = 0; y < imOut->ysize; y++) {\
|
||||
UINT8* out = (UINT8*) imOut->image[y];\
|
||||
UINT8* in1 = (UINT8*) imIn1->image[y];\
|
||||
UINT8* in2 = (UINT8*) imIn2->image[y];\
|
||||
for (x = 0; x < imOut->linesize; x++) {\
|
||||
int temp = operation;\
|
||||
if (temp <= 0)\
|
||||
out[x] = 0;\
|
||||
else if (temp >= 255)\
|
||||
out[x] = 255;\
|
||||
else\
|
||||
out[x] = temp;\
|
||||
}\
|
||||
UINT8* out = (UINT8*) imOut->image[y];\
|
||||
UINT8* in1 = (UINT8*) imIn1->image[y];\
|
||||
UINT8* in2 = (UINT8*) imIn2->image[y];\
|
||||
for (x = 0; x < imOut->linesize; x++) {\
|
||||
int temp = operation;\
|
||||
if (temp <= 0)\
|
||||
out[x] = 0;\
|
||||
else if (temp >= 255)\
|
||||
out[x] = 255;\
|
||||
else\
|
||||
out[x] = temp;\
|
||||
}\
|
||||
}\
|
||||
return imOut;
|
||||
|
||||
#define CHOP2(operation, mode)\
|
||||
#define CHOP2(operation, mode)\
|
||||
int x, y;\
|
||||
Imaging imOut;\
|
||||
imOut = create(imIn1, imIn2, mode);\
|
||||
if (!imOut)\
|
||||
return NULL;\
|
||||
return NULL;\
|
||||
for (y = 0; y < imOut->ysize; y++) {\
|
||||
UINT8* out = (UINT8*) imOut->image[y];\
|
||||
UINT8* in1 = (UINT8*) imIn1->image[y];\
|
||||
UINT8* in2 = (UINT8*) imIn2->image[y];\
|
||||
for (x = 0; x < imOut->linesize; x++) {\
|
||||
out[x] = operation;\
|
||||
}\
|
||||
UINT8* out = (UINT8*) imOut->image[y];\
|
||||
UINT8* in1 = (UINT8*) imIn1->image[y];\
|
||||
UINT8* in2 = (UINT8*) imIn2->image[y];\
|
||||
for (x = 0; x < imOut->linesize; x++) {\
|
||||
out[x] = operation;\
|
||||
}\
|
||||
}\
|
||||
return imOut;
|
||||
|
||||
|
@ -64,15 +64,15 @@ create(Imaging im1, Imaging im2, char* mode)
|
|||
|
||||
if (!im1 || !im2 || im1->type != IMAGING_TYPE_UINT8 ||
|
||||
(mode != NULL && (strcmp(im1->mode, "1") || strcmp(im2->mode, "1"))))
|
||||
return (Imaging) ImagingError_ModeError();
|
||||
return (Imaging) ImagingError_ModeError();
|
||||
if (im1->type != im2->type ||
|
||||
im1->bands != im2->bands)
|
||||
return (Imaging) ImagingError_Mismatch();
|
||||
return (Imaging) ImagingError_Mismatch();
|
||||
|
||||
xsize = (im1->xsize < im2->xsize) ? im1->xsize : im2->xsize;
|
||||
ysize = (im1->ysize < im2->ysize) ? im1->ysize : im2->ysize;
|
||||
|
||||
return ImagingNew(im1->mode, xsize, ysize);
|
||||
return ImagingNewDirty(im1->mode, xsize, ysize);
|
||||
}
|
||||
|
||||
Imaging
|
||||
|
|
|
@ -37,7 +37,7 @@ ImagingEffectMandelbrot(int xsize, int ysize, double extent[4], int quality)
|
|||
if (width < 0.0 || height < 0.0 || quality < 2)
|
||||
return (Imaging) ImagingError_ValueError(NULL);
|
||||
|
||||
im = ImagingNew("L", xsize, ysize);
|
||||
im = ImagingNewDirty("L", xsize, ysize);
|
||||
if (!im)
|
||||
return NULL;
|
||||
|
||||
|
@ -81,7 +81,7 @@ ImagingEffectNoise(int xsize, int ysize, float sigma)
|
|||
int nextok;
|
||||
double this, next;
|
||||
|
||||
imOut = ImagingNew("L", xsize, ysize);
|
||||
imOut = ImagingNewDirty("L", xsize, ysize);
|
||||
if (!imOut)
|
||||
return NULL;
|
||||
|
||||
|
@ -90,7 +90,7 @@ ImagingEffectNoise(int xsize, int ysize, float sigma)
|
|||
|
||||
for (y = 0; y < imOut->ysize; y++) {
|
||||
UINT8* out = imOut->image8[y];
|
||||
for (x = 0; x < imOut->xsize; x++) {
|
||||
for (x = 0; x < imOut->xsize; x++) {
|
||||
if (nextok) {
|
||||
this = next;
|
||||
nextok = 0;
|
||||
|
@ -121,14 +121,14 @@ ImagingEffectSpread(Imaging imIn, int distance)
|
|||
Imaging imOut;
|
||||
int x, y;
|
||||
|
||||
imOut = ImagingNew(imIn->mode, imIn->xsize, imIn->ysize);
|
||||
imOut = ImagingNewDirty(imIn->mode, imIn->xsize, imIn->ysize);
|
||||
|
||||
if (!imOut)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
#define SPREAD(type, image)\
|
||||
for (y = 0; y < imIn->ysize; y++)\
|
||||
for (x = 0; x < imIn->xsize; x++) {\
|
||||
for (y = 0; y < imOut->ysize; y++)\
|
||||
for (x = 0; x < imOut->xsize; x++) {\
|
||||
int xx = x + (rand() % distance) - distance/2;\
|
||||
int yy = y + (rand() % distance) - distance/2;\
|
||||
if (xx >= 0 && xx < imIn->xsize && yy >= 0 && yy < imIn->ysize) {\
|
||||
|
|
|
@ -26,11 +26,11 @@ ImagingModeFilter(Imaging im, int size)
|
|||
int histogram[256];
|
||||
|
||||
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)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
size = size / 2;
|
||||
|
||||
|
|
|
@ -1642,11 +1642,11 @@ ImagingQuantize(Imaging im, int colors, int mode, int kmeans)
|
|||
ImagingSectionLeave(&cookie);
|
||||
|
||||
if (result > 0) {
|
||||
imOut = ImagingNew("P", im->xsize, im->ysize);
|
||||
imOut = ImagingNewDirty("P", im->xsize, im->ysize);
|
||||
ImagingSectionEnter(&cookie);
|
||||
|
||||
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++];
|
||||
|
||||
free(newData);
|
||||
|
|
Loading…
Reference in New Issue
Block a user