diff --git a/src/Mod/Material/Gui/BaseDelegate.cpp b/src/Mod/Material/Gui/BaseDelegate.cpp index 12291aaf93..cf7b8cf375 100644 --- a/src/Mod/Material/Gui/BaseDelegate.cpp +++ b/src/Mod/Material/Gui/BaseDelegate.cpp @@ -126,7 +126,7 @@ void BaseDelegate::paintImage(QPainter* painter, QImage img; if (!propertyValue.isEmpty()) { QByteArray by = QByteArray::fromBase64(propertyValue.toUtf8()); - img = QImage::fromData(by, "PNG").scaled(64, 64, Qt::KeepAspectRatio); + img = QImage::fromData(by).scaled(64, 64, Qt::KeepAspectRatio); } QRect target(option.rect); if (target.width() > target.height()) { diff --git a/src/Mod/Material/Gui/ImageEdit.cpp b/src/Mod/Material/Gui/ImageEdit.cpp index 4629b3b053..5a0367b85a 100644 --- a/src/Mod/Material/Gui/ImageEdit.cpp +++ b/src/Mod/Material/Gui/ImageEdit.cpp @@ -134,7 +134,7 @@ ImageEdit::ImageEdit(const QString& propertyName, QString value = _property->getString(); if (!value.isEmpty()) { QByteArray by = QByteArray::fromBase64(value.toUtf8()); - QImage img = QImage::fromData(by, "PNG"); + QImage img = QImage::fromData(by); _pixmap = QPixmap::fromImage(img); } showPixmap(); diff --git a/src/Mod/Material/Gui/MaterialsEditor.cpp b/src/Mod/Material/Gui/MaterialsEditor.cpp index 1375a308cb..44d33e5d06 100644 --- a/src/Mod/Material/Gui/MaterialsEditor.cpp +++ b/src/Mod/Material/Gui/MaterialsEditor.cpp @@ -940,12 +940,11 @@ bool MaterialsEditor::updateTexturePreview() const try { auto property = _material->getAppearanceProperty(QStringLiteral("TextureImage")); if (!property->isNull()) { - // Base::Console().log("Has 'TextureImage'\n"); auto propertyValue = property->getString(); if (!propertyValue.isEmpty()) { QByteArray by = QByteArray::fromBase64(propertyValue.toUtf8()); - image = QImage::fromData(by, "PNG"); //.scaled(64, 64, Qt::KeepAspectRatio); - hasImage = true; + image = QImage::fromData(by); + hasImage = !image.isNull(); } } } @@ -962,9 +961,11 @@ bool MaterialsEditor::updateTexturePreview() const if (!image.load(filePath)) { Base::Console().log("Unable to load image '%s'\n", filePath.toStdString().c_str()); - // return; // ??? + hasImage = false; + } + else { + hasImage = !image.isNull(); } - hasImage = true; } } catch (const Materials::PropertyNotFound&) {