简体   繁体   中英

Unable to load DLL 'EDSDK.dll' Canon SDK Error in C#

I'm trying to add to an existing website using the Canon SDK and it's resize options. I have added the EDSDK.cs to my App_Code folder and these dlls to my Bin directory: EdsImage.dll, EDSDK.dll, MLib.dll, Ucs32P.dll, DPPDLL.dll, DPPLibCom.dll, and DPPRSC.dll. My code is just trying to convert the image to a JPG file:

uint err;
        err = EDSDK.EdsInitializeSDK();
        IntPtr inStream;
        err = EDSDK.EdsCreateFileStream("img_001.CR2", EDSDK.EdsFileCreateDisposition.OpenExisting, EDSDK.EdsAccess.Read, out inStream);
        IntPtr imgRef;
        err = EDSDK.EdsCreateImageRef(inStream, out imgRef);
        err = EDSDK.EdsSetPropertyData(imgRef, EDSDK.PropID_WhiteBalance, 0, 4, EDSDK.WhiteBalance_Cloudy);
        IntPtr outStream;
        err = EDSDK.EdsCreateFileStream("img_001.jpg", EDSDK.EdsFileCreateDisposition.CreateAlways, EDSDK.EdsAccess.Write, out outStream);
        EDSDK.EdsImageInfo info;
        err = EDSDK.EdsGetImageInfo(imgRef, EDSDK.EdsImageSource.FullView, out info);
        EDSDK.EdsSaveImageSetting set = new EDSDK.EdsSaveImageSetting();
        set.JPEGQuality = 9;
        err = EDSDK.EdsSaveImage(imgRef, EDSDK.EdsTargetImageType.Jpeg, set, outStream);
        EDSDK.EdsRelease(imgRef);
        EDSDK.EdsRelease(inStream);
        EDSDK.EdsRelease(outStream);
        EDSDK.EdsTerminateSDK();

Any help would be greatly appreciated. Thank you!!

I have found a solution to this problem that I wanted to share in case anyone had the same problem. I downloaded a .exe file here http://www.centrostudiprogressofotografico.it/en/dcraw/ and ran it as a process in the website to convert the .cr2 to a jpg. Here is the code:

string dcRawExe = HttpContext.Current.Server.MapPath("PATH TO:/dcraw-9.26-ms-64-bit.exe");
string strCR2File = "PATH TO CR2 FILE";
string strJPGFile = "PATH TO JPG FILE";
var startInfo = new ProcessStartInfo(dcRawExe)
{
    Arguments = "-c -e \"" + strCR2File + "\"",
    RedirectStandardOutput = true,
    UseShellExecute = false
};
var process = System.Diagnostics.Process.Start(startInfo);
var image = System.Drawing.Image.FromStream(process.StandardOutput.BaseStream);
image.Save(strJPGFile, System.Drawing.Imaging.ImageFormat.Jpeg);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM