4646
4747#include " agg_basics.h"
4848#include " _backend_agg.h"
49- #include " _transforms.h"
5049#include " agg_pixfmt_rgba.h"
5150#include " util/agg_color_conv_rgb8.h"
51+ #include " agg_py_transforms.h"
5252
5353#include < wx/image.h>
5454#include < wx/bitmap.h>
5555#include < wx/wxPython/wxPython.h>
5656
5757
5858// forward declarations
59- static wxImage *convert_agg2image (RendererAgg *aggRenderer, Bbox * clipbox);
60- static wxBitmap *convert_agg2bitmap (RendererAgg *aggRenderer, Bbox * clipbox);
59+ static wxImage *convert_agg2image (RendererAgg *aggRenderer, Py::Object clipbox);
60+ static wxBitmap *convert_agg2bitmap (RendererAgg *aggRenderer, Py::Object clipbox);
6161
6262
6363// the extension module
@@ -94,9 +94,7 @@ class _wxagg_module : public Py::ExtensionModule<_wxagg_module>
9494 RendererAgg* aggRenderer = static_cast <RendererAgg*>(
9595 args[0 ].getAttr (" _renderer" ).ptr ());
9696
97- Bbox *clipbox = NULL ;
98- if (args[1 ].ptr () != Py_None)
99- clipbox = static_cast <Bbox*>(args[1 ].ptr ());
97+ Py::Object clipbox = args[1 ];
10098
10199 // convert the buffer
102100 wxImage *image = convert_agg2image (aggRenderer, clipbox);
@@ -118,9 +116,7 @@ class _wxagg_module : public Py::ExtensionModule<_wxagg_module>
118116 RendererAgg* aggRenderer = static_cast <RendererAgg*>(
119117 args[0 ].getAttr (" _renderer" ).ptr ());
120118
121- Bbox *clipbox = NULL ;
122- if (args[1 ].ptr () != Py_None)
123- clipbox = static_cast <Bbox*>(args[1 ].ptr ());
119+ Py::Object clipbox = args[1 ];
124120
125121 // convert the buffer
126122 wxBitmap *bitmap = convert_agg2bitmap (aggRenderer, clipbox);
@@ -141,7 +137,7 @@ class _wxagg_module : public Py::ExtensionModule<_wxagg_module>
141137// Implementation Functions
142138//
143139
144- static wxImage *convert_agg2image (RendererAgg *aggRenderer, Bbox * clipbox)
140+ static wxImage *convert_agg2image (RendererAgg *aggRenderer, Py::Object clipbox)
145141{
146142 int srcWidth = 1 ;
147143 int srcHeight = 1 ;
@@ -150,19 +146,16 @@ static wxImage *convert_agg2image(RendererAgg *aggRenderer, Bbox *clipbox)
150146 bool deleteSrcBuffer = false ;
151147 agg::int8u *srcBuffer = NULL ;
152148
153- if (clipbox == NULL ) {
149+ double l, b, r, t;
150+
151+ if (!py_convert_bbox (clipbox.ptr (), l, b, r, t)) {
154152 // Convert everything: rgba => rgb -> image
155153 srcBuffer = aggRenderer->pixBuffer ;
156154 srcWidth = (int ) aggRenderer->get_width ();
157155 srcHeight = (int ) aggRenderer->get_height ();
158156 srcStride = (int ) aggRenderer->get_width ()*4 ;
159157 } else {
160158 // Convert a region: rgba => clipped rgba => rgb -> image
161- double l = clipbox->ll_api ()->x_api ()->val () ;
162- double b = clipbox->ll_api ()->y_api ()->val ();
163- double r = clipbox->ur_api ()->x_api ()->val () ;
164- double t = clipbox->ur_api ()->y_api ()->val () ;
165-
166159 srcWidth = (int ) (r-l);
167160 srcHeight = (int ) (t-b);
168161 srcStride = srcWidth*4 ;
@@ -230,7 +223,7 @@ static wxImage *convert_agg2image(RendererAgg *aggRenderer, Bbox *clipbox)
230223}
231224
232225
233- static wxBitmap *convert_agg2bitmap (RendererAgg *aggRenderer, Bbox * clipbox)
226+ static wxBitmap *convert_agg2bitmap (RendererAgg *aggRenderer, Py::Object clipbox)
234227{
235228 // Convert everything: rgba => rgb -> image => bitmap
236229 // Convert a region: rgba => clipped rgba => rgb -> image => bitmap
0 commit comments