“背景色指数"解读在 GIF 规范中 [英] Interpretation of "background colour index" in GIF specification

查看:18
本文介绍了“背景色指数"解读在 GIF 规范中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您查看 GIF 规范 并搜索背景颜色索引",你看到如下描述:

If you look in the GIF specification and search for "Background Color Index", you see the following description:

vii) 背景颜色索引 - 全局颜色表的索引背景颜色.背景颜色是用于那些的颜色屏幕上未被图像覆盖的像素.如果全球颜色表标志设置为(零),该字段应为零且应该被忽略.

vii) Background Color Index - Index into the Global Color Table for the Background Color. The Background Color is the color used for those pixels on the screen that are not covered by an image. If the Global Color Table Flag is set to (zero), this field should be zero and should be ignored.

这里有一个歧义,就是如果全局颜色表标志"设置为零并且忽略该字段,那么如果图像数据本身没有,则未定义GIF的实际背景颜色覆盖整个图像区域.这是可能的,因为每个图像数据块独立指定左/右/宽/高,并且不需要每个像素都必须由图像数据编码.

There is an ambiguity here, which is that if the "Global Color Table Flag" is set to zero and this field is ignored, then it is undefined what background colour of a GIF actually should be if the image data itself does not cover the entire image area. This possible because every image data block specifies left/right/width/height independently and there is no requirement that every pixel must be encoded by the image data.

我误解了吗?如果不是,那么在这种模棱两可的情况下,今天 GIF 实现的实际行为是什么?

Am I misinterpreting this? If not, then in the presence of this ambiguity, what is the de facto behaviour of GIF implementations today?

推荐答案

例如,Safari 使用黑色作为背景.使用 Win10 照片查看器很难分辨,因为它无论如何都使用黑色背景.Chrome、IE 和 Edge 使用白色.当没有背景颜色而您需要背景颜色时,规范没有定义行为,所以我猜您会得到任意选择,尽管我投票支持透明是最明智的.

For the example, Safari uses black as the background. With Win10 photo viewer it's hard to tell, as it uses a black background anyway. Chrome, IE and Edge use white. The spec doesn't define the behaviour when there's no background colour and you need one, so I guess arbitrary choices is what you'll get, though I vote for transparent being the most sensible.

这篇关于“背景色指数"解读在 GIF 规范中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆