My small white one, CImage class is not very good, hope to have a big show a
The code
Void CzdljDlg: : OnBnClickedButton2 ()
{
CImage img.
Cstrings ipath=_T (" C: \ Users MAC \ \ Desktop \ shortest path - copy \ ZDLJ/res/t1 1 -- 2. PNG ");
If (IsIconic ())
{
CPaintDC dc (this);//for drawing device context
The SendMessage (WM_ICONERASEBKGND, reinterpret_cast & lt; WPARAM> (dc) GetSafeHdc ()), 0);
//make the icon is centered within the workspace rectangular
Int cxIcon=GetSystemMetrics (SM_CXICON);
Int cyIcon=GetSystemMetrics (SM_CYICON);
CRect the rect.
GetClientRect (& amp; The rect);
Int x=(the rect. Width () - cxIcon + 1)/2;
Int y=(the rect. Height () - cyIcon + 1)/2;
//draw the icon
Dc. DrawIcon (x, y, m_hIcon);
}
The else
{
CPaintDC dc (this);
if(! Img. The IsNull ()) img. Destroy ();
Img. Load (ipath);//the load load, otherwise don't show
TransparentPNG (& amp; Img);//transparent processing function called
if(! Img img. IsNull ()). The Draw (dc m_hDC, 15, 14);
CDialogEx: : OnPaint ();
}
}
Void CzdljDlg: : TransparentPNG (CImage * PNG)
{
for(int i=0; I & lt; PNG - & gt; GetWidth (); I++)//traverse pixel processing
{
for(int j=0; J & lt; PNG - & gt; GetHeight (). J++)
{
Unsigned char * pucColor=reinterpret_cast & lt; Unsigned char * & gt; (PNG - & gt; GetPixelAddress (I, j));
PucColor [0]=pucColor pucColor [0] * [3]/255;
PucColor [1]=pucColor pucColor [1] * [3]/255;
PucColor [2]=pucColor * pucColor [2] [3]/255;
}
}
}
CodePudding user response:
A single '\' is the escape character, path with '\ \'Cstrings ipath=_T (" C: \ \ Users \ \ MAC \ \ Desktop \ \ shortest path - copy \ \ ZDLJ \ \ res \ \ t1 1 -- 2. PNG ");
CodePudding user response:
Compile, all, pass theWarning C4129: 'U' : unrecognized character escape sequence
Warning C4129: 'M: unrecognized character escape sequence
Warning C4129: 'D' : unrecognized character escape sequence
CodePudding user response: