使用缓冲存储器数据创建图像 [英] Image Creation using buffer memory data
本文介绍了使用缓冲存储器数据创建图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
我正在开发一个程序,其中,我正在接收图像的字节,并在存储之后创建一个位图来显示。
这是我的主要代码请看这个..
Hello all!
I''m working on a program in which, I''m receiving the bytes of an image and after storing this creating a bitmap to display.
This is my Main code Please see this..
static char buff[MAX_SIZE];
int num;
//receiving the bytes from a client
num=recv(Socket, buff, sizeof(buff), 0);
// progress the buffer
tagBITMAPFILEHEADER bfh = *(tagBITMAPFILEHEADER*)buff;
tagBITMAPINFOHEADER bih = *(tagBITMAPINFOHEADER*)(buff+sizeof(tagBITMAPFILEHEADER));
RGBQUAD rgb = *(RGBQUAD*)(buff+sizeof(tagBITMAPFILEHEADER)+sizeof(tagBITMAPINFOHEADER));
BITMAPINFO bi;
bi.bmiColors[0] = rgb;
bi.bmiHeader = bih;
char* pPixels = (buff+bfh.bfOffBits);
char* ppvBits;
hbitmap = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, (void**) &ppvBits, NULL, 0);
SetDIBits(NULL, hbitmap, 0, bih.biHeight, pPixels, &bi, DIB_RGB_COLORS);
GetObject(hbitmap, sizeof(BITMAP), &cBitmap);
我无法根据收到的数据创建位图..
我认为代码有问题。
先谢谢你的帮助!
I''m unable to create a bitmap from the data received..
I think something wrong with code.
Thanks in advance for your help!
推荐答案
仔细阅读文档: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v = vs.85)。 aspx [ ^ ]
您最好使用清晰且已知的样本图像进行编码,并检查标头和数据是否被核心传输和检索。
我的提示是,背投错了。
read the docs carefully: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183376(v=vs.85).aspx[^]
You better code with a clear and known sample image, and check whether the header and data are transmitted and retreived corectly.
My tip is, that the backcast goes wrong.
这篇关于使用缓冲存储器数据创建图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文