From fd85716e21208ca214711376c68896a79d630690 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 4 Jan 2013 09:05:53 -0500 Subject: [PATCH] allow querying the bitmap texture underlying a 'Texture' object (if any) --- include/mitsuba/render/texture.h | 3 +++ src/librender/texture.cpp | 1 + src/textures/bitmap.cpp | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/include/mitsuba/render/texture.h b/include/mitsuba/render/texture.h index f53f325e..05108c39 100644 --- a/include/mitsuba/render/texture.h +++ b/include/mitsuba/render/texture.h @@ -74,6 +74,9 @@ public: /// Serialize to a binary data stream virtual void serialize(Stream *stream, InstanceManager *manager) const; + /// Return the underlying bitmap representation (if any) + virtual ref getBitmap() const; + MTS_DECLARE_CLASS() protected: Texture(const Properties &props); diff --git a/src/librender/texture.cpp b/src/librender/texture.cpp index 66797fb9..76221c71 100644 --- a/src/librender/texture.cpp +++ b/src/librender/texture.cpp @@ -47,6 +47,7 @@ Spectrum Texture::getMinimum() const { NotImplementedError("getMinimum"); } Spectrum Texture::getMaximum() const { NotImplementedError("getMaximum"); } bool Texture::isConstant() const { NotImplementedError("isConstant"); } bool Texture::usesRayDifferentials() const { NotImplementedError("usesRayDifferentials"); } +ref Texture::getBitmap() const { return NULL; } ref Texture::expand() { return this; diff --git a/src/textures/bitmap.cpp b/src/textures/bitmap.cpp index ba80bd21..21f2f292 100644 --- a/src/textures/bitmap.cpp +++ b/src/textures/bitmap.cpp @@ -400,6 +400,10 @@ public: return result; } + ref getBitmap() const { + return m_mipmap1.get() ? m_mipmap1->toBitmap() : m_mipmap3->toBitmap(); + } + Spectrum eval(const Point2 &uv, const Vector2 &d0, const Vector2 &d1) const { stats::filteredLookups.incrementBase(); ++stats::filteredLookups;