From 880d00256883b455dbfb7dbf8a2845d69013f958 Mon Sep 17 00:00:00 2001 From: Kent <642238553@qq.com> Date: Tue, 3 Sep 2019 15:30:43 +0800 Subject: [PATCH 1/3] seems fixed this --- src/osgPlugins/tiff/ReaderWriterTIFF.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp index 4f9abef1b..6262a6e76 100644 --- a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp +++ b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp @@ -809,20 +809,19 @@ class ReaderWriterTIFF : public osgDB::ReaderWriter int t = height_ret; int r = 1; - int internalFormat = numComponents_ret; - unsigned int pixelFormat = numComponents_ret == 1 ? GL_LUMINANCE : numComponents_ret == 2 ? GL_LUMINANCE_ALPHA : numComponents_ret == 3 ? GL_RGB : numComponents_ret == 4 ? GL_RGBA : (GLenum)-1; - unsigned int dataType = bitspersample_ret == 8 ? GL_UNSIGNED_BYTE : bitspersample_ret == 16 ? GL_UNSIGNED_SHORT : bitspersample_ret == 32 ? GL_FLOAT : (GLenum)-1; + int internalFormat = pixelFormat; + osg::Image* pOsgImage = new osg::Image; pOsgImage->setImage(s,t,r, internalFormat, From df087b9524def613f0540a4733ad4048b49b34fe Mon Sep 17 00:00:00 2001 From: Kent <642238553@qq.com> Date: Tue, 3 Sep 2019 15:54:58 +0800 Subject: [PATCH 2/3] may be better --- src/osgPlugins/tiff/ReaderWriterTIFF.cpp | 36 +++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp index 6262a6e76..510fdb981 100644 --- a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp +++ b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp @@ -820,7 +820,41 @@ class ReaderWriterTIFF : public osgDB::ReaderWriter bitspersample_ret == 16 ? GL_UNSIGNED_SHORT : bitspersample_ret == 32 ? GL_FLOAT : (GLenum)-1; - int internalFormat = pixelFormat; + int internalFormat = 0; + switch (pixelFormat) { + case GL_LUMINANCE: { + switch (dataType) { + case GL_UNSIGNED_BYTE: internalFormat = GL_LUMINANCE8UI_EXT; break; + case GL_UNSIGNED_SHORT: internalFormat = GL_LUMINANCE16UI_EXT; break; + case GL_FLOAT : internalFormat = GL_LUMINANCE32F_ARB; break; + } + break; + } + case GL_LUMINANCE_ALPHA: { + switch (dataType) { + case GL_UNSIGNED_BYTE: internalFormat = GL_LUMINANCE_ALPHA8UI_EXT; break; + case GL_UNSIGNED_SHORT: internalFormat = GL_LUMINANCE_ALPHA16UI_EXT; break; + case GL_FLOAT: internalFormat = GL_LUMINANCE_ALPHA32F_ARB; break; + } + break; + } + case GL_RGB: { + switch (dataType) { + case GL_UNSIGNED_BYTE: internalFormat = GL_RGB8UI_EXT; break; + case GL_UNSIGNED_SHORT: internalFormat = GL_RGB16UI_EXT; break; + case GL_FLOAT: internalFormat = GL_RGB32F_ARB; break; + } + break; + } + case GL_RGBA : { + switch (dataType) { + case GL_UNSIGNED_BYTE: internalFormat = GL_RGBA8UI_EXT; break; + case GL_UNSIGNED_SHORT: internalFormat = GL_RGBA16UI_EXT; break; + case GL_FLOAT: internalFormat = GL_RGBA32F_ARB; break; + } + break; + } + } osg::Image* pOsgImage = new osg::Image; pOsgImage->setImage(s,t,r, From 7bb44d7e188785f34542833d84378c99146f5b9d Mon Sep 17 00:00:00 2001 From: Kent <642238553@qq.com> Date: Tue, 3 Sep 2019 16:11:14 +0800 Subject: [PATCH 3/3] emmmmmmm --- src/osgPlugins/tiff/ReaderWriterTIFF.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp index 510fdb981..034bdd88e 100644 --- a/src/osgPlugins/tiff/ReaderWriterTIFF.cpp +++ b/src/osgPlugins/tiff/ReaderWriterTIFF.cpp @@ -824,8 +824,8 @@ class ReaderWriterTIFF : public osgDB::ReaderWriter switch (pixelFormat) { case GL_LUMINANCE: { switch (dataType) { - case GL_UNSIGNED_BYTE: internalFormat = GL_LUMINANCE8UI_EXT; break; - case GL_UNSIGNED_SHORT: internalFormat = GL_LUMINANCE16UI_EXT; break; + case GL_UNSIGNED_BYTE: internalFormat = GL_LUMINANCE8; break; + case GL_UNSIGNED_SHORT: internalFormat = GL_LUMINANCE16; break; case GL_FLOAT : internalFormat = GL_LUMINANCE32F_ARB; break; } break; @@ -840,16 +840,16 @@ class ReaderWriterTIFF : public osgDB::ReaderWriter } case GL_RGB: { switch (dataType) { - case GL_UNSIGNED_BYTE: internalFormat = GL_RGB8UI_EXT; break; - case GL_UNSIGNED_SHORT: internalFormat = GL_RGB16UI_EXT; break; + case GL_UNSIGNED_BYTE: internalFormat = GL_RGB8; break; + case GL_UNSIGNED_SHORT: internalFormat = GL_RGB16; break; case GL_FLOAT: internalFormat = GL_RGB32F_ARB; break; } break; } case GL_RGBA : { switch (dataType) { - case GL_UNSIGNED_BYTE: internalFormat = GL_RGBA8UI_EXT; break; - case GL_UNSIGNED_SHORT: internalFormat = GL_RGBA16UI_EXT; break; + case GL_UNSIGNED_BYTE: internalFormat = GL_RGBA8; break; + case GL_UNSIGNED_SHORT: internalFormat = GL_RGBA16; break; case GL_FLOAT: internalFormat = GL_RGBA32F_ARB; break; } break;