Februray 7th Wednesday (一月 七日 水曜日)

本文详细介绍了如何在Windows环境下加载并显示位图文件。文章解析了位图文件的结构,包括文件头、信息头、调色板及图像数据等部分,并探讨了不同颜色模式下的像素表示方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  I learned how to display a bitmap file at Windows.  A normal bitmap file is consist of four parts:
BITMAPFILEHEADER, BITMAPINFOHEADER, Palette, ImageData.  The palette is an array of colors.  Every
pixel datum is an index of that palette.  In this way, the size of a bitmap file can be reduced.

  The size of BITMAPFILEHEADER is just 14 bytes.  The first member of it is "bfType", which is used
to check whether this file is a bitmap file.  Normally, its value in a bitmap is 0x424D -- "BM".  The
second member is "bfSize" that is store the size of the whole bitmap file.  "bfOffBits" is its last
member, which tell us where is the begin of image data in the bitmap file.

  In BITMAPINFOHEADER, "biBitCount" is one of its important member.  It not only represent which color
mode is a bitmap file, but also indicate how many bytes is used to present a pixel on screen.  The 24
bits true color mode has so much color that a bitmap file in true color has no its own palette.  In that
case, every pixel is represented by three byte -- R, G, B.

  I wrote a function to load a bitmap file by specified file name.  Because of the vice of Windows APIs,
my load function have to create a block of memory depending on a device context.  The device context likes
a buffer behind a window object.  So, when repainting a window it copy data from the buffer to the screen.
In this way, a bitmap file is displayed on the screen. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值