Changeset - d7edbe56b125
[Not reviewed]
default
0 3 0
Roeland Merks - 15 years ago 2010-11-26 14:56:40
roeland.merks@cwi.nl
The snapshot feature stopped working on Windows. The problem was in MainBase::Save, where the "format" argument was added to "image->save". On Windows the file format must be given in Capitals and in specific formats (e.g. TIFF works, TIF not).

It is much safer to leave the 'format' argument out and let the system guess the format from the file extension.

--
user: Roeland Merks <roeland.merks@cwi.nl>
branch 'default'
changed src/canvas.cpp
changed src/mainbase.cpp
changed src/mainbase.h
3 files changed with 19 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/canvas.cpp
Show inline comments
 
@@ -718,7 +718,7 @@ void Main::snapshot()
 
  Q3FileDialog *fd = new Q3FileDialog( this, "Save snapshot", TRUE );
 
  fd->setDir(par.datadir);
 
  fd->setMode( Q3FileDialog::AnyFile );
 
  fd->setFilter( "Image files (*.pdf *.png *.jpg *.tif *.bpm)");
 
  fd->setFilter( "Image files (*.pdf *.png *.jpg *.tif)");
 
  QString fileName;
 

	
 
  if ( fd->exec() == QDialog::Accepted ) {
 
@@ -750,8 +750,12 @@ void Main::snapshot()
 
    } else {
 

	
 
      // Save bitmaps at 1024x768
 
      Save((const char *)fileName, extension, 1024, 768);
 
      QString status_message = QString("Wrote snapshot to %1").arg(fileName);
 
      QString status_message;
 
      if (Save((const char *)fileName, extension, 1024, 768)==0) {
 
	status_message = QString("Wrote snapshot to %1").arg(fileName);
 
      } else {
 
	status_message = QString("Error writing snapshot to %1").arg(fileName);
 
      }
 
      cerr << status_message.toStdString() << endl;
 
      statusBar()->showMessage(status_message);
 

	
src/mainbase.cpp
Show inline comments
 
@@ -319,7 +319,7 @@ void MainBase::XMLReadSettings(xmlNode *
 
  }
 
}
 

	
 
void MainBase::Save(const char *fname, const char *format, int sizex, int sizey)
 
int MainBase::Save(const char *fname, const char *format, int sizex, int sizey)
 
{
 

	
 
  Vector ll,ur;
 
@@ -327,15 +327,15 @@ void MainBase::Save(const char *fname, c
 

	
 
  if (QString(fname).isEmpty()) {
 
    MyWarning::warning("No output filename given. Saving nothing.\n");
 
    return;
 
    return 1;
 
  }
 

	
 
  ll*=Cell::Magnification(); ur*=Cell::Magnification();
 

	
 
  // give the leaf some space
 
  Vector border = ((ur-ll)/5.);
 

	
 
  if (!QString(format).contains("pdf", Qt::CaseInsensitive)) {
 
  
 
  if (!QString(format).contains("PDF", Qt::CaseInsensitive)) {
 

	
 
    QImage *image = new QImage(QSize(sizex, sizey), QImage::Format_RGB32);
 
    image->fill(QColor(Qt::white).rgb());
 
@@ -344,9 +344,12 @@ void MainBase::Save(const char *fname, c
 
#ifdef QDEBUG
 
    qDebug() << "Native Image Filename: " << QDir::toNativeSeparators(QString(fname)) << endl;
 
#endif
 
    if (!image->save(QDir::toNativeSeparators(QString(fname)), format)) {
 
      MyWarning::warning("Image not saved successfully. Is the disk full or the extension not recognized?");
 
    }
 
    if (!image->save(QDir::toNativeSeparators(QString(fname)))) { // please do not add "format" here! It is much better to have the system guess the file format from the extension. That prevents loads of cross-platform problems.
 
      MyWarning::warning("Image '%s' not saved successfully. Is the disk full or the extension not recognized?",fname);
 
      delete painter;
 
      delete image;
 
      return 1;
 
    } 
 
    delete painter;
 
    delete image;
 
  } else {
 
@@ -358,6 +361,7 @@ void MainBase::Save(const char *fname, c
 
    
 
    cerr << "Rendering to printer\n";
 
  }
 
  return 0;
 
}
 

	
 
void MainBase::CutSAM()
src/mainbase.h
Show inline comments
 
@@ -96,7 +96,7 @@ class MainBase  {
 

	
 
  virtual double getFluxArrowsize(void) { return 10.;}
 

	
 
  void Save(const char *fname, const char *format, int sizex=640, int sizey=480);
 
  int Save(const char *fname, const char *format, int sizex=640, int sizey=480);
 
  void CutSAM(void);
 

	
 
  void Plot(int resize_stride=10);
0 comments (0 inline, 0 general)