I created a simple code which draws a PNG image with alpha layer in a dialogbox & used this code:
void CBmpPngDlg::OnPaint()
{
CPaintDC dc(this);
HRSRC hResource = ::FindResource(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_PNG2), _T("PNG"));
CXTPGraphicBitmapPng bmpPNG;
if (!bmpPNG.LoadFromResource(::AfxGetInstanceHandle(), hResource))
{
TRACE0("Failed to load PNG from resource\n");
return;
}
CBitmap bmp;
if (bmp.Attach(CXTPImageManagerIcon::PreMultiplyAlphaBitmap(bmpPNG)))
{
CXTPImageManagerIcon::DrawAlphaBitmap(&dc, bmp, CPoint(0, 0), CSize(344, 344));
bmp.Detach();
bmpPNG.DeleteObject();
}
}
& I am confused on using the CGdiObject::Attach, CGdiObject::Detach & CGdiObject::DeleteObject GDI functions. So is this code correct?:
bmp.Attach(CXTPImageManagerIcon::PreMultiplyAlphaBitmap(bmpPNG));
bmp.Detach();
bmpPNG.DeleteObject();
or should i use this:
bmp.Attach(CXTPImageManagerIcon::PreMultiplyAlphaBitmap(bmpPNG));
bmpPNG.Detach();
bmpPNG.DeleteObject();
or it is not necessary to use it.
Is the code
bmpPNG.DeleteObject();
necessary?
Help me please :confused:
[Original Question Title]
CGdiObject::Attach & CGdiObject::Detach & CGdiObject::DeleteObject
[/Original Question Title]