prodigal son
Jan 17th, 2006, 07:13 AM
Hi,
I have an intptr that points to an image stored in memory. The image is a frame from an avi stream. I need to copy the raw data from the image into a structure in unmanaged memory. What is the best way of doing this?
I have received hints but i am not sure how to implement the following. Do any of you gurus have an idea? :ehh:
-=Code Hint=-
Rather than copying these to managed memory, copy them over the OpenCV buffer allocated for the data. (If you have to have the data in managed memory, then I guess you must copy back from managed to unmanaged. )
byte *src = what I get from the grabber, before it is marshaled to managed memory,
byte *dest = (byte *) this.getPixelAddr(0,0,0);
somehow raw copy the data from src to dest (I think there are some raw copy utils in System.Runtime.InteropServices.Marshall.Copy)
There is a gotcha: Windows images are “upside down” relative to DirectX images, so your copy may need to go one scan line at a time, and flip the image as it copies.
-=Code Hint=-
What is the best marshal.copy method to use in this situation and will i have to take into consideration that the image is upside down?
Paul
I have an intptr that points to an image stored in memory. The image is a frame from an avi stream. I need to copy the raw data from the image into a structure in unmanaged memory. What is the best way of doing this?
I have received hints but i am not sure how to implement the following. Do any of you gurus have an idea? :ehh:
-=Code Hint=-
Rather than copying these to managed memory, copy them over the OpenCV buffer allocated for the data. (If you have to have the data in managed memory, then I guess you must copy back from managed to unmanaged. )
byte *src = what I get from the grabber, before it is marshaled to managed memory,
byte *dest = (byte *) this.getPixelAddr(0,0,0);
somehow raw copy the data from src to dest (I think there are some raw copy utils in System.Runtime.InteropServices.Marshall.Copy)
There is a gotcha: Windows images are “upside down” relative to DirectX images, so your copy may need to go one scan line at a time, and flip the image as it copies.
-=Code Hint=-
What is the best marshal.copy method to use in this situation and will i have to take into consideration that the image is upside down?
Paul