aboutsummaryrefslogtreecommitdiffstats
path: root/examples/declarative/canvas/pixels/pixels.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/canvas/pixels/pixels.qml')
-rw-r--r--examples/declarative/canvas/pixels/pixels.qml43
1 files changed, 43 insertions, 0 deletions
diff --git a/examples/declarative/canvas/pixels/pixels.qml b/examples/declarative/canvas/pixels/pixels.qml
new file mode 100644
index 0000000000..45f398dc5e
--- /dev/null
+++ b/examples/declarative/canvas/pixels/pixels.qml
@@ -0,0 +1,43 @@
+import QtQuick 2.0
+import "../contents"
+Item {
+ id:container
+ width:360
+ height:600
+
+ Column {
+ spacing:5
+ anchors.fill:parent
+ Text { font.pointSize:25; text:"Processing pixels"; anchors.horizontalCenter:parent.horizontalCenter}
+
+ Canvas {
+ id:canvas
+ width:360
+ height:360
+ smooth:true
+ renderTarget:Canvas.Image
+ threadRendering:false
+ property string image :"../contents/qt-logo.png"
+ Component.onCompleted:loadImage(image);
+ onImageLoaded:requestPaint();
+ onPaint: {
+
+ var ctx = canvas.getContext('2d');
+ if (canvas.isImageLoaded(image)) {
+ var pixels = ctx.createImageData(image);
+ //pixels.mirror();
+ pixels.filter(Canvas.GrayScale);
+ //pixels.filter(Canvas.Threshold, 100); //default 127
+ //pixels.filter(Canvas.Blur, 20); //default 10
+ //pixels.filter(Canvas.Opaque);
+ //pixels.filter(Canvas.Invert);
+ //pixels.filter(Canvas.Convolute, [0,-1,0,
+ // -1,5,-1,
+ // 0,-1,0]);
+ //ctx.putImageData(pixels, 0, 0, canvas.width, canvas.height);
+ ctx.putImageData(pixels, 0, 0);
+ }
+ }
+ }
+ }
+} \ No newline at end of file