dongtun1683 2011-12-17 10:29 采纳率: 0%
浏览 48

将画布保存为仅可见区域的图像

i am trying to save an image from canvas after resizing it or adding some effects on it but i am unable to save the visible area of canvas it save full image all the time is there any way i can save only visible part of canvas whatever is in it with php or javascript or anything else

i am using jquery and php to save image from but same thing

    var canvasData = canvas.toDataURL("image/png");
var postData = 'canvasData='+canvasData;
var ajax = new XMLHttpRequest();
ajax.open('POST','http://localhost/canvas/imagesaver.php',true);
ajax.setRequestHeader('Content-Type', 'canvas/upload');

here is what i am trying to do right now

http://jsfiddle.net/BPmb5/1/

  • 写回答

1条回答 默认 最新

  • doutangkao2789 2013-08-10 19:03
    关注

    only client solution:

    1. create second canvas of the right size (or you might resize a hiddon one from your page)
    2. use the canvas context function of second canvas ctx.drawImage(canvas1, sx, sy, sw, sh, dx, dy, dw, dh)
    3. use your .toDataURL("image/png") code on second canvas
    评论

报告相同问题?

悬赏问题

  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问