用WTL框架 在图片控件上贴图后不透明
这段是加载图片:bool ShowJpgGif(CImage& img,char* strPath)
{
IStream pStm;
int len = 0;
FILE f = fopen(strPath,"rb");
if (f != NULL)
{
fseek(f,0,SEEK_END);
len = ftell(f);
rewind(f);
HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, len);
LPVOID pvData = NULL;
if (hGlobal != NULL)
{
pvData = GlobalLock(hGlobal);
if (pvData != NULL)
{
fread(pvData,1,len,f);
fclose(f);
GlobalUnlock(hGlobal);
CreateStreamOnHGlobal(hGlobal, TRUE, &pStm);
img.Load(pStm);
if (img.GetBPP() == 32)
{
int i;
int j;
for (i = 0; i < img.GetWidth(); i++)
{
for (j = 0; j < img.GetHeight(); j++)
{
byte *pByte = (byte *)img.GetPixelAddress(i, j);
pByte[0] = pByte[0] * pByte[3] / 255;
pByte[1] = pByte[1] * pByte[3] / 255;
pByte[2] = pByte[2] * pByte[3] / 255;
}
}
}
GlobalFree(pStm);
return true;
}
else
return false;
}
else
return false;
}
这段是贴图上去
if(!ShowJpgGif(m_myImg,".\\res\\mainfram\\app.png"))
return ;
m_hBitmap = m_myImg.Detach();
m_quit = GetDlgItem(IDC_STATIC_APP);
m_quit.SetBitmap(m_hBitmap);
求各位大侠相助啊