@@ -59,17 +59,14 @@ PyRendererAgg_draw_path(RendererAgg *self,
59
59
60
60
static void
61
61
PyRendererAgg_draw_text_image (RendererAgg *self,
62
- py::array_t <agg::int8u, py::array::c_style> image_obj,
62
+ py::array_t <agg::int8u, py::array::c_style | py::array::forcecast > image_obj,
63
63
double x,
64
64
double y,
65
65
double angle,
66
66
GCAgg &gc)
67
67
{
68
- numpy::array_view<agg::int8u, 2 > image;
69
-
70
- if (!image.converter_contiguous (image_obj.ptr (), &image)) {
71
- throw py::error_already_set ();
72
- }
68
+ // TODO: This really shouldn't be mutable, but Agg's renderer buffers aren't const.
69
+ auto image = image_obj.mutable_unchecked <2 >();
73
70
74
71
self->draw_text_image (gc, image, x, y, angle);
75
72
}
@@ -98,13 +95,10 @@ PyRendererAgg_draw_image(RendererAgg *self,
98
95
GCAgg &gc,
99
96
double x,
100
97
double y,
101
- py::array_t <agg::int8u, py::array::c_style> image_obj)
98
+ py::array_t <agg::int8u, py::array::c_style | py::array::forcecast > image_obj)
102
99
{
103
- numpy::array_view<agg::int8u, 3 > image;
104
-
105
- if (!image.set (image_obj.ptr ())) {
106
- throw py::error_already_set ();
107
- }
100
+ // TODO: This really shouldn't be mutable, but Agg's renderer buffers aren't const.
101
+ auto image = image_obj.mutable_unchecked <3 >();
108
102
109
103
x = mpl_round (x);
110
104
y = mpl_round (y);
@@ -179,21 +173,18 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
179
173
agg::trans_affine master_transform,
180
174
unsigned int mesh_width,
181
175
unsigned int mesh_height,
182
- py::object coordinates_obj,
176
+ py::array_t < double , py::array::c_style | py::array::forcecast> coordinates_obj,
183
177
py::object offsets_obj,
184
178
agg::trans_affine offset_trans,
185
179
py::object facecolors_obj,
186
180
bool antialiased,
187
181
py::object edgecolors_obj)
188
182
{
189
- numpy::array_view<const double , 3 > coordinates;
190
183
numpy::array_view<const double , 2 > offsets;
191
184
numpy::array_view<const double , 2 > facecolors;
192
185
numpy::array_view<const double , 2 > edgecolors;
193
186
194
- if (!coordinates.converter (coordinates_obj.ptr (), &coordinates)) {
195
- throw py::error_already_set ();
196
- }
187
+ auto coordinates = coordinates_obj.mutable_unchecked <3 >();
197
188
if (!convert_points (offsets_obj.ptr (), &offsets)) {
198
189
throw py::error_already_set ();
199
190
}
@@ -219,19 +210,12 @@ PyRendererAgg_draw_quad_mesh(RendererAgg *self,
219
210
static void
220
211
PyRendererAgg_draw_gouraud_triangles (RendererAgg *self,
221
212
GCAgg &gc,
222
- py::object points_obj,
223
- py::object colors_obj,
213
+ py::array_t < double > points_obj,
214
+ py::array_t < double > colors_obj,
224
215
agg::trans_affine trans)
225
216
{
226
- numpy::array_view<const double , 3 > points;
227
- numpy::array_view<const double , 3 > colors;
228
-
229
- if (!points.converter (points_obj.ptr (), &points)) {
230
- throw py::error_already_set ();
231
- }
232
- if (!colors.converter (colors_obj.ptr (), &colors)) {
233
- throw py::error_already_set ();
234
- }
217
+ auto points = points_obj.unchecked <3 >();
218
+ auto colors = colors_obj.unchecked <3 >();
235
219
236
220
self->draw_gouraud_triangles (gc, points, colors, trans);
237
221
}
0 commit comments