佳能 EDSDK 在电脑上下载或保存图像?

Canon EDSDK download or save image on pc?

我想用佳能 C# SDK 在我的电脑上保存图像? 如何在我的电脑上下载拍摄的照片并在 C# picturebox 上显示?

这是一个应用程序的摘录。它下载内存中的图像和 returns 带有图像的位图实例

public Bitmap DownloadImage(IntPtr ObjectPointer)
{
    //get information about image
    EDSDK.EdsDirectoryItemInfo dirInfo = new EDSDK.EdsDirectoryItemInfo();
    this.Parent.Lock(this.Ref);
    lock (LVlock) { Error = EDSDK.EdsGetDirectoryItemInfo(ObjectPointer, out dirInfo); }
    this.Parent.Unlock(this.Ref);
    //check the extension. Raw data cannot be read by the bitmap class
    string ext = Path.GetExtension(dirInfo.szFileName).ToLower();

    if (ext == ".jpg" || ext == ".jpeg")
    {
        Bitmap bmp = null;
        this.Parent.Lock(this.Ref);
        lock (LVlock)
        {
            IntPtr streamRef, jpgPointer;
            uint length;

            //create memory stream
            Error = EDSDK.EdsCreateMemoryStream(dirInfo.Size, out streamRef);
            //download data to the stream
            DownloadData(ObjectPointer, streamRef);
            Error = EDSDK.EdsGetPointer(streamRef, out jpgPointer);
            Error = EDSDK.EdsGetLength(streamRef, out length);

            unsafe
            {
                //create a System.IO.Stream from the pointer
                using (UnmanagedMemoryStream ums = new UnmanagedMemoryStream((byte*)jpgPointer.ToPointer(), length, length, FileAccess.Read))
                {
                    //create bitmap from stream (it's a normal jpeg image)
                    bmp = new Bitmap(ums);
                    //Tentar colocar um dispose no ums aqui
                }
            }

            //release data
            Error = EDSDK.EdsRelease(streamRef);
            //Error = EDSDK.EdsRelease(jpgPointer);


        }
        this.Parent.Unlock(this.Ref);
        return bmp;
    }
    else
    {
        //if it's a RAW image, cancel the download and release the image
        this.Parent.Lock(this.Ref);
        lock (LVlock)
        {
            Error = EDSDK.EdsDownloadCancel(ObjectPointer);
            Error = EDSDK.EdsRelease(ObjectPointer);
        }
        this.Parent.Unlock(this.Ref);
        return null;
    }
}
private void DownloadData(IntPtr ObjectPointer, IntPtr stream)
{

    //get information about the object
    EDSDK.EdsDirectoryItemInfo dirInfo;
    Error = EDSDK.EdsGetDirectoryItemInfo(ObjectPointer, out dirInfo);

    try
    {
        //set progress event
        Error = EDSDK.EdsSetProgressCallback(stream, SDKProgressCallbackEvent, EDSDK.EdsProgressOption.Periodically, ObjectPointer);
        //download the data
        Error = EDSDK.EdsDownload(ObjectPointer, dirInfo.Size, stream);
    }
    finally
    {
        //set the download as complete
        Error = EDSDK.EdsDownloadComplete(ObjectPointer);
        //release object
        Error = EDSDK.EdsRelease(ObjectPointer);
    }

}

我建议看看这篇 CodeProject 文章 http://www.codeproject.com/Articles/688276/Canon-EDSDK-Tutorial-in-Csharp