EdsSaveImage throws EDS_ERR_INVALID_HANDLE

403 Views Asked by At

I have a Delphi program built around the edsdk. I can take the picture, download the direct jpg of raw files. But when I get a raw (CR2)-file, I can't display the result. Any solution to achieve this would do, but my latest try was to follow this answer as I have difficulties translating the c#-code of most other examples to Delphi. This I what I have now:

procedure   TShooter.JPegFromRaw(rawFileName, JPegFileName: TFileName);
var rawStream, jpgStream: EdsStreamRef;
    imgRef: EdsImageRef;
    imageInfo: EdsImageInfo;
    jpgQuality: EdsSaveImageSetting;
begin
    try
        jpgQuality.JPEGQuality      := 9;
        jpgQuality.iccProfileStream := nil;
        jpgQuality.reserved         := 0;

        raiseError(EdsCreateFileStream(PChar(rawFileName),
                                   kEdsFileCreateDisposition_OpenExisting,
                                   kEdsAccess_Read, rawStream));
        raiseError(EdsCreateFileStream(PChar(JPegFileName),
                                   kEdsFileCreateDisposition_CreateAlways,
                                   kEdsAccess_Write, jpgStream));

        raiseError(EdsCreateImageRef(rawStream, imgRef));
        raiseError(EdsGetImageInfo(imgRef, kEdsImageSrc_FullView, imageInfo));
        raiseError(EdsSaveImage(imgRef, kEdsTargetImageType_Jpeg, jpgQuality, jpgStream));

    finally
        raiseError(EdsRelease(jpgStream));
        raiseError(EdsRelease(rawStream));
        raiseError(EdsRelease(imgRef));
    end { try };
end;

When executing this, it throws EDS_ERR_INVALID_HANDLE in the last line (EdsSaveImage(...)). The line before that doesn't really contribute to the result, but since it also uses imgRef, I have left it there. Since it returns ERR_OK, I assume imgRef is correct. But then I am lost what else could cause the error.

1

There are 1 best solutions below

5
Johannes Bildstein On

Raw image support has been removed with SDK version 3.2

I think you are supposed to use DPP (Digital Photo Professional) now. In earlier versions, DPP was shipped together with the SDK and the raw image functions simply used that in the background.