本文介绍了VC ++ _如何通过二进制系统在“图片控件"中显示图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取一个24位的位图并将其显示在图片框中.我找到了两种方法来解决此问题,但都失败了.
请帮帮我!


对话框中有一个图片控件",其类型为位图".
函数"PhDrawFixUpA"获取24位位图.


第一个代码:

I want to get a 24-Bit bitmap and display it into a Picture Box.I find 2 ways to solve this question but both failed.
Please help me!


There is a ''Picture Control'' whose type is Bitmap in a dialog.
The function ''PhDrawFixUpA'' gets the 24-Bit bitmap.


First One Code:

char * szPicData = (char*)malloc(4000000);
PhDrawFixUpA(szPicData);
BITMAPFILEHEADER bmpFileHeader;
memcpy(&bmpFileHeader,szPicData,sizeof(BITMAPFILEHEADER));
BITMAPINFOHEADER bmpInfoHeader;
memcpy(&bmpInfoHeader,szPicData+sizeof(BITMAPFILEHEADER),sizeof(BITMAPINFOHEADER));
BITMAPINFO bmpInfo;
memcpy(&bmpInfo,szPicData+sizeof(BITMAPFILEHEADER),sizeof(BITMAPINFO));
BITMAP bitmap;
bitmap.bmType = 0;
bitmap.bmWidth = bmpInfoHeader.biWidth;
bitmap.bmHeight = bmpInfoHeader.biHeight;
bitmap.bmWidthBytes = (bmpInfoHeader.biWidth*bmpInfoHeader.biBitCount/8 + 3)/4*4;
bitmap.bmPlanes = 1;
bitmap.bmBitsPixel = bmpInfoHeader.biBitCount;
bitmap.bmBits = szPicData+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFO);
static HBITMAP hBitmap = CreateBitmapIndirect(&bitmap);
SendDlgItemMessage(hDlg,IDP_DRAWPIC,STM_SETIMAGE,IMAGE_BITMAP,(LPARAM)hBitmap);




问题是我在图片控件"中看不到任何内容.



第二个密码:




The problem is I can''t see anything in the ''Picture Control''.



Second One Code:

char * szPicData = (char*)malloc(4000000);
PhDrawFixUpA(szPicData);
BITMAPFILEHEADER bmpFileHeader;
memcpy(&bmpFileHeader,szPicData,sizeof(BITMAPFILEHEADER));
BITMAPINFOHEADER bmpInfoHeader;
memcpy(&bmpInfoHeader,szPicData+sizeof(BITMAPFILEHEADER),sizeof(BITMAPINFOHEADER));
BITMAPINFO bmpInfo;
memcpy(&bmpInfo,szPicData+sizeof(BITMAPFILEHEADER),sizeof(BITMAPINFO));
static HBITMAP hBitmap = CreateBitmap(bmpInfoHeader.biWidth, bmpInfoHeader.biHeight,1,
      bmpInfoHeader.biPlanes,szPicData+sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFO));

SendDlgItemMessage(hDlg,IDP_DRAWPIC,STM_SETIMAGE,IMAGE_BITMAP,LPARAM)hBitmap);




问题是我可以在图片控件"中看到内容,但该图像不是预期的图像.
备注:
我将图片数据"szPicData"作为位图文件保存到磁盘中,我可以看到想要的内容.




The problem is I can see things in the ''Picture Control'', but the image is not the intended one.
Remark:
I save the Picture Data ''szPicData'' as a bitmap file into my disk,and I can see what I want to.

推荐答案


这篇关于VC ++ _如何通过二进制系统在“图片控件"中显示图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 06:27