1.文件: HBITMAP hmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),"D:\\map1.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE); ((CStatic*)GetDlgItem(IDC_PIC1))->SetBitmap(hmap); 2.流: STDAPI OleLoadPicture( IStream * pStream, //Pointer to the stream that contains picture's data LONG lSize, //Number of bytes read from the stream BOOL fRunmode, //The opposite of the initial value of the picture's // property REFIID riid, //Reference to the identifier of the interface // describing the type of interface pointer to return VOID ppvObj //Address of output variable that receives interface // pointer requested in riid ); 或者 CBitmap::CreateBitmap BOOL CreateBitmap( int nWidth, int nHeight, UINT nPlanes, UINT nBitcount, const void* lpBits ); 云云
LoadImage();
LoadBitmap();
2.从流中传递过来的图片数据,直接输出到picture里。
OleLoadPicture();
HBITMAP hmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),"D:\\map1.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
((CStatic*)GetDlgItem(IDC_PIC1))->SetBitmap(hmap);
2.流:
STDAPI OleLoadPicture(
IStream * pStream,
//Pointer to the stream that contains picture's data
LONG lSize, //Number of bytes read from the stream
BOOL fRunmode,
//The opposite of the initial value of the picture's
// property
REFIID riid, //Reference to the identifier of the interface
// describing the type of interface pointer to return
VOID ppvObj //Address of output variable that receives interface
// pointer requested in riid
);
或者
CBitmap::CreateBitmap
BOOL CreateBitmap( int nWidth, int nHeight, UINT nPlanes, UINT nBitcount, const void* lpBits );
云云
首先,我先将bmp文件读入到一个数组中,然后用CreateBitmap构造bitmap类,送到picture控件中显示。代码如下:
ifstream source;
source.open("e:\\N70_main.bmp",ios::binary|ios::in);
if(!source)
{
MessageBox("Create ifstream fail");
}
int i=0;
char *src;
char ch;
while(source.get(ch))
{
i++;
}
int count=i;
source.close();
src=new char[count];
source.open("e:\\test.bmp",ios::binary|ios::in);
if(!source)
{
MessageBox("Create ifstream fail");
}
i=0;
while(source.get(ch))
{
src[i]=ch;
i++;
}
source.close();
CBitmap hmap;
hmap.CreateBitmap(302,186,1,24,src);
((CStatic*)GetDlgItem(IDC_PICTURE_MOBILE))->SetBitmap(hmap);
dest.close();
delete [] src;
为什么在picture控件中什么都没有,CreateBitmap的返回值是1,这个我看了。请大家继续帮帮忙呀
http://www.vckbase.com/document/viewdoc/?id=674
另外,jpg的显示大家有没有什么办法,除了用某些activeX控件。我还是想把它转成bitmap,放到控件里显示