gpt4 book ai didi

javascript - toDataURL 与 toDataURLHD

转载 作者:可可西里 更新时间:2023-11-01 01:53:50 25 4
gpt4 key购买 nike

所以我看到有人提出了一些新的(大概)功能; toDataURLHDtoBlobHDgetImageDataHD 等“以原生 Canvas 位图分辨率返回 [数据]”( http://developers.whatwg.org/the-canvas-element.html )。

但是我不明白这些术语。这是否意味着在某些情况下非高清版本会在返回之前重新缩放图像数据? (即在高分辨率显示器上 toDataURL 可能会生成质量低于实际 Canvas 的图像),或者这只是指图像中的每英寸像素元数据?

我一直在尝试尽可能多的缩放方法( fiddle :http://jsfiddle.net/SktKQ/),它似乎总是逐个像素,但这很难确定,我无法访问任何用于测试的高分辨率显示器。

我正在寻找的是:我能否依靠 toDataURL & Co. 生成我的 Canvas 的像素对像素副本,其宽度和高度完全等于 属性 在元素上设置? (如果是这样,高清版本有什么意义?)

最佳答案

WhatWG documents on canvas说以下内容:

The size of the coordinate space does not necessarily represent the size of the actual bitmaps that the user agent will use internally or during rendering. On high-definition displays, for instance, the user agent may internally use bitmaps with two device pixels per unit in the coordinate space, so that the rendering remains at high quality throughout. Anti-aliasing can similarly be implemented using over-sampling with bitmaps of a higher resolution than the final image on the display.

The toDataURL() method returns the data at a resolution of 96dpi. The toDataURLHD() method returns it at the native canvas bitmap resolution.

我的理解是 toDataURL 只返回 CSS 像素(96 DPI);但实现可以自由使用更高的像素密度,只有通过 toDataURLHD 才能看到。也就是说,即使您将 Canvas 定义为 800x600,作为 CSS 像素大小,实现实际上可以使用 192 DPI 密度(1600x1200);如果您使用前者,您将获得 800x600,而 HD 方法将确保您获得实际像素。

此外声明如下:

Thus, in the 2D context, calling the drawImage() method to render the output of the toDataURLHD() method to the canvas, given the appropriate dimensions, has no visible effect.

但是,不能保证使用来自 toDataURL 的图像数据不会产生可见效果(分辨率较差)。

关于javascript - toDataURL 与 toDataURLHD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18386825/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com