From 7301d1505a3f8794d34c4700d697cc594564f2a6 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 14 May 2002 09:34:11 +0000 Subject: [PATCH] Added osg::Image::flipHorziontal and flipVertical, submitted by Brede Johansen. --- include/osg/Image | 6 +++++ src/osg/Image.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/include/osg/Image b/include/osg/Image index 610cc6403..2e9b70ed5 100644 --- a/include/osg/Image +++ b/include/osg/Image @@ -109,6 +109,12 @@ class SG_EXPORT Image : public Object if (!_data) return NULL; return _data+(column*getPixelSizeInBits())/8+row*getRowSizeInBytes()+image*getImageSizeInBytes(); } + + /** Flip the image horizontally.*/ + void flipHorizontal(int image=0); + + /** Flip the image vertically.*/ + void flipVertical(int image=0); /** Ensure image dimensions are a power of two. diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 86de0a53a..195484859 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -83,9 +83,9 @@ void Image::setFileName(const std::string& fileName) #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #endif -const bool Image::isPackedType(GLenum format) +const bool Image::isPackedType(GLenum type) { - switch(format) + switch(type) { case(GL_UNSIGNED_BYTE_3_3_2): case(GL_UNSIGNED_BYTE_2_3_3_REV): @@ -103,9 +103,9 @@ const bool Image::isPackedType(GLenum format) } } -const unsigned int Image::computeNumComponents(GLenum type) +const unsigned int Image::computeNumComponents(GLenum format) { - switch(type) + switch(format) { case(GL_COLOR_INDEX): return 1; case(GL_STENCIL_INDEX): return 1; @@ -334,6 +334,67 @@ void Image::scaleImage(const int s,const int t,const int r) ++_modifiedTag; } +void Image::flipHorizontal(int image) +{ + if (_data==NULL) + { + notify(WARN) << "Error Image::flipVertical() do not succeed : cannot flip NULL image."<