简体   繁体   English

IE10中的图像插值

[英]Image interpolation in IE10

This is my use case: 这是我的用例:

I have a web page with a responsive design. 我有一个响应式设计的网页。 The page is vertically split in two halves, on the right hand side I want to show an image (a PDF page rendered as PNG or JPG). 页面垂直分成两半,在右侧我想显示一个图像(一个PDF页面呈现为PNG或JPG)。 The size of the image should change as soon as the window is resized. 调整窗口大小后,图像的大小应该会更改。

I thought I already solved this. 我以为我已经解决了这个问题。 I render the image on the server to be big enough for the biggest possible window size (according to our company setup). 我将服务器上的图像渲染到足够大的窗口大小(根据我们公司的设置)。 Chrome and Firefox scale down (and interpolate) the image just fine. Chrome和Firefox缩小(并插入)图像就好了。

But then there is Internet Explorer 10: If the image size is scaled down to anything beneath 100% it looks like a million flies randomly covering the image ... I cannot seem to find a solution for this. 但是有一个Internet Explorer 10:如果图像大小缩小到100%以下的任何值,它看起来像一百万只苍蝇随机覆盖图像...我似乎无法找到解决方案。

I learned that in the ol' days (IE7) there used to be a CSS rule for this called -ms-interpolation-mode that could be set to bicubic . 我了解到,在ol'(IE7)中,曾经有一个CSS规则用于这种称为-ms-interpolation-mode ,可以设置为bicubic But this has been declared obsolete and is not available in IE9+ 但是这已被宣布为过时的,并且在IE9 +中不可用

Do I have to accept it like that? 我必须这样接受吗? How can this setting be called obsolete if there is no interpolation for scaled images in IE9+? 如果在IE9 +中没有缩放图像的插值,那么如何将此设置称为过时? Is there any solution for this? 这有什么解决方案吗?

I know: Usually you don't let your browser scale your images. 我知道:通常你不会让你的浏览器扩展你的图像。 But do you have a better solution for this use case? 但是你有更好的解决方案吗?

EDIT: I should have mentioned that the images in question are black text on white background. 编辑:我应该提到有问题的图像是白色背景上的黑色文本。 The effect is better visible when using thin lined fonts in the image. 在图像中使用细线字体时,效果更明显。

EDIT2: Please recheck the fiddle ( http://jsfiddle.net/7grxut1t/16/ ) before you close this thread. 编辑2:请在关闭此主题之前重新检查小提琴( http://jsfiddle.net/7grxut1t/16/ )。 If you resize to a very small size in Chrome and IE you will see the difference! 如果您在Chrome和IE中调整到非常小的尺寸,您将看到差异!

The relevant part of my code 我的代码的相关部分

<div>
   <img src="http://websocket.bplaced.net/test.png"/>
</div>

CSS: CSS:

div {
   position: relative;
   width: 50%;
   height: 100%;
}

img {
   width: 100%;
}

Ok, I found a quite dirty, yet applicable workaround 好的,我发现了一个相当肮脏但适用的解决方法

The angular service from https://gist.github.com/fisch0920/37bac5e741eaec60e983 uses the canvas element to interpolate the image on-the-fly. 来自https://gist.github.com/fisch0920/37bac5e741eaec60e983的角度服务使用canvas元素即时插入图像。 It works for me in IE10 (I am not sure about IE9- though). 它在IE10中适用于我(虽然我不确定IE9)。

Its method imageService.resizeStep is amazingly fast in IE ... it renders noticeably faster than the native Firefox image interpolation rendering. 它的方法imageService.resizeStep在IE中速度惊人...它比原生的Firefox图像插值渲染明显更快。

I don't really like it, but it works and it doesn't even slow down the user's workflow. 我真的不喜欢它,但它有效,它甚至不会减慢用户的工作流程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM