Raphael.js 在ie7,ie8浏览器内绘制图形採用的vml,在绘制image的时候会解析成

<?xml:namespace prefix = "rvml" ns = "urn:schemas-microsoft-com:vml" />
<rvml:shape class=rvml style="HEIGHT: 1px; WIDTH: 1px; POSITION: absolute; LEFT: 0px; FILTER: none; TOP: 0px; VISIBILITY: visible; rotation: 0; flip: " raphael="true" raphaelid="0" coordsize = "21600,21600" stroked = "f" strokecolor = "black" path = " m0,0 l37087200,0,37087200,16912800,0,16912800 xe">
<rvml:stroke class=rvml opacity = "1" miterlimit = "8">
</rvml:stroke><rvml:skew class=rvml on = "t" matrix = "1,0,0,1,0,0" offset = "-.5,-.5"></rvml:skew>
<rvml:fill class=rvml rotate = "t" src = "../123.png" type = "tile" size = "1717,783" position = "0,0"></rvml:fill>
</rvml:shape>

也就是使用vml来绘制图形,在chrome和firfox还有ie8之后都是採用svg来绘制图形。可是这样就会造就一个问题,在window 8系统中默认ie是ie10,然后使用开发人员工具的时候切换ie至ie7 ie8的时候图像会比原来大好多,在xp系统中或者是window 7系统中也会有相同的表现,比如图像错位,真实的点坐标不正确等。

解决的方法:

vml  image size不正确的问题是由于 ie 浏览器对 fill size 单位不清晰造成的,查看mrocsoft文档知道fill使用的单位pt,而非px,图像单位我们获取的一般都是pixel也就是px。

可是1px=1.34pt这就会造成图像变形。

跟踪源代码在Raphael.js  4953行中fill.size = _.fillsize[0] * abs(sx) + S + _.fillsize[1] * abs(sy);这里是没有单位,也是罪恶源泉,我们改动成fill.size = _.fillsize[0] * abs(sx) / 1.34 + "pt" + S + _.fillsize[1] * abs(sy) / 1.34 + "pt";一切问题搞得。

结果图例如以下:

After few hours of debug I've figured out that VML implementation is missing measurement points in image tag size definition.

Line number 4952 missing “pt” constant that has to be present in VML tag. So just changing 
fill.size = _.fillsize[0] * abs(sx) + S + _.fillsize[1] * abs(sy);

to something like

fill.size = _.fillsize[0] * abs(sx)/1.34 + "pt" + S + _.fillsize[1] * abs(sy)/1.34 + "pt";

附带pt,px等一些单位的转换

  • Pixel↔m   1 m = 3779.5275593333 Pixel
  • Pixel↔dm   1 dm = 377.95275593333 Pixel
  • Pixel↔cm   1 cm = 37.795275593333 Pixel
  • Pixel↔mm   1 mm = 3.7795275593333 Pixel
  • Pixel↔in   1 in = 96 Pixel
  • Pixel↔ft   1 ft = 1152 Pixel
  • Pixel↔Pica   1 Pica = 16 Pixel
  • Pixel↔Point   1 Point = 1.3333333333333 Pixel
  • Pixel↔Twip   1 Pixel = 15 Twip
  • 最新文章

    1. pandas.DataFrame排除特定行
    2. LDD3 字符设备驱动简单分析
    3. C++引用的作用和用法
    4. Visual Studio 2013 always switches source control plugin to Git and disconnect TFS
    5. Reflection
    6. ViewController与outlet绑定
    7. C# Web中Session的使用
    8. 2048-AI程序算法分析
    9. 【转】BLE 学习记录
    10. crm操作安全角色
    11. Python练手例子(12)
    12. git命令提交新项目
    13. 解决win10系统dpi放大后,部分网页文字颜色很浅的问题
    14. 关于TP5的一对一、一对多同时存在的关联查询
    15. [java初探06]__排序算法的简单认识
    16. idea 上搭建 Mybatis 逆向工程
    17. ubuntu修改root密码
    18. oracle创建dblink方法
    19. CTF密码学之摩斯密码
    20. ecliplse java log4j 配置

    热门文章

    1. opencv3+python+pycharm报错问题(cmd命令正常)
    2. Angular——MVC模式开发实战
    3. dutacm.club_1089_A Water Problem_(dp)
    4. HDU_1548_A strange lift
    5. Discuz伪静态代码
    6. docker在ubuntu16.04下的安装及阿里云镜像的配置
    7. java基础学习之内存分析(栈、堆、方法区)
    8. Java线程处理
    9. Gitlab forbidden
    10. Linux常用命令——链接命令