一直在努力

坚持,坚持,再坚持 我一直在努力

导航

XBM中big endian And little endian的困惑

     xbm是一种图片格式,能用文本文件的方式来描述位图,具体信息可以参考http://www.fileformat.info/format/xbm/egff.htm

然而在具体解析xbm是,文档中有这样一句描述“with the first pixel in the bitmap (at position 0,0) represented by the high bit of the first byte in the array. ”

意思是说(0,0) 的位置应该用第一个字节的高位来表示,那么在这样的一个图形中

#define FOO_width 8 #define FOO_height 8 #define FOO_x_hot 0 #define FOO_y_hot 7
static unsigned char FOO_bits[] = {0x3F, 0x80, 0x00, 0x7C, 0x00, 0x82, 0x41, 0x00}; 
字节0x3E(0011 1111)的高位应该是什么呢?是最后一个1还是第一个0,结果是最后一个1,这个让人比较费解
在big endian情况下,
内存位置 0 1 2 3 4 5 6 7
         0 0 1 1 1 1 1 1
高位应该是1
在little endian下
内存位置 0 1 2 3 4 5 6 7
         1 1 1 1 1 1 0 0
高位应该是0
而在xbm的描述中并没有说明是big还是little为什么可以直接确认高位是1呢?是我对big little的理解不对? 还是xbm文档默认就是big

posted on 2010-10-17 16:21  朱竹  阅读(321)  评论(0编辑  收藏  举报