Home > Software engineering >  CImage unable to remove the PNG image problem
CImage unable to remove the PNG image problem

Time:03-14

Novice to teach, how should change, m_PictureGoods is Picture Control
 void CDialog_Tab3: : OnLvnItemchangedListCommoditySel (NMHDR * pNMHDR, LRESULT * pResult) 
{
LPNMLISTVIEW pNMLV=reinterpret_cast & lt; LPNMLISTVIEW> (pNMHDR);
//TODO: add the control notification handler code
If (pNMLV - & gt; IItem!=1)
{
M_dwCommoditySelItem=pNMLV - & gt; IItem.
//display picture
CImage Image;

//CBitmap Bitmap.
//HBITMAP HBITMAP;
Char path [MAX_PATH]={0};
Char szBuffer1 [20]={0};
Char szBuffer2 [5]={0};
GetCurrentDirectory (MAX_PATH, path);
M_listCommoditySel. GetItemText (m_dwCommoditySelItem, 2, szBuffer1, sizeof (szBuffer1));//type
M_listCommoditySel. GetItemText (m_dwCommoditySelItem, 3, szBuffer2, sizeof (szBuffer2));//type son ID
Sprintf_s (path, "% s \ \ icon \ \ % s \ \ % s % s_0_0. The PNG", path, szBuffer1, szBuffer1, szBuffer2);
MyDbgPrintf (" path: % s ", path);
Image. The Load (path);
If (Image. The IsNull ())
{
MyDbgPrintf (" Image. The Load (path); Abnormal ");
return;
}
//processing transparent channel
If (Image. GetBPP ()==32)//confirm the Image contains Alpha channel
{
Int I=0, j=0;
for (; i {
for (; J & lt; Image. GetHeight (); J++)
{
BYTE * pByte=(BYTE *) Image. GetPixelAddress (I, j);
PByte [0]=pByte pByte [0] * [3]/255;
PByte [1]=pByte pByte [1] * [3]/255;
PByte [2]=pByte * pByte [2] [3]/255;
}
}
}
Image. The Draw (m_pictureGoods. GetDC () - & gt; M_hDC, 0, 0);
Image. The Destroy ();
M_pictureGoods. ReleaseDC (m_pictureGoods GetDC ());
//hBitmap=(hBitmap) LoadImage (AfxGetInstanceHandle (), path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
//hBitmap=(hBitmap) Bitmap. GetSafeHandle ();
//m_pictureGoods SetBitmap (hBitmap);
}

* pResult=0;
}

CodePudding user response:

CStatic + CImage implement a simple picture display control

CodePudding user response:

6666 love the love
  • Related