mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Added braces
This commit is contained in:
parent
9f2773b3f7
commit
3a75e843f4
|
@ -490,8 +490,9 @@ getpixel(Imaging im, ImagingAccess access, int x, int y)
|
|||
case IMAGING_TYPE_FLOAT32:
|
||||
return PyFloat_FromDouble(pixel.f);
|
||||
case IMAGING_TYPE_SPECIAL:
|
||||
if (strncmp(im->mode, "I;16", 4) == 0)
|
||||
if (strncmp(im->mode, "I;16", 4) == 0) {
|
||||
return PyLong_FromLong(pixel.h);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1456,8 +1457,9 @@ _point(ImagingObject* self, PyObject* args)
|
|||
lut[i*4] = CLIP8(data[i]);
|
||||
lut[i*4+1] = CLIP8(data[i+256]);
|
||||
lut[i*4+2] = CLIP8(data[i+512]);
|
||||
if (n > 768)
|
||||
if (n > 768) {
|
||||
lut[i*4+3] = CLIP8(data[i+768]);
|
||||
}
|
||||
}
|
||||
im = ImagingPoint(self->image, mode, (void*) lut);
|
||||
} else {
|
||||
|
@ -1523,16 +1525,18 @@ _putdata(ImagingObject* self, PyObject* args)
|
|||
/* Plain string data */
|
||||
for (i = y = 0; i < n; i += image->xsize, y++) {
|
||||
x = n - i;
|
||||
if (x > (int) image->xsize)
|
||||
if (x > (int) image->xsize) {
|
||||
x = image->xsize;
|
||||
}
|
||||
memcpy(image->image8[y], p+i, x);
|
||||
}
|
||||
} else {
|
||||
/* Scaled and clipped string data */
|
||||
for (i = x = y = 0; i < n; i++) {
|
||||
image->image8[y][x] = CLIP8((int) (p[i] * scale + offset));
|
||||
if (++x >= (int) image->xsize)
|
||||
if (++x >= (int) image->xsize) {
|
||||
x = 0, y++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1932,12 +1936,14 @@ im_setmode(ImagingObject* self, PyObject* args)
|
|||
/* color to color */
|
||||
strcpy(im->mode, mode);
|
||||
im->bands = modelen;
|
||||
if (!strcmp(mode, "RGBA"))
|
||||
if (!strcmp(mode, "RGBA")) {
|
||||
(void) ImagingFillBand(im, 3, 255);
|
||||
}
|
||||
} else {
|
||||
/* trying doing an in-place conversion */
|
||||
if (!ImagingConvertInPlace(im, mode))
|
||||
if (!ImagingConvertInPlace(im, mode)) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (self->access) {
|
||||
|
|
|
@ -406,11 +406,11 @@ text_layout_raqm(PyObject* string, FontObject* self, const char* dir, PyObject *
|
|||
|
||||
direction = RAQM_DIRECTION_DEFAULT;
|
||||
if (dir) {
|
||||
if (strcmp(dir, "rtl") == 0)
|
||||
if (strcmp(dir, "rtl") == 0) {
|
||||
direction = RAQM_DIRECTION_RTL;
|
||||
else if (strcmp(dir, "ltr") == 0)
|
||||
} else if (strcmp(dir, "ltr") == 0) {
|
||||
direction = RAQM_DIRECTION_LTR;
|
||||
else if (strcmp(dir, "ttb") == 0) {
|
||||
} else if (strcmp(dir, "ttb") == 0) {
|
||||
direction = RAQM_DIRECTION_TTB;
|
||||
if (p_raqm.version_atleast == NULL || !(*p_raqm.version_atleast)(0, 7, 0)) {
|
||||
PyErr_SetString(PyExc_ValueError, "libraqm 0.7 or greater required for 'ttb' direction");
|
||||
|
@ -694,8 +694,9 @@ font_getsize(FontObject* self, PyObject* args)
|
|||
offset = -glyph_info[i].y_advance -
|
||||
face->glyph->metrics.height -
|
||||
face->glyph->metrics.vertBearingY;
|
||||
if (offset < 0)
|
||||
if (offset < 0) {
|
||||
y_max -= offset;
|
||||
}
|
||||
}
|
||||
|
||||
if (bbox.xMax > x_max) {
|
||||
|
|
|
@ -1085,8 +1085,9 @@ PyImaging_JpegEncoderNew(PyObject* self, PyObject* args)
|
|||
if (extra && extra_size > 0) {
|
||||
/* malloc check ok, length is from python parsearg */
|
||||
char* p = malloc(extra_size); // Freed in JpegEncode, Case 5
|
||||
if (!p)
|
||||
if (!p) {
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
memcpy(p, extra, extra_size);
|
||||
extra = p;
|
||||
} else {
|
||||
|
@ -1097,7 +1098,9 @@ PyImaging_JpegEncoderNew(PyObject* self, PyObject* args)
|
|||
/* malloc check ok, length is from python parsearg */
|
||||
char* pp = malloc(rawExifLen); // Freed in JpegEncode, Case 5
|
||||
if (!pp) {
|
||||
if (extra) free(extra);
|
||||
if (extra) {
|
||||
free(extra);
|
||||
}
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
memcpy(pp, rawExif, rawExifLen);
|
||||
|
|
|
@ -1660,17 +1660,16 @@ convert(Imaging imOut, Imaging imIn, const char *mode,
|
|||
}
|
||||
}
|
||||
|
||||
if (!convert)
|
||||
if (!convert) {
|
||||
#ifdef notdef
|
||||
return (Imaging) ImagingError_ValueError("conversion not supported");
|
||||
#else
|
||||
{
|
||||
static char buf[256];
|
||||
/* FIXME: may overflow if mode is too large */
|
||||
sprintf(buf, "conversion from %s to %s not supported", imIn->mode, mode);
|
||||
return (Imaging) ImagingError_ValueError(buf);
|
||||
}
|
||||
static char buf[256];
|
||||
/* FIXME: may overflow if mode is too large */
|
||||
sprintf(buf, "conversion from %s to %s not supported", imIn->mode, mode);
|
||||
return (Imaging) ImagingError_ValueError(buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
imOut = ImagingNew2Dirty(mode, imOut, imIn);
|
||||
if (!imOut) {
|
||||
|
|
|
@ -32,11 +32,13 @@ ImagingCrop(Imaging imIn, int sx0, int sy0, int sx1, int sy1)
|
|||
}
|
||||
|
||||
xsize = sx1 - sx0;
|
||||
if (xsize < 0)
|
||||
if (xsize < 0) {
|
||||
xsize = 0;
|
||||
}
|
||||
ysize = sy1 - sy0;
|
||||
if (ysize < 0)
|
||||
if (ysize < 0) {
|
||||
ysize = 0;
|
||||
}
|
||||
|
||||
imOut = ImagingNewDirty(imIn->mode, xsize, ysize);
|
||||
if (!imOut) {
|
||||
|
|
|
@ -941,8 +941,9 @@ ellipse(Imaging im, int x0, int y0, int x1, int y1,
|
|||
}
|
||||
lx = x, ly = y;
|
||||
}
|
||||
if (n == 0)
|
||||
if (n == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (inner) {
|
||||
// Inner circle
|
||||
|
|
|
@ -39,15 +39,18 @@ ImagingGetBBox(Imaging im, int bbox[4])
|
|||
for (x = 0; x < im->xsize; x++) {\
|
||||
if (im->image[y][x] & mask) {\
|
||||
has_data = 1;\
|
||||
if (x < bbox[0])\
|
||||
if (x < bbox[0]) {\
|
||||
bbox[0] = x;\
|
||||
if (x >= bbox[2])\
|
||||
}\
|
||||
if (x >= bbox[2]) {\
|
||||
bbox[2] = x+1;\
|
||||
}\
|
||||
}\
|
||||
}\
|
||||
if (has_data) {\
|
||||
if (bbox[1] < 0)\
|
||||
bbox[1] = y;\
|
||||
if (bbox[1] < 0) {\
|
||||
bbox[1] = y;\
|
||||
}\
|
||||
bbox[3] = y+1;\
|
||||
}\
|
||||
}
|
||||
|
|
|
@ -52,8 +52,9 @@
|
|||
default:\
|
||||
return -1;\
|
||||
}\
|
||||
if (state->y < state->ysize)\
|
||||
if (state->y < state->ysize) {\
|
||||
out = im->image8[state->y + state->yoff] + state->xoff;\
|
||||
}\
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,24 +71,25 @@ ImagingGifDecode(Imaging im, ImagingCodecState state, UINT8* buffer, Py_ssize_t
|
|||
|
||||
if (!state->state) {
|
||||
|
||||
/* Initialise state */
|
||||
if (context->bits < 0 || context->bits > 12) {
|
||||
state->errcode = IMAGING_CODEC_CONFIG;
|
||||
return -1;
|
||||
}
|
||||
/* Initialise state */
|
||||
if (context->bits < 0 || context->bits > 12) {
|
||||
state->errcode = IMAGING_CODEC_CONFIG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Clear code */
|
||||
context->clear = 1 << context->bits;
|
||||
/* Clear code */
|
||||
context->clear = 1 << context->bits;
|
||||
|
||||
/* End code */
|
||||
context->end = context->clear + 1;
|
||||
/* End code */
|
||||
context->end = context->clear + 1;
|
||||
|
||||
/* Interlace */
|
||||
if (context->interlace) {
|
||||
context->interlace = 1;
|
||||
context->step = context->repeat = 8;
|
||||
} else
|
||||
context->step = 1;
|
||||
/* Interlace */
|
||||
if (context->interlace) {
|
||||
context->interlace = 1;
|
||||
context->step = context->repeat = 8;
|
||||
} else {
|
||||
context->step = 1;
|
||||
}
|
||||
|
||||
state->state = 1;
|
||||
}
|
||||
|
|
|
@ -179,8 +179,9 @@ ImagingGetHistogram(Imaging im, Imaging imMask, void* minmax)
|
|||
FLOAT32* in = (FLOAT32*) im->image32[y];
|
||||
for (x = 0; x < im->xsize; x++) {
|
||||
i = (int) (((*in++)-fmin)*scale);
|
||||
if (i >= 0 && i < 256)
|
||||
if (i >= 0 && i < 256) {
|
||||
h->histogram[i]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
ImagingSectionLeave(&cookie);
|
||||
|
|
|
@ -219,8 +219,9 @@ ImagingPointTransform(Imaging imIn, double scale, double offset)
|
|||
|
||||
if (!imIn || (strcmp(imIn->mode, "I") != 0 &&
|
||||
strcmp(imIn->mode, "I;16") != 0 &&
|
||||
strcmp(imIn->mode, "F") != 0))
|
||||
strcmp(imIn->mode, "F") != 0)) {
|
||||
return (Imaging) ImagingError_ModeError();
|
||||
}
|
||||
|
||||
imOut = ImagingNew(imIn->mode, imIn->xsize, imIn->ysize);
|
||||
if (!imOut) {
|
||||
|
|
|
@ -689,8 +689,12 @@ static void
|
|||
free_box_tree(BoxNode *n)
|
||||
{
|
||||
PixelList *p,*pp;
|
||||
if (n->l) free_box_tree(n->l);
|
||||
if (n->r) free_box_tree(n->r);
|
||||
if (n->l) {
|
||||
free_box_tree(n->l);
|
||||
}
|
||||
if (n->r) {
|
||||
free_box_tree(n->r);
|
||||
}
|
||||
for (p=n->head[0];p;p=pp) {
|
||||
pp=p->next[0];
|
||||
free(p);
|
||||
|
@ -1008,7 +1012,9 @@ compute_palette_from_median_cut(
|
|||
/* malloc check ok, using calloc */
|
||||
if (!(avg[i]=calloc(nPaletteEntries, sizeof(uint32_t)))) {
|
||||
for(i=0;i<3;i++) {
|
||||
if (avg[i]) free (avg[i]);
|
||||
if (avg[i]) {
|
||||
free (avg[i]);
|
||||
}
|
||||
}
|
||||
free(count);
|
||||
return 0;
|
||||
|
|
|
@ -41,8 +41,9 @@ ImagingRawEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
|||
}
|
||||
state->count = state->bytes;
|
||||
state->bytes = bytes;
|
||||
} else
|
||||
} else {
|
||||
state->count = state->bytes;
|
||||
}
|
||||
|
||||
/* The "ystep" field specifies the orientation */
|
||||
|
||||
|
|
|
@ -90,8 +90,9 @@ ImagingXbmEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
|||
bytes--;
|
||||
state->count = 0;
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
*ptr++ = '\n';
|
||||
}
|
||||
|
||||
bytes -= 5;
|
||||
|
||||
|
|
|
@ -307,8 +307,9 @@ ImagingZipEncode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes)
|
|||
|
||||
}
|
||||
|
||||
if (context->z_stream.avail_out == 0)
|
||||
if (context->z_stream.avail_out == 0) {
|
||||
break; /* Buffer full */
|
||||
}
|
||||
|
||||
case 2:
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user