@@ -103,24 +103,39 @@ static PyObject *PyFT2Image_draw_rect_filled(PyFT2Image *self, PyObject *args, P
103103const char *PyFT2Image_as_str__doc__ =
104104 " s = image.as_str()\n "
105105 " \n "
106+ " [*Deprecated*]\n "
106107 " Return the image buffer as a string\n "
107108 " \n " ;
108109
109110static PyObject *PyFT2Image_as_str (PyFT2Image *self, PyObject *args, PyObject *kwds)
110111{
111- // TODO: Use a buffer to avoid the copy
112+ if (PyErr_WarnEx (PyExc_DeprecationWarning,
113+ " FT2Image.as_str is deprecated since Matplotlib 3.2 and "
114+ " will be removed in Matplotlib 3.4; convert the FT2Image "
115+ " to a NumPy array with np.asarray instead." ,
116+ 1 )) {
117+ return NULL ;
118+ }
112119 return PyBytes_FromStringAndSize ((const char *)self->x ->get_buffer (),
113120 self->x ->get_width () * self->x ->get_height ());
114121}
115122
116123const char *PyFT2Image_as_rgba_str__doc__ =
117124 " s = image.as_rgba_str()\n "
118125 " \n "
126+ " [*Deprecated*]\n "
119127 " Return the image buffer as a RGBA string\n "
120128 " \n " ;
121129
122130static PyObject *PyFT2Image_as_rgba_str (PyFT2Image *self, PyObject *args, PyObject *kwds)
123131{
132+ if (PyErr_WarnEx (PyExc_DeprecationWarning,
133+ " FT2Image.as_rgba_str is deprecated since Matplotlib 3.2 and "
134+ " will be removed in Matplotlib 3.4; convert the FT2Image "
135+ " to a NumPy array with np.asarray instead." ,
136+ 1 )) {
137+ return NULL ;
138+ }
124139 npy_intp dims[] = {(npy_intp)self->x ->get_height (), (npy_intp)self->x ->get_width (), 4 };
125140 numpy::array_view<unsigned char , 3 > result (dims);
126141
@@ -141,22 +156,44 @@ static PyObject *PyFT2Image_as_rgba_str(PyFT2Image *self, PyObject *args, PyObje
141156const char *PyFT2Image_as_array__doc__ =
142157 " x = image.as_array()\n "
143158 " \n "
159+ " [*Deprecated*]\n "
144160 " Return the image buffer as a width x height numpy array of ubyte \n "
145161 " \n " ;
146162
147163static PyObject *PyFT2Image_as_array (PyFT2Image *self, PyObject *args, PyObject *kwds)
148164{
165+ if (PyErr_WarnEx (PyExc_DeprecationWarning,
166+ " FT2Image.as_array is deprecated since Matplotlib 3.2 and "
167+ " will be removed in Matplotlib 3.4; convert the FT2Image "
168+ " to a NumPy array with np.asarray instead." ,
169+ 1 )) {
170+ return NULL ;
171+ }
149172 npy_intp dims[] = {(npy_intp)self->x ->get_height (), (npy_intp)self->x ->get_width () };
150173 return PyArray_SimpleNewFromData (2 , dims, NPY_UBYTE, self->x ->get_buffer ());
151174}
152175
153176static PyObject *PyFT2Image_get_width (PyFT2Image *self, PyObject *args, PyObject *kwds)
154177{
178+ if (PyErr_WarnEx (PyExc_DeprecationWarning,
179+ " FT2Image.get_width is deprecated since Matplotlib 3.2 and "
180+ " will be removed in Matplotlib 3.4; convert the FT2Image "
181+ " to a NumPy array with np.asarray instead." ,
182+ 1 )) {
183+ return NULL ;
184+ }
155185 return PyLong_FromLong (self->x ->get_width ());
156186}
157187
158188static PyObject *PyFT2Image_get_height (PyFT2Image *self, PyObject *args, PyObject *kwds)
159189{
190+ if (PyErr_WarnEx (PyExc_DeprecationWarning,
191+ " FT2Image.get_height is deprecated since Matplotlib 3.2 and "
192+ " will be removed in Matplotlib 3.4; convert the FT2Image "
193+ " to a NumPy array with np.asarray instead." ,
194+ 1 )) {
195+ return NULL ;
196+ }
160197 return PyLong_FromLong (self->x ->get_height ());
161198}
162199
0 commit comments