PNG文件格式的字节序? [英] PNG file format endianness?
问题描述
我不确定endian是否是正确的单词,但是..
Im not sure if endian is the right word but..
我一直在通过PNG文件进行解析,并且我注意到所有的整数值都是大尾数形式.这是真的吗?
I have been parsing through a PNG file and I have noticed that all of the integer values are in big endian. Is this true?
例如,宽度和高度作为32位无符号整数存储在PNG文件中.我的图片是16x16,并在文件中存储为:
For example, the width and height are stored in the PNG file as 32bit unsigned integers. My image is 16x16 and in the file its stored as:
00 00 00 10
何时应该:
10 00 00 00
这是真的还是我缺少什么?
Is this true or is there something I am missing?
推荐答案
是的,根据规范,整数必须采用网络字节顺序(大字节序):
Yes, according to the specification, integers must be in network byte order (big endian):
所有需要一个以上字节的整数应按网络字节顺序排列:最高有效字节在前,然后较低有效字节按重要性降序排列(MSB LSB为两字节整数,MSB B2 B1 LSB为四字节) -byte整数).字节的最高位(值128)编号为位7;最低位(值1)编号为位0.除非另有说明,否则值是无符号的.明确表示为带符号的值用二进制补码表示.
All integers that require more than one byte shall be in network byte order: the most significant byte comes first, then the less significant bytes in descending order of significance (MSB LSB for two-byte integers, MSB B2 B1 LSB for four-byte integers). The highest bit (value 128) of a byte is numbered bit 7; the lowest bit (value 1) is numbered bit 0. Values are unsigned unless otherwise noted. Values explicitly noted as signed are represented in two's complement notation.
http://www. w3.org/TR/2003/REC-PNG-20031110/#7整数和字节顺序
这篇关于PNG文件格式的字节序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!