BITMAPINFOHEADER + buffer to Magick::Image
Posted: 2010-12-30T17:37:43-07:00
Hello,
(Here is a similar topic I posted back earlier (and found a solution to).)
For a DirectShow application, I want to transfer a BITMAP image info a Magick::Image. Basically, I have a BITMAPINFOHEADER and a BYTE* buffer pointing to the pixel data of the bitmap described by the BITMAPINFOHEADER.
I have spent quite a bit of time trying to figure this out, but couldn't.
I found this post, but extracting the image_info members would be a really complicated function (converting from BITMAPINFOHEADER to Magick::ImageInfo). Also, for some reason ImageInfo.size is a char* array (how can I specify a 720x480 image with a char* array?). With more searching, I did find a DIBToImage() function here which does the job, but this seems too complicated.
The thing is that I can easily write the BITMAP to disk and read it back into a Magick::Image with ReadImage, but this is a very expensive operation. I looked through the Magick source code (Image.cpp, constitute.cpp), but could not find the function used to read from .bmp files (very similar to what I want to do).
There should be an easy way to do this right?
Thank you very much in advance for any help.
Also, please post back if anything is unclear.
(Here is a similar topic I posted back earlier (and found a solution to).)
For a DirectShow application, I want to transfer a BITMAP image info a Magick::Image. Basically, I have a BITMAPINFOHEADER and a BYTE* buffer pointing to the pixel data of the bitmap described by the BITMAPINFOHEADER.
Code: Select all
int bitmapToMagick(BITMAPINFOHEADER* bmiHeader, char* bitmap, size_t length, Magick::Image &Image) {
//...code here...//
}
I found this post, but extracting the image_info members would be a really complicated function (converting from BITMAPINFOHEADER to Magick::ImageInfo). Also, for some reason ImageInfo.size is a char* array (how can I specify a 720x480 image with a char* array?). With more searching, I did find a DIBToImage() function here which does the job, but this seems too complicated.
The thing is that I can easily write the BITMAP to disk and read it back into a Magick::Image with ReadImage, but this is a very expensive operation. I looked through the Magick source code (Image.cpp, constitute.cpp), but could not find the function used to read from .bmp files (very similar to what I want to do).
There should be an easy way to do this right?
Thank you very much in advance for any help.
Also, please post back if anything is unclear.