HTML5 canvas how to change putImageData scale -



HTML5 canvas how to change putImageData scale -

how alter putimagedata scale scale(1.5, 1.5) not working..

var imagedata = context.getimagedata(0, 0, canvas.width, canvas.height); context.clearrect(0, 0, canvas.width, canvas.height); context.scale(1.5, 1.5); context.putimagedata(imagedata, 0, 0);

correct, code not scale existing drawings.

context.scale affects new drawings, not existing drawings.

context.putimagedata set saved original pixels on canvas, putimagedata not drawing command results not scaled.

to scale existing pixels have save pixels entity outside of canvas. outside entity new image element or sec canvas element.

example code , demo: http://jsfiddle.net/m1erickson/p5nee/

// canvas related variables var canvas=document.getelementbyid("canvas"); var context=canvas.getcontext("2d"); // draw test square context.fillstyle="red"; context.fillrect(0,0,50,50); // create image canvas // clear & scale canvas // draw image canvas var imageobject=new image(); imageobject.onload=function(){ context.clearrect(0,0,canvas.width,canvas.height); context.scale(1.2,1.2); context.drawimage(imageobject,0,0); } imageobject.src=canvas.todataurl();

scale putimagedata

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -