GIF颜色表公式
在此处注明的 GIF 规范中:
http://www.w3.org/Graphics /GIF/spec-gif89a.txt
它给出了以下计算颜色表大小的公式:
3 x 2^(全局颜色表的大小+1)。
鉴于此,他们使用“x”而不是“*”,我是否正确地假设“^”不代表“异或”?如果是这样的话,“^”是什么意思?
谢谢。
In the GIF specifications noted here:
http://www.w3.org/Graphics/GIF/spec-gif89a.txt
It gives the following formula for calculating the color table size:
3 x 2^(Size of Global Color Table+1).
Given this they use 'x' instead of '*', am I correct in assuming '^' does not mean XOR? If that is the case, what does '^' mean?
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
^
通常用于求幂,而2
是一种非常常见的底数。颜色表大小
变量表示为三位值,与 +1 组合表示颜色表介于 2 到 256 种颜色之间。这确实符合 GIF 格式。(在 C 语言中,您可以将其写为
6 << Size_of_global_color_table
)^
is commonly used for exponentiation, and2
is a very common base for that.The
Size of Color Table
variable is noted as a three-bit value, with in combination with the +1 means that the color table is between 2 and 256 colors. That indeed matches the GIF format.(In C, you'd write this as
6 << Size_of_global_color_table
)^ 表示功率。因此,它是全局颜色表大小的 2 次幂 + 1。基本上,以 2 为基数的东西可以通过左移操作轻松地求幂到一个值。所以,你不需要 pow() API。只需执行以下操作即可。 2<<; (全局颜色表大小)。例如,2^3 等于 2 << 2. 一般来说,公式如下,2^n 等于 2<< (n-1)。
您可以从以下链接下载解码器逻辑和详细信息 - http://www.tune2wizard.com/gif -解码器/
^ means power. So, it is 2 raise to the power of size of global colour table + 1. Basically, something as a base 2 can be powered to a value easily by left shift operation. So, you don't need pow() API. Just do the following . 2 << ( global_colour_table_size). For example, 2^3 is equal to 2 << 2. In general the formula is the following, 2^n is equal to 2<< (n-1).
You can download the decoder logic and details from the following link - http://www.tune2wizard.com/gif-decoder/
从全局颜色表中获取颜色数和字节数的 C# 代码
C# code to get the number of colors and bytes from the Global Color Table