使用MFC将白色背景透明化时遇到读取字符串时字符出错,以及字符串中字符无效
void CMVScameraDlg::TransparentPNG(ATL::CImage* png)
{
if(img.GetBPP() == 32)
for (int i = 0; i < png->GetWidth(); i++) //遍历像素处理
{
for (int j = 0; j < png->GetHeight(); j++)
{
unsigned char* pucColor = reinterpret_cast<unsigned char*>(png->GetPixelAddress(i, j));
pucColor[0] = pucColor[0] * pucColor[3] / 255;
pucColor[1] = pucColor[1] * pucColor[3] / 255;
pucColor[2] = pucColor[2] * pucColor[3] / 255;
}
}
运行到 unsigned char* pucColor = reinterpret_cast<unsigned char*>(png->GetPixelAddress(i, j));时,出现第一个错误
往下运行出现第二个错误
图片能够正常显示,就卡在了背景透明化这里,求解答