我无法确定gif89a spec https://www.w3.org/Graphics/GIF/spec-gif89a.txt中的“颜色分辨率”字段和“全局颜色表的大小”字段之间的区别(第9-10页):
颜色分辨率-每一主要颜色的位数.,减去1。这个值表示整个调色板的大小。全球颜色表的大小-.若要确定颜色表的实际大小,请将2提高到字段+ 1的值。 ..。 全局颜色表是一个表示红-绿-蓝三色三胞胎的字节序列.并包含等于3x2^(全局颜色Table+1的大小)的字节数。
假设我们想要创建一个3种颜色的图像,红色,绿色和蓝色。在这种情况下,我们至少需要ceil(log2(3)) =每种颜色2位(00 =红色,01 =绿色,10 =蓝色)。然后,根据规范,颜色分辨率(CR)字段必须设置为ceil(log2(3)) -1=2-1= 1:
packed fields = X001XXXX
---
CR field更广泛地说,如果N是颜色的数目,那么CR = ceil(log2(N)) - 1。
关于全局颜色表( GCT )的大小,1种颜色需要3 RGB字节,因此条目数=字节数/3=2^(GCT+1的大小)。由于我们想存储3种颜色,所以我会选择3之后的2的幂(log2(3))= 2^2 = 4。然后,2^( GCT + 1) = 2^ ceil(log2(3)),GCT +1= ceil(log2(3))和GCT = ceil(log2(3)) -1=2-1= 1:
packed fields = XXXXX001
---
Size of GCT field同样,如果N是颜色的数目,那么GCT = ceil(log2(N)) - 1的大小。
如你所见,CR = GCT = ceil(log2(N)) - 1,似乎CR字段和GCT字段的大小始终保持相同的值。我想我错了,因为如果我是对的,这两个字段中的一个将是无用的,但到目前为止,我还没有在规范中找到任何说明。
我并不是唯一感到困惑的人:bytes.html。本文将GCT字段大小的定义应用于CR字段,而GCT字段的大小根本没有定义:
..。颜色分辨率..。允许您计算GCT的大小。如果该字段的值为N,则全局颜色表中的条目数将为2^ (N+1) .因此,样本图像中的001代表2位/像素;111表示8位/像素。
有人知道这两个领域有什么不同吗?
发布于 2019-07-25 23:25:48
从规范中:
iv) Color Resolution - Number of bits per primary color available
to the original image, minus 1. This value represents the size of
the entire palette from which the colors in the graphic were
selected, not the number of colors actually used in the graphic.
For example, if the value in this field is 3, then the palette of
the original image had 4 bits per primary color available to create
the image. This value should be set to indicate the richness of
the original palette, even if not every color from the whole
palette is available on the source machine.因此,为了清楚,颜色分辨率被认为是每个颜色的比特数(小于1),在原始图像的GIF是从。
https://stackoverflow.com/questions/57210687
复制相似问题