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
  • Raphael.js image 在ie8以下的兼容性问题的更多相关文章

    1. svg绘图工具raphael.js的使用

      1.raphael.js svg画图的开源库,支持IE8+ 官方api: http://dmitrybaranovskiy.github.io/raphael/reference.html Githu ...

    2. 学习RaphaelJS矢量图形包--Learning Raphael JS Vector Graphics中文翻译(一)

      (原文地址:http://www.cnblogs.com/idealer3d/p/LearningRaphaelJSVectorGraphics.html) 前面3篇博文里面,我们讲解了一本叫做< ...

    3. 强大的矢量图形库:Raphael JS 中文帮助文档及教程

      Raphael 是一个用于在网页中绘制矢量图形的 Javascript 库.它使用 SVG W3C 推荐标准和 VML 作为创建图形的基础,你可以通过 JavaScript 操作 DOM 来轻松创建出 ...

    4. CSS HACK区别IE6、IE7、IE8、Firefox兼容性

      相信不少人,都特别清楚CSS HACK,而其中也是区别IE6.IE7.IE8.Firefox兼容性问题用的,CSS hack由于不同的浏览器,对CSS的解析认识不一样,因此会导致生成的页面效果不一样. ...

    5. Raphael Js矢量库API简介:

      Raphael Js矢量库API简介:Raphael Javascript 是一个 Javascript的矢量库. 2010年6月15日,著名的JavaScript库ExtJS与触摸屏代码库项目jQT ...

    6. PHP+Mysql+jQuery实现中国地图区域数据统计(raphael.js)

      使用过百度统计或者cnzz统计的童鞋应该知道,后台有一个地图统计,不同访问量的省份显示的颜色也不一样,今天我将带领大家开发一个这样的案例.上一篇<使用raphael.js绘制中国地图>文章 ...

    7. Javascript实战开发:教你使用raphael.js绘制中国地图

      最近的数据统计项目中要用到中国地图,也就是在地图上动态的显示某个时间段某个省份地区的统计数据,我们不需要flash,仅仅依靠raphael.js以及SVG图像就可以完成地图的交互操作.在本文中,我给大 ...

    8. raphael.js 给元素 hover 添加glow() 外发光

      用raphael.js 给 svg画布里面添加个元素,嗯就圓好了,男人一般都喜欢圆形的东西,比如xx ,  xxx , 还有xxx $(document).ready(function() { var ...

    9. IE6、IE7、IE8、Firefox兼容性

      整理关于IE6.IE7.IE8.Firefox兼容性CSS HACK问题 1.区别IE和非IE浏览器CSS HACK代码 #divcss5{background:blue; /*非IE 背景藍色*/b ...

    随机推荐

    1. CF540B School Marks

      思路: 贪心. 实现: #include <iostream> #include <cstdio> #include <vector> #include <a ...

    2. String field contains invalid UTF-8 data when serializing a protocol buffer. Use the 'bytes' type if you intend to send raw bytes.

      [libprotobuf ERROR google/protobuf/wire_format.cc:1053] String field contains invalid UTF-8 data whe ...

    3. JS高级——文件操作

      https://www.cnblogs.com/mingmingruyuedlut/archive/2011/10/12/2208589.html https://blog.csdn.net/pl16 ...

    4. swift protocol 与类继承结合时的bug

      protocol CommonTrait: class { func commonBehavior() -> String } extension CommonTrait { func comm ...

    5. Functions of the call stack

      https://en.wikipedia.org/wiki/Call_stack#STACK-FRAME As noted above, the primary purpose of a call s ...

    6. lsb_release No LSB modules are available

      lsb_release 提示: No LSB modules are available   执行: sudo apt-get install lsb-core

    7. logging,numpy,pandas,matplotlib模块

      logging模块 日志总共分为以下五个级别,这五个级别自下而上进行匹配debug->info->warning->error->critical,默认的最低级别warning ...

    8. 00Enterprise Resource Planning

      Enterprise Resource Planning         企业资源计划即 ERP (Enterprise Resource Planning),由美国 Gartner Group 公司 ...

    9. 题解 洛谷P3203/BZOJ2002【[HNOI2010]弹飞绵羊】

      裸的LCT,关键是要怎么连边,怎么将这种弹飞关系转化成连边就行了. 那么我们可以这样连边: 一个节点i的爸爸就是i+ki. 没有i+ki那么就被弹飞了,即\(i\)的爸爸是虚拟节点n+1. 那么怎么求 ...

    10. 洛谷——P1273 有线电视网

      P1273 有线电视网 题目大意: 题目描述 某收费有线电视网计划转播一场重要的足球比赛.他们的转播网和用户终端构成一棵树状结构,这棵树的根结点位于足球比赛的现场,树叶为各个用户终端,其他中转站为该树 ...