I have the following code:
Image *img=Image::FromFile(currentImagePath.c_str(), false);
Bitmap* pBitmap = static_cast<Bitmap*>(img/*->Clone()*/);
HBITMAP handleToSliceRet=NULL;
Status status = pBitmap->GetHBITMAP(Color(0,0,0), &handleToSliceRet);
I have initialized gdi and everything, but when I try to run this, if I uncomment the /->Clone()/ the debugger will say Access violation reading 0x0000
and if I leave it commented, it fails on the line Status status = pBitmap->GetHBITMAP(Color(0,0,0), &handleToSliceRet);
with another access violation. I've been at this for about 6 hours now to no avail.
The current path of the image I'm trying to process is "C:\cube\cube0000.png"
Bitmap
derives fromImage
, not the other way around.Image::FromFile
returns anImage
, not aBitmap
- and you can't just cast it into existence.Instead, use
Bitmap::FromFile
from the beginning to get a realBitmap
object.