javascript - Can an image be created from a new canvas object? -


i'm attempting create new canvas, clipping operations on image, , returning new image.

but, without doing image, error when trying render image method returns.

the htmlimageelement provided in 'broken' state. 

here code:

   let image = imageutils.getimage("path_to_my_image.jpg");     let canvas = document.createelement("canvas");    canvas.width = texture.width;    canvas.height = texture.height;     let g = canvas.getcontext("2d");    g.drawimage(image, 0, 0);     let newimage = new image();    newimage.src = canvas.todataurl("image/jpeg");  return newimage; 

i'm able render image if don't try generate new canvas object, know that's not issue. i've searched around quite bit , haven't seen on topic.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -