Data Buffer into a VB .Net Byte Array
-
Hi! I'll preface this by saying I'm a novice with C++ and the majority of my work is VB .Net, although in the past month I've had to take a self-crash-course in C++ for a project with some severely short deadlines, so I'm able to grasp basic C++ concepts. My C++ work at the moment involves writing my own C++ DLL to act as a join between a VB .Net application I am writing and an SDK that is designed for and writen in, C++ (I unfortunately lack the time to a solid course in C# and work with a more compatible pair of languages). The reason I'm writing this DLL is because certain uses of data types (unions being my biggest problem) used by the SDK aren't replicable in VB .Net (at least not to the best of my ability), and it's been easier to reproduce the functionality I need in C++ and send the data my VB .Net app needs back up the line. Coming to my problem, the SDK is for a Canon line of digital cameras, and is used for manipulating the camera from a PC (taking pictures and getting live video, with a whole bunch of additional features on the camera you can access). My goal is to be able to take pictures (which I've fully accomplished), and get live video so that the user of my application can see what they're going to take a picture of before they do so. To put this in context, the app is for taking security badge photos. The SDK handles video capture as sending to the PC what the digital view-finder on the camera can 'see', and it does this at a frame rate I think to be on the order of 25-29 fps, via an event call procedure I vaguely understand. Basically I create a pointer for the event that the initial function recognizes and then runs every time a frame of data is sent in from the camera, and then I write what code I want to in that event to display images. The event's parameters are a void field that is a buffer holding the data of the image, an unsigned long field holding the size of the buffer, another unsigned long field for the format (a 0 or 1 that I set as a seperate parameter of the initial function call to set the images coming back as bitmap or jpeg format, I'm using bitmap), and one more unsigned long field that I can use at my hearts content, but doesn't play any role in my needs. Basically, I want to take what's in that buffer, and get it to my VB .Net application as a Byte array (in the .Net sense of the type) that I can then turn via a .Net memory-stream that data into a bitmap image (that final step being something I've done countless times before). My attempts at the moment hav