开发者

Image capture using CameraCapture

开发者 https://www.devze.com 2023-03-21 08:22 出处:网络
I am using a sample code from Microsoft windows SDK (CameraCapture, which is found in C:\\Program Files\\Windows Mobile 6 SDK\\Samples\\PocketPC\\CPP\\win32\\CameraCapture) to capture image using wind

I am using a sample code from Microsoft windows SDK (CameraCapture, which is found in C:\Program Files\Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\CameraCapture) to capture image using windows mobile. The program save a image 开发者_开发知识库into a file, but I am interested to store the image into memory rather than any saving into storage.

any suggestions?


I don't have access to that particular sample but I assume that the project is using the CaptureCameraDialog class.

http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.forms.cameracapturedialog_members.aspx

Unfortunately using this class will only return the image path. You don't state why you need to save it in memory rather than on the disk but if your intention is to do some basic processing then you could just load it from the disk once captured.

using (CameraCaptureDialog cameraCapture = new CameraCaptureDialog())
{
    cameraCapture.ShowDialog();

    //get the name of the last image taken
    string fileName = cameraCapture.FileName;

    //Load the image from disk into our image object
    Image image = new Bitmap(fileName);
}

A word of caution here. I believe when saved to disk the images will be in a compressed format, but when loaded into memory they will be uncompressed. It is very easy to cause an out of memory exception when working with images in the compact framework so I wouldn't recommend holding lots of images in memory at once especially if working with a hi resolution camera.

0

精彩评论

暂无评论...
验证码 换一张
取 消