나는 다음과 같은 코드가 있습니다CImage를 사용하여 그레이 스케일 BMP의 char 배열을 올바르게로드하려면 어떻게합니까?
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"이 원인이 될 수 당신이에 관해서는 어떤 아이디어가있는 경우
/I 변경해야하는지, 나는 도움을 감사하겠습니다!
: 확인)
이미지 파일이 예상하는 디렉토리에 없습니다. –
이미지가 프로그램과 동일한 디렉토리에 있으며 이미지를로드하는 데 문제가 없습니다. –