Use the actual size of the image for the iteration.
authorGunnar Sletta <gunnar.sletta@digia.com>
Tue, 23 Apr 2013 10:32:01 +0000 (12:32 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 23 Apr 2013 10:53:48 +0000 (12:53 +0200)
If the rectangle dimension was a floating-point value, we could
sample outside the image, causing tons of warnings.

Change-Id: I10abece9a6b0cf769551f554fb5999d5d90e4c9d
Reviewed-by: aavit <eirik.aavitsland@digia.com>

src/particles/qquickmaskextruder.cpp

index 3153e2b..927cf97 100644 (file)
@@ -132,8 +132,10 @@ void QQuickMaskExtruder::ensureInitialized(const QRectF &r)
     m_img = m_pix.image().createAlphaMask();
     m_img = m_img.convertToFormat(QImage::Format_Mono);//Else LSB, but I think that's easier
     m_img = m_img.scaled(r.size().toSize());//TODO: Do they need aspect ratio stuff? Or tiling?
-    for (int i=0; i<r.width(); i++){
-        for (int j=0; j<r.height(); j++){
+    int w = m_img.width();
+    int h = m_img.height();
+    for (int i=0; i<w; i++){
+        for (int j=0; j<h; j++){
             if (m_img.pixelIndex(i,j))//Direct bit manipulation is presumably more efficient
                 m_mask << QPointF(i,j);
         }