OSDN Git Service

[Qt][OSD][OpenGL][AVIO] Fix wrong color at one-board-computers.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 19 Feb 2019 17:10:43 +0000 (02:10 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 19 Feb 2019 17:10:43 +0000 (02:10 +0900)
[Qt][OpenGL] Fix not save screenshot with OpenGL renderers.(This issue didn't happen with OpenGL ES).

source/src/qt/gui/qt_gldraw.cpp
source/src/qt/gui/qt_glutil.cpp
source/src/qt/osd_screen.cpp

index 9a5e459..523b55e 100644 (file)
@@ -84,8 +84,6 @@ void GLDrawClass::resizeGL(int width, int height)
 
 void GLDrawClass::paintGL(void)
 {
-       SaveToPixmap(); // If save requested, then Save to Pixmap.
-       //qWarning("Test");
        if(extfunc != NULL) {
                if(delay_update) {
                        extfunc->setVirtualVramSize(vram_width, vram_height);
@@ -95,6 +93,7 @@ void GLDrawClass::paintGL(void)
                //extfunc->paintGL();
        }
        emit sig_draw_timing();
+       SaveToPixmap(); // If save requested, then Save to Pixmap.
 }
 
 scrntype_t* GLDrawClass::get_screen_buffer(int y)
@@ -115,11 +114,6 @@ void GLDrawClass::do_display_osd_leds(int lednum, bool onoff)
        }
 }
 
-//void GLDrawClass::paintEvent(QPaintEvent *ev)
-//{
-//     // Do Nothing.
-//     // http://doc.qt.io/qt-5/qopenglwidget.html#Threading
-//}
 
 #ifndef GL_MULTISAMPLE
 #define GL_MULTISAMPLE  0x809D
index 22756dc..06422a7 100644 (file)
@@ -343,7 +343,9 @@ void GLDrawClass::SaveToPixmap(void)
 {
        if(save_pixmap_req) {
                if(!filename_screen_pixmap.isEmpty()) {
-                       QImage snapshot = this->grabFramebuffer();
+                       //QImage snapshot = QImage(this->size(), QImage::Format_ARGB32_Premultiplied);
+                       //glReadPixels(0, 0, this->width(), this->height(), GL_RGBA, GL_UNSIGNED_BYTE, snapshot.bits());
+                       QImage snapshot = this->grabFramebuffer().convertToFormat(QImage::Format_RGB32);
                        snapshot.save(filename_screen_pixmap);
                }
                save_pixmap_req = false;
index 798327b..389d0c4 100644 (file)
@@ -361,8 +361,7 @@ int OSD_BASE::add_video_frames()
        if(using_flags->is_use_one_board_computer()) {
                //int size = vm_screen_buffer.pImage.byteCount();
                int i = counter;
-               rec_image_buffer = QImage(background_image);
-               QImage *video_result;
+               rec_image_buffer = background_image.rgbSwapped();
                if(p_glv->is_ready_to_map_vram_texture()) {
                        vm_screen_buffer.is_mapped = true;
                        vm_screen_buffer.glv = p_glv;
@@ -371,8 +370,6 @@ int OSD_BASE::add_video_frames()
                                if(p != NULL) {
                                        if(p != vm_screen_buffer.pImage.scanLine(y)) {
                                                memcpy(vm_screen_buffer.pImage.scanLine(y), p, vm_screen_buffer.pImage.width() * sizeof(scrntype_t));
-                                       } else {
-                                               memset(vm_screen_buffer.pImage.scanLine(y), 0x00, vm_screen_buffer.pImage.width() * sizeof(scrntype_t));
                                        }
                                } else {
                                        if(vm_screen_buffer.pImage.scanLine(y) != NULL) {
@@ -381,15 +378,15 @@ int OSD_BASE::add_video_frames()
                                }
                        }
                }
-               video_result = &(vm_screen_buffer.pImage);
+               QImage video_result = QImage(vm_screen_buffer.pImage);
 
                QRgb pixel;
-               int ww = video_result->width();
-               int hh = video_result->height();
+               int ww = video_result.width();
+               int hh = video_result.height();
                //printf("%d x %d\n", ww, hh);
                for(int yy = 0; yy < hh; yy++) {
                        for(int xx = 0; xx < ww; xx++) {
-                               pixel = video_result->pixel(xx, yy);
+                               pixel = video_result.pixel(xx, yy);
 #if defined(__LITTLE_ENDIAN__)
                                pixel |= 0xff000000;
                                if(pixel != 0xff000000) {
@@ -419,8 +416,6 @@ int OSD_BASE::add_video_frames()
                                if(p != NULL) {
                                        if(p != vm_screen_buffer.pImage.scanLine(y)) {
                                                memcpy(vm_screen_buffer.pImage.scanLine(y), p, vm_screen_buffer.pImage.width() * sizeof(scrntype_t));
-                                       } else {
-                                               memset(vm_screen_buffer.pImage.scanLine(y), 0x00, vm_screen_buffer.pImage.width() * sizeof(scrntype_t));
                                        }
                                } else {
                                        if(vm_screen_buffer.pImage.scanLine(y) != NULL) {