By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,985 Members | 2,877 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,985 IT Pros & Developers. It's quick & easy.

Problem of Using Unamanged memory in VC++6.0

P: 31

I am writing a DLL for Capturing the Image from Camera Device using Camera SDK DLL.
All the calls made to functions in Camera SDK DLL are working properly as I am able to get a return value of zero.

I am able to get the image data as unmanaged memory address(pointer) as a result of a functions call to the camera SDK. I do not know how to display this data directly in the interface using the bitmap class without copying the same to managed memory. I want to directly access the image data pointed to by the pointer.

As of now I am using marshall function available in .Net to copy the data (the starting address of which is pointed to by the pointer) to managed bytestream data. Then I copy the bytestream data to a Physical file in the local Hard Disk and then making use of the bitmap class to display the same in the interface.

I have a constraint not to use any .Net framework classes for completing this image display function. Marshall is a .net framework class. Can anybody suggest an alternative process by which I can directly make use of the data in the unmanaged memory to display the image using the bitmap class.

I also want to display the image making use of the data directly from memory (Live Image) rather than writing it to a physical file (C:\\DempPicture.jpg) and then using the bitmap class to view it.

I need to write the code in VC++6.0(DLL) and display the image without using marshal function which is .net class. I see this problem as more of a conceptual problem and not related to the camera SDK.

In .Net I am using following code,

//Function call that returns the Pointer to Image Data
//prVoid* pVFData  refers to the pointer.

prResponse prSTDCALL MyViewFinderFunction(
prHandle CameraHandle,
prContext Context,
prUInt32 Size,
prVoid* pVFData


//The code segment making use of .net Framework Class (Marshal) to //display the image is as below

System::Byte buffer __gc[] = new System::Byte[MY_BUFFER_SIZE];
System::Runtime::InteropServices::Marshal::Copy(pV FData, buffer, 0, Size);
System::IO::MemoryStream* ms = new System::IO::MemoryStream(buffer);
System::Drawing::Bitmap *pBitmap = new System::Drawing::Bitmap(ms);
Aug 11 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.