MCBBS Wiki欢迎您共同参与编辑!在参与编辑之前请先阅读Wiki方针。
如果在编辑的过程中遇到了什么问题,可以去讨论板提问。
为了您能够无阻碍地参与编辑 未验证/绑定过邮箱的用户,请尽快绑定/验证。
MCBBS Wiki GitHub群组已上线!
您可以在回声洞中发表吐槽!
服务器状态监控。点击进入
本站由MCBBS用户自行搭建,与MCBBS及东银河系漫游指南(北京)科技有限公司没有从属关系。点此了解 MCBBS Wiki 不是什么>>
用户:Salt lovely/沙盒
跳到导航
跳到搜索
测试功能
这里是投票标题
(可选)这里是投票副标题
QWERTYUIOP
JS代码存档
// MCBBS头像上传时三个大小头像切片上传代码 - 修改 - 启用抗锯齿 // 其实就加了两行 (0, eval)(`function saveAvatar() { var img = $('avatarimage'); var sd = getSelectorDimention(); var ad = getAvatarDimension(); var rl = (sd.left-ad.left)/ad.width; var rt = (sd.top-ad.top)/ad.height; var rw = sd.width/ad.width; var rh = sd.height/ad.height; var iw = jQuery('#avatarimage').width(); var ih = jQuery('#avatarimage').height(); var sl = rl*iw; var st = rt*ih; var sw = rw*iw; var sh = rh*ih; var tw = sw; var th = sh; if (sw>200 || sh>250) { var r = Math.max(sw/200, sh/250); tw = Math.floor(sw/r); th = Math.floor(sh/r); } var canvas = document.createElement('canvas'); canvas.width = tw; canvas.height = th; var ctx = canvas.getContext("2d"); ctx.fillStyle = 'white'; ctx.fillRect(0, 0, tw, th); ctx.drawImage(img, sl, st, sw, sh, 0, 0, tw, th); ctx.imageSmoothingEnabled = true; // 启用抗锯齿 ctx.imageSmoothingQuality = "high"; // 高品质抗锯齿 var dataURL = canvas.toDataURL("image/jpeg"); jQuery('#avatar1').val(dataURL.substr(dataURL.indexOf(",") + 1)); var tw = sw; var th = sh; if (sw>120 || sh>120) { var r = Math.max(sw/120, sh/120); tw = Math.floor(sw/r); th = Math.floor(sh/r); } var canvas = document.createElement('canvas'); canvas.width = tw; canvas.height = th; var ctx = canvas.getContext("2d"); ctx.fillStyle = 'white'; ctx.fillRect(0, 0, tw, th); ctx.drawImage(img, sl, st, sw, sh, 0, 0, tw, th); var dataURL = canvas.toDataURL("image/jpeg"); jQuery('#avatar2').val(dataURL.substr(dataURL.indexOf(",") + 1)); var mwh = Math.min(sw, sh); if (sw>mwh) { sl += Math.floor((sw-mwh)/2); sw = mwh; } if (sh>mwh) { st += Math.floor((sh-mwh)/2); sh = mwh; } var tw = 48; var th = 48; var canvas = document.createElement('canvas'); canvas.width = tw; canvas.height = th; var ctx = canvas.getContext("2d"); ctx.fillStyle = 'white'; ctx.fillRect(0, 0, tw, th); ctx.drawImage(img, sl, st, sw, sh, 0, 0, tw, th); var dataURL = canvas.toDataURL("image/jpeg"); jQuery('#avatar3').val(dataURL.substr(dataURL.indexOf(",") + 1)); var src = $('avatarform').action; $('avatarform').action = data[data.indexOf('src')+1].replace('images/camera.swf?inajax=1', 'index.php?m=user&a=rectavatar&base64=yes'); $('avatarform').target='rectframe'; }`)