diff --git a/QtMeshViewer/Header/tga.h b/QtMeshViewer/Header/tga.h index ede8ac9..6e77435 100644 --- a/QtMeshViewer/Header/tga.h +++ b/QtMeshViewer/Header/tga.h @@ -3,7 +3,6 @@ #include #include -#include "..\Header\Profiler.h" QImage loadTga(QString filePath, bool &success) { @@ -47,7 +46,7 @@ QImage loadTga(QString filePath, bool &success) // jump to the data block fsPicture.seekg(ui32IDLength + ui32PaletteLength, std::ios_base::cur); - img = QImage(ui32Width, ui32Height, ui32BpP == 32? QImage::Format_RGBA8888 : QImage::Format_RGB888); + img = QImage(ui32Width, ui32Height, QImage::Format_RGBA8888); // uncompressed if (ui32PicType == 2 && (ui32BpP == 24 || ui32BpP == 32)) @@ -63,8 +62,11 @@ QImage loadTga(QString filePath, bool &success) int valr = vui8Pixels.at(y * ui32Width * ui32BpP / 8 + x * ui32BpP / 8 + 2); int valg = vui8Pixels.at(y * ui32Width * ui32BpP / 8 + x * ui32BpP / 8 + 1); int valb = vui8Pixels.at(y * ui32Width * ui32BpP / 8 + x * ui32BpP / 8); + int vala = 255; + if (ui32BpP == 32) + vala = vui8Pixels.at(y * ui32Width * ui32BpP / 8 + x * ui32BpP / 8 + 3); - QColor value(valr, valg, valb); + QColor value(valr, valg, valb, vala); img.setPixel(x, ui32Width - 1 - y, value.rgba()); } } @@ -93,7 +95,7 @@ QImage loadTga(QString filePath, bool &success) if (ui32BpP == 32) color.setRgba(qRgba(tempData[2], tempData[1], tempData[0], tempData[3])); else - color.setRgb(qRgb(tempData[2], tempData[1], tempData[0])); + color.setRgba(qRgba(tempData[2], tempData[1], tempData[0], 255)); img.setPixel(tmp_pixelIndex % ui32Width, ui32Height - 1 - (tmp_pixelIndex / ui32Width), color.rgba()); tmp_pixelIndex++; @@ -113,7 +115,7 @@ QImage loadTga(QString filePath, bool &success) if (ui32BpP == 32) color.setRgba(qRgba(tempData[2], tempData[1], tempData[0], tempData[3])); else - color.setRgb(qRgb(tempData[2], tempData[1], tempData[0])); + color.setRgba(qRgba(tempData[2], tempData[1], tempData[0], 255)); img.setPixel(tmp_pixelIndex % ui32Width, ui32Height - 1 - (tmp_pixelIndex / ui32Width), color.rgba()); tmp_pixelIndex++; @@ -125,14 +127,12 @@ QImage loadTga(QString filePath, bool &success) else { fsPicture.close(); - img = QImage(1, 1, QImage::Format_RGB32); - img.fill(Qt::red); success = false; return img; } fsPicture.close(); - success = true; return img; + } diff --git a/QtMeshViewer/Source/GeometryEngine.cpp b/QtMeshViewer/Source/GeometryEngine.cpp index a113718..331eaae 100644 --- a/QtMeshViewer/Source/GeometryEngine.cpp +++ b/QtMeshViewer/Source/GeometryEngine.cpp @@ -5,7 +5,6 @@ #include "..\Header\OutputDevice.h" #include -#include "../Header/Profiler.h" ///////////////////////////////////////////////////////////////////////// // constructor/destructor diff --git a/QtMeshViewer/Source/MshFile.cpp b/QtMeshViewer/Source/MshFile.cpp index 99cd6ce..0e063e8 100644 --- a/QtMeshViewer/Source/MshFile.cpp +++ b/QtMeshViewer/Source/MshFile.cpp @@ -3,7 +3,6 @@ #include "..\Header\OutputDevice.h" #include -#include "..\Header\Profiler.h" // helper function to save data from file to any variable type #define F2V(variableName) reinterpret_cast(&variableName)