Gnats 4615: When exporting workspace or plots, jpeg format is not listed
Phil Weinstein -- 12-17-2008 -- HIT REFRESH -- Gnats Record / Public

SOLVED:  SEE SOLUTION

On the training machines, when you go to export a plot or the workspace image, it does not list jpg or jpeg as one of the supported file types. If you type in the extension, it works fine.

It does have both jpg extensions on my machine. What is different about the training machines?

The relevant code is highlighted:

File: Q3GUI/ExportImageDlg.cpp:

ExportImageDlg::ExportImageDlg(QWidget* parent,
                               const char* name, bool modal)
        : Q3FileDialog(parent, name, modal),
          _dir(""),
          ... ... ...
{
   ... ... ...

   // Add all the supported image types to the file filter.
   char (*imgFormat)(NULL);
   int selectedFilter(0);

   QList imgFormatList (QImageWriter::supportedImageFormats());
   for (int i = 0; i < imgFormatList.size(); ++i)
   {
      imgFormat = imgFormatList[i].data();

      QString filterString;
      filterString.sprintf("%s Image (*.%s)", imgFormat,
                           QString(imgFormat).lower().latin1());

      if (imgFormat == _format)
         selectedFilter = i;

      // The first item must be added with setFilters() to clear the filters
      // and tell the dialog that other filters may be added
      if (i == 0)
      {
         setFilters(filterString);
      }
      else
      {
         addFilter(filterString);
      }
   }
   // Set the static default filter
   setSelectedFilter(selectedFilter);

   ... ... ...
}

I have a question posted on the Qt Centre blog:

QImageWriter supportedImageFormats only sometimes includes JPEG. Why?

On some of our installations built with Qt 4.3.3, users are seeing the results of QImageWriter::supportedImageFormats to be only these items -- and this is a problem for us:

  • bmp Image (*.bmp)
  • png Image (*.png)
  • ppm Image (*.ppm)
  • xbm Image (*.xbm)
  • xpm Image (*.xpm)

On other installations, the following items are also shown:

  • jpeg Image (*.jpeg)
  • jpg Image (*.jpg)

Why might this be? And how can we make the JPEG options show up on all installations?

Message URL:
http://www.qtcentre.org/forum/f-qt-programming-2/t-qimagewriter-supportedimageformats-only-sometimes-includes-jpeg-why-17633.html

Q3GUI/ExportImageDlg:

ExportImageDlg.gif

Solution:

Copy the "jpeg" related files from a Qt4 development area, e.g. in C:\RiverWare\tools\Qt4\plugins\imageformats\ to a new imageformats subdirectory where the riverware.exe program exists:

ImageFormatsDir.gif

AllImageFormatsDir.gif