]> git.sesse.net Git - kdenlive/blobdiff - src/colorcorrection/vectorscopegenerator.cpp
Fix vectorscope for 24bit RGB images:
[kdenlive] / src / colorcorrection / vectorscopegenerator.cpp
index 4ee5eccc1c41b71434b101fa19d0f11a9a8e51b2..052022500894eb19f80fed91965b4439a421effe 100644 (file)
@@ -137,12 +137,13 @@ QImage VectorscopeGenerator::calculateVectorscope(const QSize &vectorscopeSize,
     double /*y,*/ u, v;
     QPoint pt;
     QRgb px;
+    int bpp = image.depth() / 8;
 
-    const int stepsize = 4*accelFactor;
+    const int stepsize = bpp * accelFactor;
 
     // Just an average for the number of image pixels per scope pixel.
     // NOTE: byteCount() has to be replaced by (img.bytesPerLine()*img.height()) for Qt 4.5 to compile, see: http://doc.trolltech.org/4.6/qimage.html#bytesPerLine
-    double avgPxPerPx = (double) 4*(image.bytesPerLine()*image.height())/scope.size().width()/scope.size().height()/accelFactor;
+    double avgPxPerPx = (double) bpp*(image.bytesPerLine()*image.height())/scope.size().width()/scope.size().height()/accelFactor;
 
     for (int i = 0; i < (image.bytesPerLine()*image.height()); i+= stepsize) {
         QRgb *col = (QRgb *) bits;