在Web浏览器中获取并显示未压缩的像素值

发布于 2025-01-28 21:25:17 字数 735 浏览 1 评论 0原文

假设我从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 uint8intense_transfer_function。这可以由PNG表示,因此那里不会丢失信息。但是,我在处理png规格之外的内容方面也很有趣,例如sample_type float32intense_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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文