【问题标题】:What does the 'h' stand for in the hexadecimal value '4D42h', and why are the bytes reversed?十六进制值“4D42h”中的“h”代表什么,为什么字节颠倒了?
【发布时间】:2014-09-21 21:05:28
【问题描述】:

我目前正在阅读 BMP 文件格式和用于定义位图文件头的I've come across the following lines of code。

typedef struct _WinBMPFileHeader
{
    WORD   FileType;     /* File type, always 4D42h ("BM") */
    DWORD  FileSize;     /* Size of the file in bytes */
    WORD   Reserved1;    /* Always 0 */
    WORD   Reserved2;    /* Always 0 */
    DWORD  BitmapOffset; /* Starting position of image data in bytes */
} WINBMPFILEHEADER;

第一条评论声称4D42h 与BM 相同。

According to Wikipedia 4D 是 M 的十六进制 ASCII 代码,而 42 是 B 的 ASCII 代码。

不过,h 代表什么?

为什么4D42h 不等同于MB?

【问题讨论】:

    标签: ascii endianness bitmapimage hex


    【解决方案1】:

    在此上下文中,h 代表十六进制表示法。

    对于顺序,您需要考虑处理器的字节顺序,在这种情况下,它们以不同的字节顺序存储在磁盘上,而不是逻辑上存储在内存中。

    【讨论】:

    • 谢谢。我熟悉用于表示十六进制值的0x## 约定,但我从未遇到过##h。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-19
    • 2011-08-05
    相关资源
    最近更新 更多