@@ -103,24 +103,39 @@ static PyObject *PyFT2Image_draw_rect_filled(PyFT2Image *self, PyObject *args, P
103
103
const char *PyFT2Image_as_str__doc__ =
104
104
" s = image.as_str()\n "
105
105
" \n "
106
+ " [*Deprecated*]\n "
106
107
" Return the image buffer as a string\n "
107
108
" \n " ;
108
109
109
110
static PyObject *PyFT2Image_as_str (PyFT2Image *self, PyObject *args, PyObject *kwds)
110
111
{
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
+ }
112
119
return PyBytes_FromStringAndSize ((const char *)self->x ->get_buffer (),
113
120
self->x ->get_width () * self->x ->get_height ());
114
121
}
115
122
116
123
const char *PyFT2Image_as_rgba_str__doc__ =
117
124
" s = image.as_rgba_str()\n "
118
125
" \n "
126
+ " [*Deprecated*]\n "
119
127
" Return the image buffer as a RGBA string\n "
120
128
" \n " ;
121
129
122
130
static PyObject *PyFT2Image_as_rgba_str (PyFT2Image *self, PyObject *args, PyObject *kwds)
123
131
{
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
+ }
124
139
npy_intp dims[] = {(npy_intp)self->x ->get_height (), (npy_intp)self->x ->get_width (), 4 };
125
140
numpy::array_view<unsigned char , 3 > result (dims);
126
141
@@ -141,22 +156,44 @@ static PyObject *PyFT2Image_as_rgba_str(PyFT2Image *self, PyObject *args, PyObje
141
156
const char *PyFT2Image_as_array__doc__ =
142
157
" x = image.as_array()\n "
143
158
" \n "
159
+ " [*Deprecated*]\n "
144
160
" Return the image buffer as a width x height numpy array of ubyte \n "
145
161
" \n " ;
146
162
147
163
static PyObject *PyFT2Image_as_array (PyFT2Image *self, PyObject *args, PyObject *kwds)
148
164
{
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
+ }
149
172
npy_intp dims[] = {(npy_intp)self->x ->get_height (), (npy_intp)self->x ->get_width () };
150
173
return PyArray_SimpleNewFromData (2 , dims, NPY_UBYTE, self->x ->get_buffer ());
151
174
}
152
175
153
176
static PyObject *PyFT2Image_get_width (PyFT2Image *self, PyObject *args, PyObject *kwds)
154
177
{
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
+ }
155
185
return PyLong_FromLong (self->x ->get_width ());
156
186
}
157
187
158
188
static PyObject *PyFT2Image_get_height (PyFT2Image *self, PyObject *args, PyObject *kwds)
159
189
{
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
+ }
160
197
return PyLong_FromLong (self->x ->get_height ());
161
198
}
162
199
0 commit comments