From 39e05f49d0fe58b42b36495950412e8d6b7673a2 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Mon, 28 Apr 2003 22:27:29 +0000 Subject: render scaled pixmap --- src/FbTk/TextureRender.cc | 31 ++++++++++++++++++++++--------- src/FbTk/TextureRender.hh | 5 +++-- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc index 1ad1b16..1f7d29f 100644 --- a/src/FbTk/TextureRender.cc +++ b/src/FbTk/TextureRender.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: TextureRender.cc,v 1.2 2003/01/10 01:02:02 fluxgen Exp $ +// $Id: TextureRender.cc,v 1.3 2003/04/28 22:27:29 fluxgen Exp $ #include "TextureRender.hh" @@ -97,8 +97,9 @@ TextureRender::~TextureRender() { Pixmap TextureRender::render(const FbTk::Texture &texture) { - - if (texture.type() & FbTk::Texture::PARENTRELATIVE) + if (texture.pixmap().drawable() != 0) + return renderPixmap(texture); + else if (texture.type() & FbTk::Texture::PARENTRELATIVE) return ParentRelative; else if (texture.type() & FbTk::Texture::SOLID) return renderSolid(texture); @@ -257,6 +258,18 @@ Pixmap TextureRender::renderGradient(const FbTk::Texture &texture) { } +Pixmap TextureRender::renderPixmap(const FbTk::Texture &src_texture) { + if (width != src_texture.pixmap().width() || + height != src_texture.pixmap().height()) { + // copy src_texture's pixmap and + // scale to fit our size + FbPixmap new_pm(src_texture.pixmap()); + new_pm.scale(width, height); + return new_pm.release(); + } + // return copy of pixmap + return FbPixmap(src_texture.pixmap()).release(); +} XImage *TextureRender::renderXImage() { Display *disp = FbTk::App::instance()->display(); @@ -488,12 +501,12 @@ XImage *TextureRender::renderXImage() { nberr = terr; } - delete [] rerr; - delete [] gerr; - delete [] berr; - delete [] nrerr; - delete [] ngerr; - delete [] nberr; + delete [] rerr; + delete [] gerr; + delete [] berr; + delete [] nrerr; + delete [] ngerr; + delete [] nberr; #endif // ORDEREDPSUEDO } break; diff --git a/src/FbTk/TextureRender.hh b/src/FbTk/TextureRender.hh index 5b77753..f07a5c7 100644 --- a/src/FbTk/TextureRender.hh +++ b/src/FbTk/TextureRender.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: TextureRender.hh,v 1.1 2003/01/09 21:09:49 fluxgen Exp $ +// $Id: TextureRender.hh,v 1.2 2003/04/28 22:27:29 fluxgen Exp $ #ifndef FBTK_TEXTURRENDER_HH #define FBTK_TEXTURRENDER_HH @@ -51,7 +51,8 @@ public: Pixmap renderSolid(const FbTk::Texture &src_texture); /// render gradient texture to pixmap Pixmap renderGradient(const FbTk::Texture &src_texture); - + /// scales and renders a pixmap + Pixmap renderPixmap(const FbTk::Texture &src_texture); private: /** Render to pixmap -- cgit v0.11.2