• Re: Copy canvas content to other canvas.

    From =?UTF-8?Q?Jonas_Th=C3=B6rnvall?=@21:1/5 to All on Sun Dec 5 07:35:59 2021
    söndag 5 december 2021 kl. 16:15:56 UTC+1 skrev Jonas Thörnvall:
    Someone wrote in answer to similar quesion *******************************************************
    Actually you don't have to create an image at all. drawImage() will accept a Canvas as well as an Image object.

    //grab the context from your destination canvas
    var destCtx = destinationCanvas.getContext('2d');"

    //call its drawImage() function passing it the source canvas directly destCtx.drawImage(sourceCanvas, 0, 0);
    Way faster than using an ImageData object or Image element. *********************************************************

    So I tried to copy ctT canvas by just using drawimage but get errors, MultiID.destCtx.drawImage(ctT, 0, 0);
    I tried it with an image so destCtx do work.

    But with canvas...
    DrawLEFTCANVAS.js:52 Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLCanvasElement or HTMLImageElement or HTMLVideoElement or ImageBitmap or OffscreenCanvas or
    SVGImageElement or VideoFrame)'.
    at listLeftCanvas (DrawLEFTCANVAS.js:52)
    at buildPlayTrack (mixDown.js:54)
    at songDataUpdate (loadsave.js:114)
    at autoLoadFile (loadsave.js:36)
    at MAINinit.js:77
    Ok saw the error, solved.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Jonas_Th=C3=B6rnvall?=@21:1/5 to All on Sun Dec 5 07:15:52 2021
    Someone wrote in answer to similar quesion *******************************************************
    Actually you don't have to create an image at all. drawImage() will accept a Canvas as well as an Image object.

    //grab the context from your destination canvas
    var destCtx = destinationCanvas.getContext('2d');"

    //call its drawImage() function passing it the source canvas directly destCtx.drawImage(sourceCanvas, 0, 0);
    Way faster than using an ImageData object or Image element. *********************************************************

    So I tried to copy ctT canvas by just using drawimage but get errors,
    MultiID.destCtx.drawImage(ctT, 0, 0);
    I tried it with an image so destCtx do work.

    But with canvas...
    DrawLEFTCANVAS.js:52 Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLCanvasElement or HTMLImageElement or HTMLVideoElement or ImageBitmap or OffscreenCanvas or
    SVGImageElement or VideoFrame)'.
    at listLeftCanvas (DrawLEFTCANVAS.js:52)
    at buildPlayTrack (mixDown.js:54)
    at songDataUpdate (loadsave.js:114)
    at autoLoadFile (loadsave.js:36)
    at MAINinit.js:77

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)