在Web浏览器中获取并显示未压缩的像素值
假设我从HTTP服务器中获得了这样的JSON数据:
{
"width":1234,
"height":356,
"channels":"rgba",
"sample_type":"uint8",
"intensity_transfer_function":"sRGB",
"pixels":"<encoded raw pixels>"
}
在这里,假定像素不是使用JPEG或PNG编码的。相反,数据包含“可显示的”像素,其中字符串
由两对十六进制数字(FF0000FF都意味着红色像素)或
组成是所有像素值的基本-64表示
,或者服务器必须以PNG的形式发送它?
附带说明:上面集sample_type
to uint8
和intense_transfer_function
。这可以由PNG表示,因此那里不会丢失信息。但是,我在处理png规格之外的内容方面也很有趣,例如sample_type
float32
和intense_transfer_function
设置为linearear
,不要丢失服务器发送的任何信息。
Suppose I have get json data like this from an HTTP server:
{
"width":1234,
"height":356,
"channels":"rgba",
"sample_type":"uint8",
"intensity_transfer_function":"sRGB",
"pixels":"<encoded raw pixels>"
}
Here, it is assumed that pixels are not encoded using JPEG or PNG. Instead the data contains "displayable" pixels, where the string
Consists of either pairs of hexadecimal digits (ff0000ff would mean a red pixel), or
Is a base-64 representation of all pixel values
Is it possible to show the data in a web browser using JavaScript, or do the server have to send it as a PNG?
As a side note: The above sets sample_type
to uint8
and intensity_transfer_function
. This can be represented by a PNG, so there would be no information loss there. However, I am also interesting in dealing with stuff that are outside the PNG spec, such as sample_type
float32
and intensity_transfer_function
set to linear
, to not loose any information sent by the server.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论