372 uchar* imagedata = g_win->R ()->screencap (w, h); |
372 uchar* imagedata = g_win->R ()->screencap (w, h); |
373 |
373 |
374 // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. |
374 // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. |
375 QImage img = QImage (imagedata, w, h, QImage::Format_ARGB32).rgbSwapped ().mirrored (); |
375 QImage img = QImage (imagedata, w, h, QImage::Format_ARGB32).rgbSwapped ().mirrored (); |
376 |
376 |
377 str root = basename (g_curfile->m_filename.chars ()); |
377 str root = basename (g_curfile->m_filename); |
378 if (root.substr (~root - 4, -1) == ".dat") |
378 if (~root >= 4 && root.substr (~root - 4, -1) == ".dat") |
379 root -= 4; |
379 root -= 4; |
380 |
380 |
381 str defaultname = (~root > 0) ? fmt ("%s.png", root.chars ()) : ""; |
381 str defaultname = (~root > 0) ? fmt ("%s.png", root.c ()) : ""; |
382 str fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, |
382 str fname = QFileDialog::getSaveFileName (g_win, "Save Screencap", defaultname, |
383 "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); |
383 "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); |
384 |
384 |
385 if (~fname > 0 && !img.save (fname)) |
385 if (~fname > 0 && !img.save (fname)) |
386 critical (fmt ("Couldn't open %s for writing to save screencap: %s", fname.chars(), strerror (errno))); |
386 critical (fmt ("Couldn't open %s for writing to save screencap: %s", fname.c (), strerror (errno))); |
387 |
387 |
388 delete[] imagedata; |
388 delete[] imagedata; |
389 } |
389 } |
390 |
390 |
391 // ========================================================================================================================================= |
391 // ========================================================================================================================================= |