Pixel Manipulation on QML Canvas Question... Uint8ClampedArray

  • Is here a way to manipolate/swap image pixel color like in html5 canvas method?
    Read image is simple ... but swap color
    how i can swap black pixel to other color?

    function picData() {
                        var ctx = canvas.getContext('2d');
                        var im = ctx.createImageData(pixelurl);
                        //// im.data[3] = 128;
                        return im
    /// after draw in other position

    My method is to read a full image like a excel table

    Only one big icon


    a sample to test is :

  • I'm not sure I really understand what you're trying to do, and I know little about what canvas is capable of... but I have had cases where I've wanted to recolour an image (or do some other per-pixel operation) and have found by far the easiest way is to use one of the QML Graphical Effects (if there's an existing one which does the job) or write a custom ShaderEffect (pixel manipulation logic typically 1-3 lines of GLSL in amongst the other boilerplate for an identity operation). I haven't tried it but I can't think of any reason a ShaderEffect shouldn't work on top of a canvas (unless you're not on an OpenGL platform that is).

    Another approach I've used where the application's images weren't quite right was to write (C++) a QQuickImageProvider to load a QImage, apply the needed adjustments to the QImage and then expose the tweaked result to the QML Image.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.