Gif图片格式如何加入透明度
How is transparency incorporated in Gif Image format
GIF89a 通过将索引指定为透明图块来支持透明度。它仅支持完全透明,这意味着不支持可变透明度(如 PNG 的情况)。
我尝试阅读 Pseudo RFC GIF89a 格式,整个文档中只提到了两次透明度。即:-
- 透明度标志
- 透明度指数
还有上面两个的描述,不是最直观的
GIF 的维基百科页面指出,索引 = 16(在 256 调色板中)的透明图块始终指定为透明图块 tile/index。但随后它指出,“图像数据中出现的唯一颜色索引是十进制 40 和 255,全局颜色 Table 分别映射到黑色和白色 ”,它让我相信我可能误解了页面中可用的信息(因为我之前在图像中看到 index < 40 的像素值)。
问题:-
.gif
(89a) 图像中如何加入透明度?是一个
调色板中的常量索引总是给出透明值?
- 如果是,那么当图像没有时,调色板是否保持不变
透明区域,这是否意味着我们只能使用 255 个独特的区域
索引(因为 1 索引总是给透明图块)?
P.S.:- 如果有人能补充一下透明度是如何包含的,我将不胜感激?是使用 Alpha 图块(如 RGBA 或 LA)还是从该像素中移除颜色以使其透明?
How is transparency incorporated in .gif (89a) images? Is a constant index in the palette always given a value of transparent?
没有
透明度标志 TF
仅指示透明度索引 TI
是否对框架有任何意义。
如果 TF == true
则当前(全局或局部)调色板中的特定颜色索引在将当前帧与图像的其余部分组合时被视为透明。此索引存储在 TI
.
If yes, then does the palette stays the same when an image has no transparent regions, and does that mean we only get to use 255 unique index (as 1 index is always given to transparent tile)?
当图像没有透明区域时,TF == false
和 TI
值通常是垃圾,因此不会被 GIF 加载器解释。
作为一名 self-proclaimed GIF 专家,我试图尽可能简洁地在文档和 this 微型加载器的源代码中记录 GIF 的内部工作原理。
[更新:]
So, does that mean transparency is only included if the .gif file has frames. Meaning it is not a single image, but a sequence of images?
没有。即使 single-frame GIF 也允许包含图形控件 header,所以不可以。
Does GIF have a fixed palette of 256 colors, meaning the palette could not store more/less then that color range. I am asking this as you mentioned, that in a B/W image, only two color exists black and white, then what happens to the rest of the palette index? or like how does GIF format manages lower color spaces?
GIF 支持任何大小为 2 的幂且介于 2 和 256 之间的调色板,结果为:2、4、8、16、32、64、128 或 256。
调色板大小由全局 GIF header 中的 bits 0 to 2 of the flags field 控制。
GIF89a 通过将索引指定为透明图块来支持透明度。它仅支持完全透明,这意味着不支持可变透明度(如 PNG 的情况)。
我尝试阅读 Pseudo RFC GIF89a 格式,整个文档中只提到了两次透明度。即:-
- 透明度标志
- 透明度指数
还有上面两个的描述,不是最直观的
GIF 的维基百科页面指出,索引 = 16(在 256 调色板中)的透明图块始终指定为透明图块 tile/index。但随后它指出,“图像数据中出现的唯一颜色索引是十进制 40 和 255,全局颜色 Table 分别映射到黑色和白色 ”,它让我相信我可能误解了页面中可用的信息(因为我之前在图像中看到 index < 40 的像素值)。
问题:-
.gif
(89a) 图像中如何加入透明度?是一个 调色板中的常量索引总是给出透明值?- 如果是,那么当图像没有时,调色板是否保持不变 透明区域,这是否意味着我们只能使用 255 个独特的区域 索引(因为 1 索引总是给透明图块)?
P.S.:- 如果有人能补充一下透明度是如何包含的,我将不胜感激?是使用 Alpha 图块(如 RGBA 或 LA)还是从该像素中移除颜色以使其透明?
How is transparency incorporated in .gif (89a) images? Is a constant index in the palette always given a value of transparent?
没有
透明度标志 TF
仅指示透明度索引 TI
是否对框架有任何意义。
如果 TF == true
则当前(全局或局部)调色板中的特定颜色索引在将当前帧与图像的其余部分组合时被视为透明。此索引存储在 TI
.
If yes, then does the palette stays the same when an image has no transparent regions, and does that mean we only get to use 255 unique index (as 1 index is always given to transparent tile)?
当图像没有透明区域时,TF == false
和 TI
值通常是垃圾,因此不会被 GIF 加载器解释。
作为一名 self-proclaimed GIF 专家,我试图尽可能简洁地在文档和 this 微型加载器的源代码中记录 GIF 的内部工作原理。
[更新:]
So, does that mean transparency is only included if the .gif file has frames. Meaning it is not a single image, but a sequence of images?
没有。即使 single-frame GIF 也允许包含图形控件 header,所以不可以。
Does GIF have a fixed palette of 256 colors, meaning the palette could not store more/less then that color range. I am asking this as you mentioned, that in a B/W image, only two color exists black and white, then what happens to the rest of the palette index? or like how does GIF format manages lower color spaces?
GIF 支持任何大小为 2 的幂且介于 2 和 256 之间的调色板,结果为:2、4、8、16、32、64、128 或 256。
调色板大小由全局 GIF header 中的 bits 0 to 2 of the flags field 控制。