
Hi All, Can anyone point me in the right directions for copying or assigning an array in memory to an image? I'm reading an frame out of an AVI file using Microsoft's vfw32.lib/vfw.h and the function that grabs the frame returns a pointer to a bitmap in memory, like this: BYTE* pDIB = (BYTE*) AVIStreamGetFrame(pFrame, index); And I need to transfer that information into an image. I have extracted the bitmap header and have a pointer to the first pixel, so I suppose I could iterate over each pixel and channel and populate the image by hand, but I imagine there is a better way. Thanks, Mark Sapp Notice: This e-mail is intended solely for use of the individual or entity to which it is addressed and may contain information that is proprietary, privileged, company confidential and/or exempt from disclosure under applicable law. If the reader is not the intended recipient or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If this communication has been transmitted from a U.S. location it may also contain data subject to the International Traffic in Arms Regulations or U.S. Export Administration Regulations and cannot be disseminated, distributed or copied to foreign nationals, residing in the U.S. or abroad, without the prior approval of the U.S. Department of State or appropriate export licensing authority. If you have received this communication in error, please notify the sender by reply e-mail or collect telephone call and delete or destroy all copies of this e-mail message, any physical copies made of this e-mail message and/or any file attachment(s).

Hi Mark,
You may construct an image view backed by your array. ie, make an image_view that is a view into your array. This way, you avoid a superfluous memory copy. Here's an example of the idea from some of my own code:
bgra8c_view_t imageView( interleaved_view( qImage.width(),
qImage.height(),
reinterpret_cast
Hi All,
Can anyone point me in the right directions for copying or assigning an array in memory to an image? I'm reading an frame out of an AVI file using Microsoft's vfw32.lib/vfw.h and the function that grabs the frame returns a pointer to a bitmap in memory, like this:
BYTE* pDIB = (BYTE*) AVIStreamGetFrame(pFrame, index);
And I need to transfer that information into an image. I have extracted the bitmap header and have a pointer to the first pixel, so I suppose I could iterate over each pixel and channel and populate the image by hand, but I imagine there is a better way.
Thanks,
Mark Sapp
Notice: This e-mail is intended solely for use of the individual or entity to which it is addressed and may contain information that is proprietary, privileged, company confidential and/or exempt from disclosure under applicable law. If the reader is not the intended recipient or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If this communication has been transmitted from a U.S. location it may also contain data subject to the International Traffic in Arms Regulations or U.S. Export Administration Regulations and cannot be disseminated, distributed or copied to foreign nationals, residing in the U.S. or abroad, without the prior approval of the U.S. Department of State or appropriate export licensing authority. If you have received this communication in error, please notify the sender by reply e-mail or collect telephone call and delete or destroy all copies of this e-mail message, any physical copies made of this e-mail message and/or any file attachment(s).

Thanks Erik and Simon, The example you sent are exactly what I'm attempting to do. I just wasn't sure if creating a view without the underlying img structure was appropriate because in the past I have only created views from an existing img. I'll let you know how it goes when I have time to implement. Thanks for the help, Mark Notice: This e-mail is intended solely for use of the individual or entity to which it is addressed and may contain information that is proprietary, privileged, company confidential and/or exempt from disclosure under applicable law. If the reader is not the intended recipient or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If this communication has been transmitted from a U.S. location it may also contain data subject to the International Traffic in Arms Regulations or U.S. Export Administration Regulations and cannot be disseminated, distributed or copied to foreign nationals, residing in the U.S. or abroad, without the prior approval of the U.S. Department of State or appropriate export licensing authority. If you have received this communication in error, please notify the sender by reply e-mail or collect telephone call and delete or destroy all copies of this e-mail message, any physical copies made of this e-mail message and/or any file attachment(s).

Hi Simon and Erik, The examples you provided are exactly what I needed. I was able to get everything up and running very quickly after looking over your examples.. I really appreciate the help you and others have offered as I'm learning the boost libraries. Thanks, Mark Notice: This e-mail is intended solely for use of the individual or entity to which it is addressed and may contain information that is proprietary, privileged, company confidential and/or exempt from disclosure under applicable law. If the reader is not the intended recipient or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If this communication has been transmitted from a U.S. location it may also contain data subject to the International Traffic in Arms Regulations or U.S. Export Administration Regulations and cannot be disseminated, distributed or copied to foreign nationals, residing in the U.S. or abroad, without the prior approval of the U.S. Department of State or appropriate export licensing authority. If you have received this communication in error, please notify the sender by reply e-mail or collect telephone call and delete or destroy all copies of this e-mail message, any physical copies made of this e-mail message and/or any file attachment(s).

Hi Mark,
The examples you provided are exactly what I needed. I was able to get everything up and running very quickly after looking over your examples.. I really appreciate the help you and others have offered as I’m learning the boost libraries.
I am glad I could help. Welcome to boost :)

Hi,
Can anyone point me in the right directions for copying or assigning an array in memory to an image? I’m reading an frame out of an AVI file using Microsoft’s vfw32.lib/vfw.h and the function that grabs the frame returns a pointer to a bitmap in memory, like this:
BYTE* pDIB = (BYTE*) AVIStreamGetFrame(pFrame, index);
And I need to transfer that information into an image. I have extracted the bitmap header and have a pointer to the first pixel, so I suppose I could iterate over each pixel and channel and populate the image by hand, but I imagine there is a better way.
Don't quite understand what do you want to achieve with GIL but to make a raw memory usable by GIL algorithms you need a proper view. Views are abstractions over underlying pixel representation so that algorithms may operate on the data regardless of storage / layout. As long as views are compatible (same dimmensions, channel count etc) all will work fine. For example in my code (source data is decoded theora video frame): gil::interleaved_view(frame->getWidth(), frame->getHeight(), (gil::rgb8_pixel_t*) frame->getBuffer(), frame->getStride() * 3); frame->getBuffer() is pointer to first byte of RGB data, last param is scanline length in bytes. You could use it like this: rgb8_image_t img(frame->getWidth(), frame->getHeight()); copy_pixels(gil::interleaved_view(frame->getWidth(), frame->getHeight(), (gil::rgb8_pixel_t*) frame->getBuffer(), frame->getStride() * 3), img); I guess in your case pixel ptr is pDIB and the rest of params has to be taken from the image header. Hope this helps. Cheers, Simon -- Szymon Gatner The Lordz Games Studio www.thelordzgamesstudio.com
participants (3)
-
Erik Hvatum
-
Sapp, Mark
-
Szymon Gatner