0
如何调整从画布生成的尺寸为640 x 480像素的300 x 150像的图像,然后发送新的图像640 x 480在基地64.如何调整从画布生成的尺寸为640像素的300 x 150的图像的大小X 480像素
因为他做了,但我失去了图像,因为它出现在黑色的背景。
请帮忙!
这是我的javascript代码:
var context = document.getElementById(idCanvas); // Canvas with image in 300 x 150
var canvasNew = document.getElementById("canvasToResize"); // Canvas to re-draw with new sizes
canvasNew.width= 640;
canvasNew.height = 480;
var context2 = canvasNew.getContext("2d");
var image = document.getElementById("newIMG"); // IMG tag for new image with new sizes
image.onload = function() {
context2.drawImage(image, 0, 0, 640, 480);
};
image.src = context.toDataURL();
return canvasNew.toDataURL().split(',')[1]; // send base 64
我可以修复它....我添加的解决方案,你需要的代码,如果他们有类似的问题 – user1515384 2012-07-11 21:59:36