GetDIBitsThe GetDIBits function retrieves the bits of the specified compatible bitmap and copies them into a buffer as a DIB using the specified format.
Depends if the 16 bit colour mode you are using is 1:5:5:5 or 5:6:5. Basically just chop off the least significant bits for each colour to make up your new 16 bit colour. i.e. For 5:6:5 16 bit colour WORD Colour16 = 0; Colour16 |= ((red24 / 8) & 0x1f) << 11; // 5 Most significant red bits into high byte of colour Colour16 |= ((green24 / 4) & 0x3f) << 5; // 6 Most significant green Colour16 |= ((blue 24 / 8) & 0x1f);
You can check out http://www.wotsit.org/ and find the specs for BMP files and see how they are stored. Their are many examples on how to save bitmaps
2 再用GetObject()得到HBITMAP句柄的位图信息
3 然后通过GetDIBits()提取RGB像素数组
4 最后转为565内存结构
Basically just chop off the least significant bits for each colour to
make up your new 16 bit colour. i.e. For 5:6:5 16 bit colour WORD Colour16 = 0; Colour16 |= ((red24 / 8) & 0x1f) << 11; // 5 Most significant red bits
into high byte of colour
Colour16 |= ((green24 / 4) & 0x3f) << 5; // 6 Most significant green
Colour16 |= ((blue 24 / 8) & 0x1f);
BMP文件是24位,输出二进制流为565(RGB)。 Practise_Think(时代“过客”) 说的好像跟我有的BCB的源代码类似,但。不知道用VC如何实现。
如: bit2bmp(void *ram, char *filename)
2 再用GetObject()得到HBITMAP句柄的位图信息
3 然后通过GetDIBits()提取RGB像素数组
4 最后转为565内存结构第四步laiyiling(◆陌生人◆MVP◆) 的方法可行。
但不知前三步怎么做?