我想把一张图片作为背景用途,但发现读过书本中没有介绍这个东东。所以有以下的疑问:
1.c语言无法插入图片。
2.c语言中没有这种直接插入图片的函数。
那究竟如何编译代码来插入一张jpg,bmp等等格式的图片?
请大家帮帮忙,告诉我具体的方法(一定是c语言哦,我还没学习到c++,c#等其他语言)
如果有相关的资料,恳请大家把其下载的地址告诉我(如果是这个论坛的资源,我还没有足够的积分下载.嘻嘻!!)
6 个解决方案
#1
dingqi
#2
帮你顶吧
#3
#include <windows.h>
loadimage or loadbitmap + bitblt
loadimage or loadbitmap + bitblt
#4
thanks..另外告诉你们一个好消息,苹果公司将在1月28号凌晨2点发布新产品哦。。又是一场革新啊~~
#5
??什么东东??
#6
IPicture* p=NULL;
IStream* s=NULL;
HGLOBAL hG;
void* pp;
FILE* fp;
// Read file in memory
fp = fopen(FileName,"rb");
if (!fp)
return NULL;
fseek(fp,0,SEEK_END);
int fs = ftell(fp);
fseek(fp,0,SEEK_SET);
hG = GlobalAlloc(GPTR,fs);
if (!hG)
{
fclose(fp);
return NULL;
}
pp = (void*)hG;
fread(pp,1,fs,fp);
fclose(fp);
CreateStreamOnHGlobal(hG,false,&s);
if (!s)
{
GlobalFree(hG);
return NULL;
}
OleLoadPicture(s,0,false,IID_IPicture,(void**)&p);
if (!p)
{
s->Release();
GlobalFree(hG);
return NULL;
}
s->Release();
GlobalFree(hG);
HBITMAP hB = 0;
p->get_Handle((unsigned int*)&hB);
// Copy the image. Necessary, because upon p's release,
// the handle is destroyed.
HBITMAP hBB = (HBITMAP)CopyImage( hB,IMAGE_BITMAP,0,0,LR_COPYRETURNORG );
p->Release();
return hBB;
}
HBITMAP hbmp;
hbmp = LoadJPG( strFilePath );
if( hbmp != NULL)
{
m_bitmap.Detach();
m_bitmap.Attach(hbmp);
}
else
{
return;
}
#1
dingqi
#2
帮你顶吧
#3
#include <windows.h>
loadimage or loadbitmap + bitblt
loadimage or loadbitmap + bitblt
#4
thanks..另外告诉你们一个好消息,苹果公司将在1月28号凌晨2点发布新产品哦。。又是一场革新啊~~
#5
??什么东东??
#6
IPicture* p=NULL;
IStream* s=NULL;
HGLOBAL hG;
void* pp;
FILE* fp;
// Read file in memory
fp = fopen(FileName,"rb");
if (!fp)
return NULL;
fseek(fp,0,SEEK_END);
int fs = ftell(fp);
fseek(fp,0,SEEK_SET);
hG = GlobalAlloc(GPTR,fs);
if (!hG)
{
fclose(fp);
return NULL;
}
pp = (void*)hG;
fread(pp,1,fs,fp);
fclose(fp);
CreateStreamOnHGlobal(hG,false,&s);
if (!s)
{
GlobalFree(hG);
return NULL;
}
OleLoadPicture(s,0,false,IID_IPicture,(void**)&p);
if (!p)
{
s->Release();
GlobalFree(hG);
return NULL;
}
s->Release();
GlobalFree(hG);
HBITMAP hB = 0;
p->get_Handle((unsigned int*)&hB);
// Copy the image. Necessary, because upon p's release,
// the handle is destroyed.
HBITMAP hBB = (HBITMAP)CopyImage( hB,IMAGE_BITMAP,0,0,LR_COPYRETURNORG );
p->Release();
return hBB;
}
HBITMAP hbmp;
hbmp = LoadJPG( strFilePath );
if( hbmp != NULL)
{
m_bitmap.Detach();
m_bitmap.Attach(hbmp);
}
else
{
return;
}