| 123 | |
| 124 | template <typename T> |
| 125 | static auto GetRawDataAsBuffer(T &self) { |
| 126 | auto *data = reinterpret_cast<unsigned char *>(self.data()); |
| 127 | auto size = static_cast<Py_ssize_t>(sizeof(typename T::value_type) * self.size()); |
| 128 | #if PY_MAJOR_VERSION >= 3 |
| 129 | auto *ptr = PyMemoryView_FromMemory(reinterpret_cast<char *>(data), size, PyBUF_READ); |
| 130 | #else |
| 131 | auto *ptr = PyBuffer_FromMemory(data, size); |
| 132 | #endif |
| 133 | return boost::python::object(boost::python::handle<>(ptr)); |
| 134 | } |
| 135 | |
| 136 | template <typename T> |
| 137 | static void ConvertImage(T &self, EColorConverter cc) { |