aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@digia.com>2013-02-06 09:18:19 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-07 08:41:08 +0100
commitfc454c16c84d159767273a21019fbd65572f3bad (patch)
tree7b425ca520029a80602fdd82701a1a2ce390b61e
parent34c679bc32ae98067cd1cca5564e03f629a0f3b8 (diff)
Fixed Canvas ImageData pixel values not being settable to 0.
Someone probably figured "since the data is all initialized to 0 to begin with, we can skip 0 values". However, it's possible to temporarily set a value to other than 0 and then back to 0, a fully valid use case that we need to support. Task-number: QTBUG-29065 Change-Id: Ia9f0803743d696ca8b9cca89c666ccba80a3abd0 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com> Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
-rw-r--r--src/quick/items/context2d/qquickcontext2d.cpp2
-rw-r--r--tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml8
2 files changed, 9 insertions, 1 deletions
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp
index a46cd6ab70..2f37c7f109 100644
--- a/src/quick/items/context2d/qquickcontext2d.cpp
+++ b/src/quick/items/context2d/qquickcontext2d.cpp
@@ -2513,7 +2513,7 @@ v8::Handle<v8::Value> ctx2d_pixelArray_indexed_set(uint32_t index, v8::Local<v8:
QV8Context2DPixelArrayResource *r = v8_resource_cast<QV8Context2DPixelArrayResource>(info.This());
const int v = value->Uint32Value();
- if (r && index < static_cast<quint32>(r->image.width() * r->image.height() * 4) && v > 0 && v <= 255) {
+ if (r && index < static_cast<quint32>(r->image.width() * r->image.height() * 4) && v >= 0 && v <= 255) {
const quint32 w = r->image.width();
const quint32 row = (index / 4) / w;
const quint32 col = (index / 4) % w;
diff --git a/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml b/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml
index 469ff2398d..487f7dc903 100644
--- a/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml
+++ b/tests/auto/quick/qquickcanvasitem/data/tst_pixel.qml
@@ -1,4 +1,5 @@
import QtQuick 2.0
+import QtTest 1.0
CanvasTestCase {
id:testCase
@@ -7,6 +8,13 @@ CanvasTestCase {
function test_createImageData(row) {
var canvas = createCanvasObject(row);
var ctx = canvas.getContext('2d');
+ var imageData = ctx.createImageData(1, 1);
+ var imageDataValues = imageData.data;
+ imageDataValues[0] = 255;
+ imageDataValues[0] = 0;
+ if (imageDataValues[0] != 0)
+ qtest_fail('ImageData value access fail, expecting 0, got ' + imageDataValues[0]);
+
ctx.reset();
canvas.destroy()
}