Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tests/test_image_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def test_embeddable(self) -> None:
with open("embed_pil.c", "w", encoding="utf-8") as fh:
home = sys.prefix.replace("\\", "\\\\")
fh.write(f"""
#include "Python.h"
#include <Python.h>

int main(int argc, char* argv[])
{{
Expand Down
6 changes: 2 additions & 4 deletions src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ _radial_gradient(PyObject *self, PyObject *args) {
}

static PyObject *
_alpha_composite(ImagingObject *self, PyObject *args) {
_alpha_composite(PyObject *self, PyObject *args) {
ImagingObject *imagep1;
ImagingObject *imagep2;

Expand All @@ -801,7 +801,7 @@ _alpha_composite(ImagingObject *self, PyObject *args) {
}

static PyObject *
_blend(ImagingObject *self, PyObject *args) {
_blend(PyObject *self, PyObject *args) {
ImagingObject *imagep1;
ImagingObject *imagep2;
double alpha;
Expand Down Expand Up @@ -1670,7 +1670,6 @@ _putdata(ImagingObject *self, PyObject *args) {
} else {
seq = PySequence_Fast(data, must_be_sequence);
if (!seq) {
PyErr_SetString(PyExc_TypeError, must_be_sequence);
return NULL;
}
double value;
Expand Down Expand Up @@ -1708,7 +1707,6 @@ _putdata(ImagingObject *self, PyObject *args) {
/* 32-bit images */
seq = PySequence_Fast(data, must_be_sequence);
if (!seq) {
PyErr_SetString(PyExc_TypeError, must_be_sequence);
return NULL;
}
switch (image->type) {
Expand Down
2 changes: 0 additions & 2 deletions src/_imagingcms.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ kevin@cazabon.com\n\
#include <lcms2.h>
#include "libImaging/Imaging.h"

#define PYCMSVERSION "1.0.0 pil"

/* version history */

/*
Expand Down
12 changes: 6 additions & 6 deletions src/_imagingmath.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
#define SUB(type, v1, v2) (v1) - (v2)
#define MUL(type, v1, v2) (v1) * (v2)

#define MIN(type, v1, v2) ((v1) < (v2)) ? (v1) : (v2)
#define MAX(type, v1, v2) ((v1) > (v2)) ? (v1) : (v2)
#define MINOP(type, v1, v2) ((v1) < (v2)) ? (v1) : (v2)
#define MAXOP(type, v1, v2) ((v1) > (v2)) ? (v1) : (v2)

#define AND(type, v1, v2) (v1) & (v2)
#define OR(type, v1, v2) (v1) | (v2)
Expand Down Expand Up @@ -134,8 +134,8 @@ BINOP(xor_I, XOR, INT32)
BINOP(lshift_I, LSHIFT, INT32)
BINOP(rshift_I, RSHIFT, INT32)

BINOP(min_I, MIN, INT32)
BINOP(max_I, MAX, INT32)
BINOP(min_I, MINOP, INT32)
BINOP(max_I, MAXOP, INT32)

BINOP(eq_I, EQ, INT32)
BINOP(ne_I, NE, INT32)
Expand All @@ -155,8 +155,8 @@ BINOP(mod_F, MOD_F, FLOAT32)
BINOP(pow_F, POW_F, FLOAT32)
BINOP(diff_F, DIFF_F, FLOAT32)

BINOP(min_F, MIN, FLOAT32)
BINOP(max_F, MAX, FLOAT32)
BINOP(min_F, MINOP, FLOAT32)
BINOP(max_F, MAXOP, FLOAT32)

BINOP(eq_F, EQ, FLOAT32)
BINOP(ne_F, NE, FLOAT32)
Expand Down
3 changes: 0 additions & 3 deletions src/libImaging/BoxBlur.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include "Imaging.h"

#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))

typedef UINT8 pixel[4];

void static inline ImagingLineBoxBlur32(
Expand Down
3 changes: 0 additions & 3 deletions src/libImaging/Convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@

#include "Imaging.h"

#define MAX(a, b) (a) > (b) ? (a) : (b)
#define MIN(a, b) (a) < (b) ? (a) : (b)

/* ITU-R Recommendation 601-2 (assuming nonlinear RGB) */
#define L(rgb) ((INT32)(rgb)[0] * 299 + (INT32)(rgb)[1] * 587 + (INT32)(rgb)[2] * 114)
#define L24(rgb) ((rgb)[0] * 19595 + (rgb)[1] * 38470 + (rgb)[2] * 7471 + 0x8000)
Expand Down
3 changes: 3 additions & 0 deletions src/libImaging/ImagingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#define MASK_UINT32_CHANNEL_3 0xff000000
#endif

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)

#define SHIFTFORDIV255(a) ((((a) >> 8) + a) >> 8)

/* like (a * b + 127) / 255), but much faster on most platforms */
Expand Down
2 changes: 0 additions & 2 deletions src/libImaging/QuantOctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ typedef struct _ColorCube {
ColorBucket buckets;
} *ColorCube;

#define MAX(a, b) (a) > (b) ? (a) : (b)

static ColorCube
new_color_cube(int r, int g, int b, int a) {
ColorCube cube;
Expand Down
2 changes: 1 addition & 1 deletion src/libImaging/QuantPngQuant.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "QuantPngQuant.h"

#ifdef HAVE_LIBIMAGEQUANT
#include "libimagequant.h"
#include <libimagequant.h>

int
quantize_pngquant(
Expand Down
16 changes: 8 additions & 8 deletions src/libImaging/TiffDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ _tiffReadProc(thandle_t hdata, tdata_t buf, tsize_t size) {
);
return 0;
}
to_read = min(size, min(state->size, (tsize_t)state->eof) - (tsize_t)state->loc);
to_read = MIN(size, MIN(state->size, (tsize_t)state->eof) - (tsize_t)state->loc);
TRACE(("to_read: %d\n", (int)to_read));

_TIFFmemcpy(buf, (UINT8 *)state->data + state->loc, to_read);
Expand All @@ -87,7 +87,7 @@ _tiffWriteProc(thandle_t hdata, tdata_t buf, tsize_t size) {
TRACE(("_tiffWriteProc: %d \n", (int)size));
dump_state(state);

to_write = min(size, state->size - (tsize_t)state->loc);
to_write = MIN(size, state->size - (tsize_t)state->loc);
if (state->flrealloc && size > to_write) {
tdata_t new_data;
tsize_t newsize = state->size;
Expand All @@ -114,7 +114,7 @@ _tiffWriteProc(thandle_t hdata, tdata_t buf, tsize_t size) {

_TIFFmemcpy((UINT8 *)state->data + state->loc, buf, to_write);
state->loc += (toff_t)to_write;
state->eof = max(state->loc, state->eof);
state->eof = MAX(state->loc, state->eof);

dump_state(state);
return to_write;
Expand Down Expand Up @@ -346,7 +346,7 @@ _decodeAsRGBA(Imaging im, ImagingCodecState state, TIFF *tiff) {

for (; state->y < state->ysize; state->y += rows_per_block) {
img.row_offset = state->y;
rows_to_read = min(rows_per_block, img.height - state->y);
rows_to_read = MIN(rows_per_block, img.height - state->y);

if (!TIFFRGBAImageGet(&img, (UINT32 *)state->buffer, img.width, rows_to_read)) {
TRACE(("Decode Error, y: %d\n", state->y));
Expand All @@ -362,7 +362,7 @@ _decodeAsRGBA(Imaging im, ImagingCodecState state, TIFF *tiff) {

// iterate over each row in the strip and stuff data into image
for (current_row = 0;
current_row < min((INT32)rows_per_block, state->ysize - state->y);
current_row < MIN((INT32)rows_per_block, state->ysize - state->y);
current_row++) {
TRACE(("Writing data into line %d ; \n", state->y + current_row));

Expand Down Expand Up @@ -465,8 +465,8 @@ _decodeTile(

TRACE(("Read tile at %dx%d; \n\n", x, y));

current_tile_width = min((INT32)tile_width, state->xsize - x);
current_tile_length = min((INT32)tile_length, state->ysize - y);
current_tile_width = MIN((INT32)tile_width, state->xsize - x);
current_tile_length = MIN((INT32)tile_length, state->ysize - y);
// iterate over each line in the tile and stuff data into image
for (tile_y = 0; tile_y < current_tile_length; tile_y++) {
TRACE(
Expand Down Expand Up @@ -580,7 +580,7 @@ _decodeStrip(

// iterate over each row in the strip and stuff data into image
for (strip_row = 0;
strip_row < min((INT32)rows_per_strip, state->ysize - state->y);
strip_row < MIN((INT32)rows_per_strip, state->ysize - state->y);
strip_row++) {
TRACE(("Writing data into line %d ; \n", state->y + strip_row));

Expand Down
5 changes: 0 additions & 5 deletions src/libImaging/TiffDecode.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@
#include <tiff.h>
#endif

#ifndef min
#define min(x, y) ((x > y) ? y : x)
#define max(x, y) ((x < y) ? y : x)
#endif

#ifndef _PIL_LIBTIFF_
#define _PIL_LIBTIFF_

Expand Down
Loading