Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 875212e

Browse files
committed
exposed to_string for buffer_region
svn path=/trunk/matplotlib/; revision=2576
1 parent 1c5d5a9 commit 875212e

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

src/_backend_agg.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ GCAgg::_set_clip_rectangle( const Py::Object& gc) {
187187
}
188188

189189

190+
Py::Object BufferRegion::to_string(const Py::Tuple &args) {
191+
return Py::asObject(PyString_FromStringAndSize((const char*)aggbuf.data,aggbuf.height*aggbuf.stride));
192+
}
193+
194+
190195

191196

192197

@@ -2268,6 +2273,17 @@ Py::Object _backend_agg_module::new_renderer (const Py::Tuple &args,
22682273
return Py::asObject(new RendererAgg(width, height, dpi, debug));
22692274
}
22702275

2276+
2277+
void BufferRegion::init_type() {
2278+
behaviors().name("BufferRegion");
2279+
behaviors().doc("A wrapper to pass agg buffer objects to and from the python level");
2280+
2281+
add_varargs_method("to_string", &BufferRegion::to_string,
2282+
"to_string()");
2283+
2284+
}
2285+
2286+
22712287
void RendererAgg::init_type()
22722288
{
22732289
behaviors().name("RendererAgg");

src/_backend_agg.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ class BufferRegion : public Py::PythonExtension<BufferRegion> {
4949
BufferRegion( agg::buffer& aggbuf, const agg::rect &r) : aggbuf(aggbuf), rect(r) {}
5050
agg::buffer aggbuf;
5151
agg::rect rect;
52-
static void init_type(void) {
53-
behaviors().name("BufferRegion");
54-
behaviors().doc("A wrapper to pass agg buffer objects to and from the python level");
55-
}
52+
Py::Object to_string(const Py::Tuple &args);
5653

54+
static void init_type(void);
5755
virtual ~BufferRegion() {};
5856
};
5957

0 commit comments

Comments
 (0)