From c41aebd1ebc15ee1e9a6800a38716e77d14cc904 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 27 Dec 2014 13:51:36 +0100 Subject: [PATCH] + fix conversion from Qi image to Inventor when image uses a color table --- src/Gui/BitmapFactory.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp index 4879aba908..f3effaf1fb 100644 --- a/src/Gui/BitmapFactory.cpp +++ b/src/Gui/BitmapFactory.cpp @@ -542,7 +542,25 @@ void BitmapFactoryInst::convert(const QImage& p, SoSFImage& img) const size[1] = p.height(); int buffersize = p.numBytes(); - int numcomponents = buffersize / ( size[0] * size[1] ); + int numcomponents = 0; + QVector table = p.colorTable(); + if (!table.isEmpty()) { + if (p.hasAlphaChannel()) { + if (p.allGray()) + numcomponents = 2; + else + numcomponents = 4; + } + else { + if (p.allGray()) + numcomponents = 1; + else + numcomponents = 3; + } + } + else { + numcomponents = buffersize / (size[0] * size[1]); + } // allocate image data img.setValue(size, numcomponents, NULL);