thehumph
February 21st, 2008, 12:17 PM
Hi folks,
I'm working on an important university project, using native unmanaged Win32 C++ in the Visual Studio 2005 Professional IDE.
I have created a class Image to encapsulate and extend functionality from both Bitmap and BitmapData objects in GDI+ (gdiplus.h) for my own purposes. Part of this process has been to create a method Image::lockBits() to transfer the functionality of the Bitmap::LockBits() method. I am having trouble with binding my BitmapData object to the Bitmap object using image->LockBits(). The relevant articles of code are below, starting with my global declarations in the Image object:
Gdiplus::Bitmap * image;
Gdiplus::BitmapData imageData;
int width;
int height;
Then the function Image::lockbits:
int Image::lockBits (int originX, int originY, int areaX, int areaY)
{
Gdiplus::Rect rect (originX, originY, areaX, areaY);
image->LockBits(&rect,
Gdiplus::ImageLockModeRead | Gdiplus::ImageLockModeWrite,
PixelFormat8bppIndexed, imageData);
return 0;
}
As you can see my BitmapData object imageData is in the correct place, but in previous uses of GDI+ I have used &imageData instead, which seems to work. If I try the same practice here, I get the following error message in Visual Studio:
>c:\users\andy\documents\uni\bsc project\code\bscproject\image.cpp(212) : error C2664: 'Gdiplus::Bitmap::LockBits' : cannot convert parameter 4 from 'Gdiplus::BitmapData **__w64 ' to 'Gdiplus::BitmapData *'
> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Has anyone experienced this or can suggest any lines of further enquiry? This has placed a halt on my integration so any help would be appreciated! I am happy to provide further information about this problem on request.
Cheers,
thehumph
I'm working on an important university project, using native unmanaged Win32 C++ in the Visual Studio 2005 Professional IDE.
I have created a class Image to encapsulate and extend functionality from both Bitmap and BitmapData objects in GDI+ (gdiplus.h) for my own purposes. Part of this process has been to create a method Image::lockBits() to transfer the functionality of the Bitmap::LockBits() method. I am having trouble with binding my BitmapData object to the Bitmap object using image->LockBits(). The relevant articles of code are below, starting with my global declarations in the Image object:
Gdiplus::Bitmap * image;
Gdiplus::BitmapData imageData;
int width;
int height;
Then the function Image::lockbits:
int Image::lockBits (int originX, int originY, int areaX, int areaY)
{
Gdiplus::Rect rect (originX, originY, areaX, areaY);
image->LockBits(&rect,
Gdiplus::ImageLockModeRead | Gdiplus::ImageLockModeWrite,
PixelFormat8bppIndexed, imageData);
return 0;
}
As you can see my BitmapData object imageData is in the correct place, but in previous uses of GDI+ I have used &imageData instead, which seems to work. If I try the same practice here, I get the following error message in Visual Studio:
>c:\users\andy\documents\uni\bsc project\code\bscproject\image.cpp(212) : error C2664: 'Gdiplus::Bitmap::LockBits' : cannot convert parameter 4 from 'Gdiplus::BitmapData **__w64 ' to 'Gdiplus::BitmapData *'
> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Has anyone experienced this or can suggest any lines of further enquiry? This has placed a halt on my integration so any help would be appreciated! I am happy to provide further information about this problem on request.
Cheers,
thehumph