Hello,
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);
ms->ReadByte();
System::Drawing::Bitmap *pBitmap = new System::Drawing::Bitmap(ms);
pBitmap->Save("C:\\DempPicture.jpg");
ms->Close();