]> git.cworth.org Git - apitrace/blobdiff - gui/apisurface.cpp
Use normalized ubytes for now.
[apitrace] / gui / apisurface.cpp
index 105532e9a2c07cc9dfc5b07fca644a828382a211..32ebff2853452144fc5ade36ce5373a20e33afe3 100644 (file)
@@ -17,6 +17,12 @@ void ApiSurface::setSize(const QSize &size)
     m_size = size;
 }
 
+static inline int
+rgba8_to_argb(quint8 r, quint8 g, quint8 b, quint8 a)
+{
+    return (a << 24 | r << 16 | g << 8 | b);
+}
+
 static inline int
 rgbaf2argb(float r, float g, float b, float a)
 {
@@ -31,7 +37,7 @@ rgbaf2argb(float r, float g, float b, float a)
 void ApiSurface::contentsFromBase64(const QByteArray &base64)
 {
     QByteArray dataArray = QByteArray::fromBase64(base64);
-    const float *data = (const float*)dataArray.data();
+    const quint8 *data = (const quint8*)dataArray.data();
     int width = m_size.width();
     int height = m_size.height();
 
@@ -45,10 +51,10 @@ void ApiSurface::contentsFromBase64(const QByteArray &base64)
 
     for (int y = 0; y < height; ++y) {
         for (int x = 0; x < width; ++x) {
-            int pixel = rgbaf2argb(data[(y * width + x) * 4 + 0],
-                                   data[(y * width + x) * 4 + 1],
-                                   data[(y * width + x) * 4 + 2],
-                                   data[(y * width + x) * 4 + 3]);
+            int pixel = rgba8_to_argb(data[(y * width + x) * 4 + 0],
+                                      data[(y * width + x) * 4 + 1],
+                                      data[(y * width + x) * 4 + 2],
+                                      data[(y * width + x) * 4 + 3]);
             pixelData[y * width + x] = pixel;
         }
     }