From 0068b838b2821d90047695c7707dc859aaf9ab10 Mon Sep 17 00:00:00 2001 From: atlante45 Date: Fri, 30 Aug 2013 15:56:28 -0700 Subject: [PATCH] Fixed importer crashing on non ARGB32 png. --- libraries/voxels/src/VoxelTree.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/voxels/src/VoxelTree.cpp b/libraries/voxels/src/VoxelTree.cpp index b17200448b..c673755e82 100644 --- a/libraries/voxels/src/VoxelTree.cpp +++ b/libraries/voxels/src/VoxelTree.cpp @@ -1614,8 +1614,10 @@ bool VoxelTree::readFromSquareARGB32Pixels(const char* filename) { QImage pngImage = QImage(filename); - for (int x = 0; x < pngImage.width() * pngImage.height(); ++x) { - minAlpha = std::min(qAlpha(pngImage.color(x)) , minAlpha); + for (int i = 0; i < pngImage.width(); ++i) { + for (int j = 0; j < pngImage.height(); ++j) { + minAlpha = std::min(qAlpha(pngImage.pixel(i, j)) , minAlpha); + } } int maxSize = std::max(pngImage.width(), pngImage.height());