-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Remove unused ImagingConvertInPlace #9878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2052,45 +2052,16 @@ _reduce(ImagingObject *self, PyObject *args) { | |
| return PyImagingNew(imOut); | ||
| } | ||
|
|
||
| static int | ||
| isRGB(const ModeID mode) { | ||
| return mode == IMAGING_MODE_RGB || mode == IMAGING_MODE_RGBA || | ||
| mode == IMAGING_MODE_RGBX; | ||
| } | ||
|
|
||
| static PyObject * | ||
| im_setmode(ImagingObject *self, PyObject *args) { | ||
| im_setalpha(ImagingObject *self, PyObject *args) { | ||
| /* attempt to modify the mode of an image in place */ | ||
|
|
||
| Imaging im; | ||
|
|
||
| char *mode_name; | ||
| Py_ssize_t modelen; | ||
| if (!PyArg_ParseTuple(args, "s#:setmode", &mode_name, &modelen)) { | ||
| return NULL; | ||
| } | ||
|
|
||
| const ModeID mode = findModeID(mode_name); | ||
|
|
||
| im = self->image; | ||
|
|
||
| /* move all logic in here to the libImaging primitive */ | ||
|
|
||
| if (im->mode == mode) { | ||
| ; /* same mode; always succeeds */ | ||
| } else if (isRGB(im->mode) && isRGB(mode)) { | ||
| /* color to color */ | ||
| im->mode = mode; | ||
| im->bands = modelen; | ||
| if (mode == IMAGING_MODE_RGBA) { | ||
| (void)ImagingFillBand(im, 3, 255); | ||
| } | ||
| } else { | ||
| /* trying doing an in-place conversion */ | ||
| if (!ImagingConvertInPlace(im, mode)) { | ||
| return NULL; | ||
| } | ||
| Imaging im = self->image; | ||
| if (im->mode != IMAGING_MODE_RGB && im->mode != IMAGING_MODE_RGBX) { | ||
| return ImagingError_ModeError(); | ||
| } | ||
| im->mode = IMAGING_MODE_RGBA; | ||
| im->bands = 4; | ||
| (void)ImagingFillBand(im, 3, 255); | ||
|
|
||
| if (self->access) { | ||
| ImagingAccessDelete(im, self->access); | ||
|
|
@@ -3739,7 +3710,7 @@ static struct PyMethodDef methods[] = { | |
| {"split", (PyCFunction)_split, METH_NOARGS}, | ||
| {"fillband", (PyCFunction)_fillband, METH_VARARGS}, | ||
|
|
||
| {"setmode", (PyCFunction)im_setmode, METH_VARARGS}, | ||
| {"setalpha", (PyCFunction)im_setalpha, METH_NOARGS}, | ||
|
Comment on lines
-3742
to
+3713
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the deprecation policy for methods on the core image objects in general (is it documented)? GitHub's Code Search isn't making it easy to find whether there are external users of
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no deprecation period.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's an useful comment, thanks! Should maybe codify it into development documentation if it isn't already (for instance, I feel much better about touching the palette code even harder in #9829). And I'll understand this as "the Python-facing interfaces defined in C extension module(s) in Pillow are also malleable" (since this is exactly that). 👍
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've created #9879 |
||
|
|
||
| {"getpalette", (PyCFunction)_getpalette, METH_VARARGS}, | ||
| {"getpalettemode", (PyCFunction)_getpalettemode, METH_NOARGS}, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is a little stale now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it? The method is still modifying the mode of an image in place. It's more specific now, is all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose...
Should this function know how to do P-to-PA and L-to-LA too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thought occurred to me. It is a bit different to RGB, since RGB already has the same
pixelsizeas RGBA.Do you mind if that is a follow-up PR? I would rather tidy things up first.