bool FormImageProp::loadFile(const QString &fileName) { QFileInfo fileInfo(fileName); QImage _image; // Targa support added if(fileInfo.completeSuffix().compare("tga") == 0){ TargaImage tgaImage; _image = tgaImage.read(fileName); }else{ QImageReader loadedImage(fileName); _image = loadedImage.read(); } if (_image.isNull()) { QMessageBox::information(this, QGuiApplication::applicationDisplayName(), tr("Cannot load %1.").arg(QDir::toNativeSeparators(fileName))); return false; } if(bOpenNormalMapMixer){ qDebug() << "<FormImageProp> Open normal mixer image:" << fileName; imageProp.glWidget_ptr->makeCurrent(); if(glIsTexture(imageProp.normalMixerInputTexId)) imageProp.glWidget_ptr->deleteTexture(imageProp.normalMixerInputTexId); imageProp.normalMixerInputTexId = imageProp.glWidget_ptr->bindTexture(_image,GL_TEXTURE_2D); ui->labelNormalMixerInfo->setText("Current image:"+ fileInfo.baseName()); emit imageChanged(); }else{ qDebug() << "<FormImageProp> Open image:" << fileName; imageName = fileInfo.baseName(); (*recentDir).setPath(fileName); image = _image; imageProp.init(image); //emit imageChanged(); emit imageLoaded(image.width(),image.height()); } return true; }
bool FormMaterialIndicesManager::loadFile(const QString &fileName) { QFileInfo fileInfo(fileName); QImage _image; // Targa support added if(fileInfo.completeSuffix().compare("tga") == 0){ TargaImage tgaImage; _image = tgaImage.read(fileName); }else{ QImageReader loadedImage(fileName); _image = loadedImage.read(); } if (_image.isNull()) { QMessageBox::information(this, QGuiApplication::applicationDisplayName(), tr("Cannot load material image %1.").arg(QDir::toNativeSeparators(fileName))); return false; } qDebug() << "<FormImageProp> Open material image:" << fileName; (*FormImageProp::recentDir).setPath(fileName); int mIndex = FBOImageProporties::currentMaterialIndeks; if(updateMaterials(_image)){ image = _image; imageProp.init(image); emit materialChanged(); FBOImageProporties::currentMaterialIndeks = mIndex; emit imageLoaded(image.width(),image.height()); // repaint all materials if(FBOImageProporties::currentMaterialIndeks != MATERIALS_DISABLED){ toggleMaterials(true); } } return true; }