Skip to content

Commit

Permalink
Correct types of _imaging methods
Browse files Browse the repository at this point in the history
Move new_block method to _imaging
remove _imaging.convert method
  • Loading branch information
homm committed Sep 18, 2024
1 parent ffa0230 commit e7bce42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/PIL/ImageTk.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ def paste(self, im: Image.Image) -> None:
if image.isblock() and im.mode == self.__mode:
block = image
else:
block = image.new_block(self.__mode, im.size)
image.convert2(block, image) # convert directly between buffers
block = Image.core.new_block(self.__mode, im.size)
image.convert2(block) # convert directly between buffers

_pyimagingtkcall("PyImagingPhoto", self.__photo, block.id)

Expand Down
29 changes: 11 additions & 18 deletions src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
#define S16(v) ((v) < 32768 ? (v) : ((v) - 65536))

/* -------------------------------------------------------------------- */
/* OBJECT ADMINISTRATION */
/* OBJECT ADMINISTRATION */
/* -------------------------------------------------------------------- */

typedef struct {
Expand Down Expand Up @@ -256,7 +256,7 @@ ImagingError_Clear(void) {
}

/* -------------------------------------------------------------------- */
/* HELPERS */
/* HELPERS */
/* -------------------------------------------------------------------- */

static int
Expand Down Expand Up @@ -605,7 +605,7 @@ getink(PyObject *color, Imaging im, char *ink) {
}

/* -------------------------------------------------------------------- */
/* FACTORIES */
/* FACTORIES */
/* -------------------------------------------------------------------- */

static PyObject *
Expand Down Expand Up @@ -688,7 +688,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 @@ -702,7 +702,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 @@ -920,15 +920,12 @@ _convert(ImagingObject *self, PyObject *args) {

static PyObject *
_convert2(ImagingObject *self, PyObject *args) {
ImagingObject *imagep1;
ImagingObject *imagep2;
if (!PyArg_ParseTuple(
args, "O!O!", &Imaging_Type, &imagep1, &Imaging_Type, &imagep2
)) {
ImagingObject *imagep;
if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) {
return NULL;
}

if (!ImagingConvert2(imagep1->image, imagep2->image)) {
if (!ImagingConvert2(imagep->image, self->image)) {
return NULL;
}

Expand Down Expand Up @@ -3491,7 +3488,7 @@ _effect_spread(ImagingObject *self, PyObject *args) {
}

/* -------------------------------------------------------------------- */
/* UTILITIES */
/* UTILITIES */
/* -------------------------------------------------------------------- */

static PyObject *
Expand Down Expand Up @@ -3527,7 +3524,7 @@ _getcodecstatus(PyObject *self, PyObject *args) {
}

/* -------------------------------------------------------------------- */
/* DEBUGGING HELPERS */
/* DEBUGGING HELPERS */
/* -------------------------------------------------------------------- */

static PyObject *
Expand Down Expand Up @@ -3630,8 +3627,6 @@ static struct PyMethodDef methods[] = {
{"effect_spread", (PyCFunction)_effect_spread, METH_VARARGS},

/* Misc. */
{"new_block", (PyCFunction)_new_block, METH_VARARGS},

{"save_ppm", (PyCFunction)_save_ppm, METH_VARARGS},

{NULL, NULL} /* sentinel */
Expand Down Expand Up @@ -4142,11 +4137,9 @@ static PyMethodDef functions[] = {
{"blend", (PyCFunction)_blend, METH_VARARGS},
{"fill", (PyCFunction)_fill, METH_VARARGS},
{"new", (PyCFunction)_new, METH_VARARGS},
{"new_block", (PyCFunction)_new_block, METH_VARARGS},
{"merge", (PyCFunction)_merge, METH_VARARGS},

/* Functions */
{"convert", (PyCFunction)_convert2, METH_VARARGS},

/* Codecs */
{"bcn_decoder", (PyCFunction)PyImaging_BcnDecoderNew, METH_VARARGS},
{"bit_decoder", (PyCFunction)PyImaging_BitDecoderNew, METH_VARARGS},
Expand Down

0 comments on commit e7bce42

Please sign in to comment.