8000 Adding possibility to choose dpi when saving · lava/matplotlib-cpp@3af24b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3af24b4

Browse files
raphael.viards@magellium.frlava
raphael.viards@magellium.fr
authored andcommitted
Adding possibility to choose dpi when saving
1 parent 2bf4f26 commit 3af24b4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

matplotlibcpp.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,7 +2439,7 @@ inline void pause(Numeric interval)
24392439
Py_DECREF(res);
24402440
}
24412441

2442-
inline void save(const std::string& filename)
2442+
inline void save(const std::string& filename, const int dpi=0)
24432443
{
24442444
detail::_interpreter::get();
24452445

@@ -2448,10 +2448,18 @@ inline void save(const std::string& filename)
24482448
PyObject* args = PyTuple_New(1);
24492449
PyTuple_SetItem(args, 0, pyfilename);
24502450

2451-
PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_save, args);
2451+
PyObject* kwargs = PyDict_New();
2452+
2453+
if(dpi > 0)
2454+
{
2455+
PyDict_SetItemString(kwargs, "dpi", PyLong_FromLong(dpi));
2456+
}
2457+
2458+
PyObject* res = PyObject_Call(detail::_interpreter::get().s_python_function_save, args, kwargs);
24522459
if (!res) throw std::runtime_error("Call to save() failed.");
24532460

24542461
Py_DECREF(args);
2462+
Py_DECREF(kwargs);
24552463
Py_DECREF(res);
24562464
}
24572465

0 commit comments

Comments
 (0)
0