B
bern11
What is the best way to access the bits in a bitmap loaded into an
image control (I'm converting a color image to greyscale). I have a
method which works, but it seems kindof cludgy. Here is what I did:
HBITMAP hSrcBmp; // GDI Bitmap Handle
BITMAP SrcBmp; // GDI Bitmap
int iStatus, iDims[2];
char *cSrc; // Pointer to Bits
// MyImagePbx is a picturebox control with an bitmap already loaded
// EditSrcBmp is a global Bitmap^
EditSrcBmp = gcnew Bitmap(MyImagePbx->Image);
// Create? a GDI bitmap
hSrcBmp = (HBITMAP)EditSrcBmp->GetHbitmap().ToInt32();
// Get bitmap object
iStatus = GetObject(hSrcBmp,sizeof(SrcBmp),&SrcBmp);
// Now i have direct access
cSrc = (char *)SrcBmp.bmBits;
// Do I have to release or destroy the hSrcBmp bitmap handle?
It seems like there has to be a better way.
image control (I'm converting a color image to greyscale). I have a
method which works, but it seems kindof cludgy. Here is what I did:
HBITMAP hSrcBmp; // GDI Bitmap Handle
BITMAP SrcBmp; // GDI Bitmap
int iStatus, iDims[2];
char *cSrc; // Pointer to Bits
// MyImagePbx is a picturebox control with an bitmap already loaded
// EditSrcBmp is a global Bitmap^
EditSrcBmp = gcnew Bitmap(MyImagePbx->Image);
// Create? a GDI bitmap
hSrcBmp = (HBITMAP)EditSrcBmp->GetHbitmap().ToInt32();
// Get bitmap object
iStatus = GetObject(hSrcBmp,sizeof(SrcBmp),&SrcBmp);
// Now i have direct access
cSrc = (char *)SrcBmp.bmBits;
// Do I have to release or destroy the hSrcBmp bitmap handle?
It seems like there has to be a better way.