Take a partial screenshot?

  • I need to take a partial screenshot, lets say from position 10,10 with 200 pixel width and 100 pixels height.

    I tried to read from the canvas (this._iRuntime._canvas), but its just black.

    The snapshotfunction only delivers a full screen shot, already as encoded url.

    In any other html5 framework that works, but not in Construct3.

    Thats what i Do:

    screenshot(this._iRuntime._canvas, 10, 10, 200, 100);

    function screenshot (_canvas, _x, _y, _sx, _sy)

    {

    var SaveCan = document.createElement('canvas');

    SaveCan.setAttribute('width', _sx);

    SaveCan.setAttribute('height', _sy);

    var SaveCtx = SaveCan.getContext('2d');

    SaveCtx.fillStyle = "rgb(100,100,200)"; //Make sure it is not black

    SaveCtx.clearRect(0,0,256,220);

    SaveCtx.drawImage(_canvas,_x,_y,_sx,_sy,0,0,_sx,_sy);

    var canvasData = SaveCan.toDataURL("image/jpg");

    -> POST to a php script

    }

    Any help welcome

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)