我有以下代码:
cout<<"Please enter the name of your BMP image file: "<<endl;
cin>>fname;
nP = fname.c_str();
CImage input = CImage();
input.Load(nP);
// allocate space for host source image
unsigned char *pHI, *pCI;
width = input.GetWidth();
height = input.GetHeight();
pCI = (unsigned char *)input.GetBits();
pHI = (unsigned char *)malloc(sizeof(unsigned char) * width * height);
// fill array with CImage array content
srand (time(NULL));
for (int cnt = 0; cnt < sizeof(unsigned char) * width * height; cnt++){
pHI[cnt] = pCI[cnt];
}
但是当我尝试获取宽度和高度时,程序给了我一个错误。
“调试断言失败!...表达式:m_hBitmap != 0”
如果您对可能导致此问题的原因/我应该更改的内容有任何想法,我将不胜感激!
:)