]> git.cworth.org Git - apitrace/blobdiff - gui/imageviewer.cpp
Use skiplist-based FastCallSet within trace::CallSet
[apitrace] / gui / imageviewer.cpp
index 7b1e425f3e64ef2438d7d9c8e43ea5fbb6189e75..1a1fe5aeec63656421a7ab3027a182f2a5fa787f 100644 (file)
@@ -19,6 +19,8 @@ ImageViewer::ImageViewer(QWidget *parent)
             SLOT(slotUpdate()));
     connect(opaqueCheckBox, SIGNAL(stateChanged(int)),
             SLOT(slotUpdate()));
+    connect(alphaCheckBox, SIGNAL(stateChanged(int)),
+            SLOT(slotUpdate()));
 
     QPixmap px(32, 32);
     QPainter p(&px);
@@ -62,8 +64,9 @@ void ImageViewer::slotUpdate()
     double upperValue = upperSpinBox->value();
 
     bool opaque = opaqueCheckBox->isChecked();
+    bool alpha  = alphaCheckBox->isChecked();
 
-    if (lowerValue != 0.0 || upperValue != 1.0 || opaque) {
+    if (lowerValue != 0.0 || upperValue != 1.0 || opaque || alpha) {
         /*
          * Rescale the image.
          *
@@ -95,11 +98,16 @@ void ImageViewer::slotUpdate()
                 int g = qGreen(pixel);
                 int b = qBlue(pixel);
                 int a = qAlpha(pixel);
-                r = clamp(((r + offset) * scale) >> 8);
-                g = clamp(((g + offset) * scale) >> 8);
-                b = clamp(((b + offset) * scale) >> 8);
-                a |= aMask;
-                scanline[x] = qRgba(r, g, b, a);
+                if (alpha) {
+                    a = clamp(((a + offset) * scale) >> 8);
+                    scanline[x] = qRgba(a, a, a, 0xff);
+                } else {
+                    r = clamp(((r + offset) * scale) >> 8);
+                    g = clamp(((g + offset) * scale) >> 8);
+                    b = clamp(((b + offset) * scale) >> 8);
+                    a |= aMask;
+                    scanline[x] = qRgba(r, g, b, a);
+                }
             }
         }
     }
@@ -122,7 +130,7 @@ QSize ImageViewer::sizeHint() const
                             m_image.height() + hScrollHeight);
 
     QRect screenRect = QApplication::desktop()->availableGeometry();
-    const float maxPercentOfDesktopSpace = 0.8;
+    const float maxPercentOfDesktopSpace = 0.8f;
     QSize maxAvailableSize(maxPercentOfDesktopSpace * screenRect.width(),
                            maxPercentOfDesktopSpace * screenRect.height());