高质量的图像
Estimated reading time: 1 minute
BRAVIA商用显示器提供了一种在应用程序中以高质量呈现图像文件的特殊方法。 在这种情况下,图像以4K YUV物理平面呈现,与RGB平面分离。
<object id="hq-img" type="application/x-4k-photo" width="1920" height="1080"></object>
这个功能的优点是:
- 画面质量比
<img>
好得多 - 支持4K分辨率
- 支持预加载和缓存
然而,也有一些限制:
- 一次只能打开一个
<object>
, 不能与媒体元素一起使用 (<audio>
和<video>
) 和其他<object>
元素。 - 获取图像数据时不支持HTTP cookie
- 不支持相对路径
方法
-
long open()
open()
prepares for image rendering and returns 0 on success. -
void close()
close()
releases the resource for image rendering. -
long show(DOMString url)
show()
starts loading and rendering the image specified by the parameter"url"
. -
long getStatus()
getStatus()
gets the plugin status and returns non-zero value when the object is opened. -
long preload(DOMString url) The preload() preloads the image data specified by the parameter “url” and stores it in the memory.
事件
- onshow
onshow
is called when the image rendering is complete.- 0: success
- non-zero: error
- onpreload
onpreload
is called when preload is complete.- 0: success or already cached
- -1: error
属性
- zoomMode
zoomMode
decides zoom mode- values: NoExpand and Smart
- default: NoExpand
- is4kPanel
is4kPanel
- true: if the panel is 4k or 8k
- false: if the panel is not 4k or 8k
- is4kPlayback
is4kPlayback
- true: if the 4k or 8k photo playback mode is enabled in the setting
- false: if the 4k or 8k photo playback mode is not enabled in the setting
举例
请下载 a sample application,它能在应用程序中通过一种特殊的方法去高质量地渲染图片。
The snippet below shows how to preload image data.
var object = document.getElementById('hq-img');
object.open();
object.onpreload = function(url, result) {
object.show(url);
};
object.preload('https://example.com/4k_image.jpg');
Last modified: 10 Jun 2022