The following example uses cimage: Create () to create a PNG Image m_savepng, and copy an existing cimage m_pngdraw to it, but leave a circle of pixels around it for editing. The edit entry is black.
The created PNG can be operated like a cimage object that comes in with normal load.
When the pixel is set to black, you must set its alpha channel to 255. Otherwise, the Black is transparent and cannot be displayed.
// Cimage * m_pngdraw
// Cimage m_savepng
If (! M_savepng.isnull ())
{
M_savepng.destroy ();
}
// When creating a PNG image, the default value 0 is used for the last create parameter instead of createalphachannel.
M_savepng.create (m_pngdraw-> getwidth () + 2, m_pngdraw-> getheight () + 2, 32, cimage: createalphachannel );
HDC = m_savepng.getdc (); // obtain the HDC of the target drawing Area
// Draw from behind the scenes () and set aside a circle of pixels
M_pngdraw-> draw (HDC, 1, 1 );
// The first column in the vertical direction
For (Int J = 1; j <m_vertpointlist.getcount (); j ++)
{
// M_vertpointlist the linked list stores some cpoint
Position posh0 = m_vertpointlist.findindex (J-1 );
Position posh1 = m_vertpointlist.findindex (j );
Cpoint pth0 = m_vertpointlist.getat (posh0 );
Cpoint pth1 = m_vertpointlist.getat (posh1 );
If (J % 2 = 0) // when the even number is reached, the strip is stretched between the original vertex and the original vertex.
{
For (int K = pth0.y; k <pth1.y; ++ K)
{
Unsigned char * puccolor = reinterpret_cast <unsigned char *> (m_savepng.getpixeladdress (0, k ));
Puccolor [0] = 0;
Puccolor [1] = 0;
Puccolor [2] = 0;
Puccolor [3] = 255; // alpha channel (transparency)
}
}
}
// The first Horizontal Column
............................
M_savepng.releasedc ();