如何判断一个16位位图是5,6,5格式还是5,5,5格式

foenix 2000-05-30 02:12:00
...全文
146 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Smile_Tiger 2000-05-30
  • 打赏
  • 举报
回复
一个位图一般就是565和555格式

将位图关联到一个DC设备,获取左上角点,然后在左上角写入白色块
用GetDibits获取bitmap数据
判断array for bitmap bits的第一个点,
如果最高位为1,则是565,否则是555
sanhan 2000-05-30
  • 打赏
  • 举报
回复
MSDN说的和我引用的并不矛盾。
哪一个更易懂好用,大家试试就知道了。

FOURCC就是biCompression的值,bpp就是biBitCount的值。
davyguo 2000-05-30
  • 打赏
  • 举报
回复
只做过判断显卡支持的格式.
Smile_Tiger 2000-05-30
  • 打赏
  • 举报
回复
sanhan的说法好象有些不对

以下是MSDN关于BITMAPINFOHEADER,biBitCount字段 = 16的一段话

16 The bitmap has a maximum of 2^16 colors. If the biCompression member of the BITMAPINFOHEADER is BI_RGB, the bmiColors member is NULL. Each WORD in the bitmap array represents a single pixel. The relative intensities of red, green, and blue are represented with 5 bits for each color component. The value for blue is in the least significant 5 bits, followed by 5 bits each for green and red. The most significant bit is not used. The bmiColors color table is used for optimizing colors used on palette-based devices, and must contain the number of entries specified by the biClrUsed member of the BITMAPINFOHEADER.
If the biCompression member of the BITMAPINFOHEADER is BI_BITFIELDS, the bmiColors member contains three DWORD color masks that specify the red, green, and blue components, respectively, of each pixel. Each WORD in the bitmap array represents a single pixel.

Windows NT: When the biCompression member is BI_BITFIELDS, bits set in each DWORD mask must be contiguous and should not overlap the bits of another mask. All the bits in the pixel do not have to be used.

Windows 95 and Windows 98: When the biCompression member is BI_BITFIELDS, the system supports only the following 16bpp color masks: A 5-5-5 16-bit image, where the blue mask is 0x001F, the green mask is 0x03E0, and the red mask is 0x7C00; and a 5-6-5 16-bit image, where the blue mask is 0x001F, the green mask is 0x07E0, and the red mask is 0xF800.
sanhan 2000-05-30
  • 打赏
  • 举报
回复
555是缺省的16bit BITMAP格式,其FOURCC为BI_RGB,bpp为16;
565是扩充格式,FOURCC为BI_BITFIELDS,bpp为16,rgb掩模为
0xF800,0x07E0,0x001F。

两者区别很大,怎么会分不开呢?
Smile_Tiger 2000-05-30
  • 打赏
  • 举报
回复
因为只有辨别位图中的白色块的最高位才能判断格式,

关联DC的目的是为了写入一个白色块,写入一个白色块的目的是为了获得白色块

如果你知道该位图的某个位置是白色块,我想也可以不关联

不过GetDibits函数需要DC参数
foenix 2000-05-30
  • 打赏
  • 举报
回复
如果我不想关联到DC呢?

16,467

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧