Commit b1f38f17 authored by Dirk Wilden's avatar Dirk Wilden

after writing a TGA image loader for an hour I found out that Qt has a hidden...

after writing a TGA image loader for an hour I found out that Qt has a hidden feature to load TGA using a QPixmap. At least works with QT4.7. If not I can commit my tga loader.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@10561 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 9f3c4847
......@@ -58,8 +58,6 @@
#include <math.h>
#define TEXTUREDATA "TextureData"
void TextureControlPlugin::slotTextureAdded( QString _textureName , QString _filename , uint _dimension , int _id)
......@@ -207,11 +205,20 @@ bool TextureControlPlugin::getImage( QString _fileName, QImage& _image ) {
else
loadFilename = OpenFlipper::Options::textureDirStr() + QDir::separator() + _fileName;
if ( !_image.load( loadFilename ) ){
_image.load(OpenFlipper::Options::textureDirStr() + QDir::separator() + "unknown.png");
return false;
}
//qimage cannot handle tga directly
if ( QFileInfo(loadFilename).suffix().toLower() == "tga" ){
QPixmap pic(loadFilename);
_image = pic.toImage();
} else {
//load the image
if ( !_image.load( loadFilename ) ){
_image.load(OpenFlipper::Options::textureDirStr() + QDir::separator() + "unknown.png");
return false;
}
}
return true;
}
......
......@@ -54,8 +54,6 @@
#include <ObjectTypes/PolyMesh/PolyMesh.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
texturePropertiesWidget::texturePropertiesWidget(QWidget *parent)
: QDialog(parent)
{
......@@ -339,21 +337,20 @@ void texturePropertiesWidget::slotChangeImage() {
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"),
OpenFlipper::Options::currentTextureDirStr(),
tr("Images (*.png *.xpm *.jpg)"));
tr("Images (*.png *.xpm *.jpg, *.tga)"));
if ( QFile(fileName).exists() ){
QFileInfo fileInfo(fileName);
OpenFlipper::Options::currentTextureDir( fileInfo.absolutePath() );
imageLabel->setPixmap( QPixmap(fileName) );
imageLabel->setPixmap( fileName );
imageLabel->setScaledContents(true);
fileLabel->setText( "File: " + fileName );
currentImage_ = fileName;
image_ = imageLabel->pixmap()->toImage();
#ifdef WITH_QWT
functionPlot_->setImage( &image_ );
functionPlot_->replot();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment