From 7f4ec5eaba8e40f27d7e414830b6766457a58da6 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Thu, 17 Jan 2013 00:45:22 -0500 Subject: [PATCH] improved python Bitmap bindings some more --- include/mitsuba/core/bitmap.h | 18 +++++++++--------- src/libpython/core.cpp | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/include/mitsuba/core/bitmap.h b/include/mitsuba/core/bitmap.h index e0841f80..b05a6197 100644 --- a/include/mitsuba/core/bitmap.h +++ b/include/mitsuba/core/bitmap.h @@ -393,15 +393,6 @@ public: /// Draw a rectangle with the specified position and size void drawRect(const Point2i &offset, const Vector2i &size, const Spectrum &value); - /** - * \brief Color balancing: apply the given scale factors to the - * red, green, and blue channels of the image - * - * When the image is not an \c EFloat16, \c EFloat32, or - * \c EFloat64-based RGB/RGBA image, the function throws an exception - */ - void colorBalance(Float r, Float g, Float b); - /// Draw a filled rectangle with the specified position and size void fillRect(Point2i offset, Vector2i size, const Spectrum &value); @@ -702,6 +693,15 @@ public: void accumulate(const Bitmap *bitmap, Point2i sourceOffset, Point2i targetOffset, Vector2i size); + /** + * \brief Color balancing: apply the given scale factors to the + * red, green, and blue channels of the image + * + * When the image is not an \c EFloat16, \c EFloat32, or + * \c EFloat64-based RGB/RGBA image, the function throws an exception + */ + void colorBalance(Float r, Float g, Float b); + /** * Apply a color transformation matrix to the contents of the bitmap * diff --git a/src/libpython/core.cpp b/src/libpython/core.cpp index 80b62dab..f5bd03e6 100644 --- a/src/libpython/core.cpp +++ b/src/libpython/core.cpp @@ -497,6 +497,25 @@ void bitmap_write(Bitmap *bitmap, Bitmap::EFileFormat fmt, Stream *stream) { bitmap->write(fmt, stream); } +ref bitmap_convert_1(Bitmap *bitmap, EPixelFormat pixelFormat, EComponentFormat componentFormat, + Float gamma, Float multiplier, Spectrum::EConversionIntent intent) { + return bitmap->convert(pixelFormat, componentFormat, gamma, multiplier, intent); +} + +ref bitmap_convert_2(Bitmap *bitmap, EPixelFormat pixelFormat, EComponentFormat componentFormat, + Float gamma, Float multiplier) { + return bitmap->convert(pixelFormat, componentFormat, gamma, multiplier); +} + +ref bitmap_convert_3(Bitmap *bitmap, EPixelFormat pixelFormat, EComponentFormat componentFormat, + Float gamma) { + return bitmap->convert(pixelFormat, componentFormat, gamma); +} + +ref bitmap_convert_4(Bitmap *bitmap, EPixelFormat pixelFormat, EComponentFormat componentFormat) { + return bitmap->convert(pixelFormat, componentFormat); +} + Transform transform_glOrthographic1(Float clipNear, Float clipFar) { return Transform::glOrthographic(clipNear, clipFar); } @@ -740,14 +759,15 @@ void export_core() { .def(bp::init()) .def(bp::init()) .def("clone", &Bitmap::clone, BP_RETURN_VALUE) + .def("clear", &Bitmap::clear) .def("separateChannel", &Bitmap::separateChannel, BP_RETURN_VALUE) .def("expand", &Bitmap::expand, BP_RETURN_VALUE) .def("flipVertically", &Bitmap::flipVertically) .def("crop", &Bitmap::crop) .def("applyMatrix", &bitmap_applyMatrix) + .def("colorBalance", &Bitmap::colorBalance) .def("accumulate", accumulate_1) .def("accumulate", accumulate_2) - .def("clear", &Bitmap::clear) .def("write", &bitmap_write) .def("setString", &Bitmap::setString) .def("getString", &Bitmap::getString, BP_RETURN_VALUE) @@ -762,9 +782,18 @@ void export_core() { .def("getBitsPerComponent", &Bitmap::getBitsPerComponent) .def("getBytesPerComponent", &Bitmap::getBytesPerComponent) .def("getBytesPerPixel", &Bitmap::getBytesPerPixel) + .def("getBufferSize", &Bitmap::getBufferSize) .def("getPixel", &Bitmap::getPixel, BP_RETURN_VALUE) .def("setPixel", &Bitmap::setPixel) - .def("getSize", &Bitmap::getSize, BP_RETURN_VALUE); + .def("drawHLine", &Bitmap::drawHLine) + .def("drawVLine", &Bitmap::drawVLine) + .def("drawRect", &Bitmap::drawRect) + .def("fillRect", &Bitmap::fillRect) + .def("getSize", &Bitmap::getSize, BP_RETURN_VALUE) + .def("convert", &bitmap_convert_1, BP_RETURN_VALUE) + .def("convert", &bitmap_convert_2, BP_RETURN_VALUE) + .def("convert", &bitmap_convert_3, BP_RETURN_VALUE) + .def("convert", &bitmap_convert_4, BP_RETURN_VALUE); BP_SETSCOPE(Bitmap_class); bp::enum_("EPixelFormat") @@ -793,6 +822,8 @@ void export_core() { .value("EPNG", Bitmap::EPNG) .value("EOpenEXR", Bitmap::EOpenEXR) .value("ETGA", Bitmap::ETGA) + .value("EPFM", Bitmap::EPFM) + .value("ERGBE", Bitmap::ERGBE) .value("EBMP", Bitmap::EBMP) .value("EJPEG", Bitmap::EJPEG) .value("EAuto", Bitmap::EAuto)