GIL - Need to load from HBITMAP

(This is using windows OS) Is there anyway to simply initialize an image (any_image?) )from a memory bitmap? I would like to plug it into an existing app to play with it and this would really make it simple... Gordon.

Looks like its this easy (not using any_image yet): using namespace gil; BITMAP bm; m_bmp.GetBitmap(&bm); if (bm.bmPlanes == 1 && bm.bmBitsPixel == 8) { rgb8c_view_t src = interleaved_view(bm.bmWidth, bm.bmHeight, (const rgb8_pixel_t*)bm.bmBits, bm.bmWidthBytes); } "Gordon Smith" <schmoo2k@hotmail.com> wrote in message news:ego53p$ese$1@sea.gmane.org...
(This is using windows OS)
Is there anyway to simply initialize an image (any_image?) )from a memory bitmap? I would like to plug it into an existing app to play with it and this would really make it simple...
Gordon.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Gordon Smith wrote:
Looks like its this easy (not using any_image yet): using namespace gil;
BITMAP bm;
m_bmp.GetBitmap(&bm);
if (bm.bmPlanes == 1 && bm.bmBitsPixel == 8)
{
rgb8c_view_t src = interleaved_view(bm.bmWidth, bm.bmHeight, (const rgb8_pixel_t*)bm.bmBits, bm.bmWidthBytes);
}
Yes. And here is how to extend it with any_image_view: typedef mpl::vector<gray8c_view_t, gray16c_view_t, rgb8c_view_t, rgb16c_view_t> my_view_types; typedef any_image_view<my_view_types> my_any_view_t; my_any_view_t create_runtime_gil_view(int color_space, int bpp, int w, int h, int row_bytes, void* pixels) { switch (color_space) { case kRGB: // your own enum switch (bpp) { case 8: return my_any_view_t(interleaved_view(w,h, (const rgb8_pixel_t*)pixels, row_bytes)); } ... } } I find this wrapper a nice way to get to GIL realm from your application. We have something similar for Photoshop, as Photoshop images are typically specified at run time. Lubomir

This might be a little off-topic. I'm sure there are several ways. My way is to obtain the pointer to the pixels, like this: DIBSECTION sDibSection; int nBytes = ::GetObject( hBitmap , sizeof( DIBSECTION ) , &sDibSection ); The DIBSECTION structure will host a BITMAPINFOHEADER and the mentioned pointer. Then you can use memcpy to fill up a GIL image. For indexed images you need to obtain the color table, also. Let me know if you are interested in the GDI code. Another way might be using GDI+ . This lib is easier to use than good ol' GDI. If you have problems contact me. I can help you. I have been wading through all the pains the GDI offers. Christian On 10/13/06, Gordon Smith <schmoo2k@hotmail.com> wrote:
(This is using windows OS)
Is there anyway to simply initialize an image (any_image?) )from a memory bitmap? I would like to plug it into an existing app to play with it and this would really make it simple...
Gordon.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (3)
-
Christian Henning
-
Gordon Smith
-
Lubomir Bourdev