EdsError downloadEvfData(HDC hdc){    EdsStreamRef stream; // JPEG stream.
    EdsUInt32 zoom;
    EdsPoint zoomPosition;
    EdsPoint imagePosition;
    EdsUInt32 histogram[256 * 4]; //(YRGB) YRGBYRGBYRGBYRGB....
    
    EdsError err = EDS_ERR_OK;
    EdsEvfImageRef evfImage = NULL;
    EdsUInt32 bufferSize = 2 * 1024 * 1024;
    // Create memory stream.
    err = EdsCreateMemoryStream(bufferSize, &stream);    // Create EvfImageRef.
    if(err == EDS_ERR_OK)
    {
    err = EdsCreateEvfImageRef(stream, &evfImage);
    }    // Download live view image data.
    if(err == EDS_ERR_OK)
    {
    err = EdsDownloadEvfImage(camera, evfImage);    
    }
    
    // Get the incidental data of the image.
    if(err == EDS_ERR_OK)
    {
    // Get the zoom ratio
    EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomPosition, 0 , sizeof(zoom), &zoom);
    // Get the focus and zoom border position
    EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomPosition, 0 , sizeof(zoomPosition), &zoomPosition);
    // Get position of image data. (when enlarging)
    EdsGetPropertyData(evfImage, kEdsPropID_Evf_ImagePosition, 0, sizeof(imagePosition), &imagePosition);
    // Get histogram (RGBY).
    EdsGetPropertyData(evfImage, kEdsPropID_Evf_Histogram, 0, sizeof(histogram), &histogram);
    }
    //
    // Display image+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    //
    Need to display the image in stream here
    //
    //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    // Release stream
    if(stream != NULL)
    {
    EdsRelease(stream);
    stream = NULL;
    }
    // Release evfImage
    if(evfImage != NULL)
    {
    EdsRelease(evfImage);
    evfImage = NULL;
    }return err;
}To display the stream as a live image i have written following functions and called them as
/*
    LPPICTURE pic= getImageFromStream(hdc, dataSet);
        if(pic!=NULL){
        displayLiveCannon(hdc, pic);        drawForcusRectangle(pDC, CPoint(dataSet.zoomPosition.x, dataSet.zoomPosition.y));        }
*/LPPICTURE getImageFromStream(HDC hdc, EVF_DATASET dataSet){    EdsUInt32 size;
    LPPICTURE pic=NULL;    unsigned char* pbyteImage = NULL;     // Get image (JPEG) pointer.
    EdsGetPointer(dataSet.stream, (EdsVoid**)&pbyteImage );
    
    if(pbyteImage != NULL)
    {    EdsGetLength(dataSet.stream, &size);    LPSTREAM stream=NULL;    HGLOBAL hMem= ::GlobalAlloc(GMEM_FIXED, size);
    LPVOID pBuff= ::GlobalLock(hMem);    memcpy(pBuff, pbyteImage, size);    ::GlobalUnlock(hMem);
    CreateStreamOnHGlobal(hMem, TRUE, &stream);
    :leLoadPicture(stream,size,true,IID_IPicture,(LPVOID *)&pic);        //generates a huge memory wastage here    GlobalFree(hMem);
    }return pic;
}
void displayLiveCannon(HDC hdc, LPPICTURE pic){        long hmWidth, hmHeight;
        pic->get_Width(&hmWidth);
        pic->get_Height(&hmHeight);        int nWidth=MulDiv(hmWidth, GetDeviceCaps(hdc, LOGPIXELSX), 2540);
        int nHeight = MulDiv(hmHeight, GetDeviceCaps(hdc, LOGPIXELSY), 2540);
    
        pic->Render(hdc                //Handle of device context on which to render the image
                    , 0        //Horizontal position of image in hdc
                    , 0        //Vertical position of image in hdc
                    , nWidth    //Horizontal dimension of destination rectangle
                    , nHeight    //Vertical dimension of destination rectangle
                    , 0        //Horizontal offset in source picture
                    , hmHeight    //Vertical offset in source picture
                    , hmWidth    //Amount to copy horizontally in source picture
                    , -hmHeight    //Amount to copy vertically in source picture
                    , NULL);    //Pointer to position of destination for a metafile hdc}

解决方案 »

  1.   

    关键是err = EdsCreateMemoryStream(bufferSize, &stream)
    中的&符号不知道在DELPHI中如何表示
      

  2.   

    &在C++里可以表示引用和地址 
    引用的时候对应VAR
    表示地址的时候对应@
      

  3.   

    按你代码表面翻译了一下。可能不一定好用。
    function downloadEvfData(hdc:HDC):EdsError;
    var
        stream:EdsStreamRef;
        zoom:EdsUInt32;
        zoomPosition,imagePosition:EdsPoint;
        histogram:array[0..256*4] of EdsUInt32;
        err:EdsError;
        evfImage:EdsEvfImageRef;
        bufferSize:EdsUInt32;
    begin
        err:=EDS_ERR_OK;
        evfImage:=nil;
        buffersize:=2*1024*1024;
        err:=EdsCreateMemoryStream(bufferSize,@stream);
        if err=EDS_ERR_OK then
            err:=EdsCreateEvfImageRef(stream, @evfImage);
        if err=EDS_ERR_OK then
            err:= EdsDownloadEvfImage(camera, evfImage);
        if err=EDS_ERR_OK then
        begin
            EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomPosition, 0 , sizeof(zoom), @zoom);
            EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomPosition, 0 , sizeof(zoomPosition), @zoomPosition);
            EdsGetPropertyData(evfImage, kEdsPropID_Evf_ImagePosition, 0, sizeof(imagePosition), @imagePosition);
            EdsGetPropertyData(evfImage, kEdsPropID_Evf_Histogram, 0, sizeof(histogram), @histogram);
        end;
        if stream<>nil then
        begin
            EdsRelease(stream);
            stream:=nil;
        end;
        if evfImage<>nil then
        begin
            EdsRelease(evfImage);
            evfImage:=nil;
        end;
        Result:=err;
    end;function getImageFromStream(hdc:HDC;dataset:EVF_DATASET):LPPICTURE;
    var
        size:EdsUInt32;
        pic:LPPICTURE;
        pbyteImage:PByte;
        stream:LPSTREAM;
        hMem:HGLOBAL;
        pBuff:LPVOID;
    begin
        pic:=nil;
        pbyteImage:=nil;
        EdsGetPointer(dataSet.stream,EdsVoid(@pbyteImage));
        if pbyteImage<>nil then
        begin
            EdsGetLength(dataSet.stream, @size);
            stream:=nil;
            hMem:=GlobalAlloc(GMEM_FIXED, size);
            pBuff:=GlobalLock(hMem);
            copyMemory(pBuff,pbyteImage,size);
            GlobalUnlock(hMem);
            CreateStreamOnHGlobal(hMem, TRUE, @stream);
            leLoadPicture(stream,size,true,IID_IPicture,Pointer(pic));
            GlobalFree(hMem);
        end;
        Result:=pic;
    end;procedure displayLiveCannon(hdc:HDC;pic:LPPICTURE);
    var
        hmWidth, hmHeight:long;
        nWidth,nHeight:integer;
    begin
        pic^.get_Width(@hmWidth);
        pic^.get_Height(@hmHeight);
        nWidth:=MulDiv(hmWidth, GetDeviceCaps(hdc, LOGPIXELSX), 2540);
        nHeight:= MulDiv(hmHeight, GetDeviceCaps(hdc, LOGPIXELSY), 2540);
        pic^.Render(hdc,0,0,nWidth,nHeight,0,hmHeight,hmWidth,-hmHeight,nil);
    end;
      

  4.   

    非常感谢
    里边的err:=EdsCreateMemoryStream(bufferSize,@stream);编译错误
    具体定义如下:
        stream:EdsStreamRef;
        zoom:EdsUInt32;
        zoomPosition,imagePosition:EdsPoint;
        evfImage:EdsEvfImageRef;
        bufferSize:EdsUInt32;定义1
      EdsObject = Pointer;
      EdsBaseRef = EdsObject;               // Baseic refernce
      EdsStreamRef        = EdsBaseRef;     // Reference to a stream
      EdsImageRef         = EdsStreamRef;   // Reference to a image
      EdsEvfImageRef      = EdsBaseRef;   // Reference to a image
    定义2
       EdsUInt32 = Cardinal;
    定义3
      type EdsPoint = record
        x : EdsInt32;
        y : EdsInt32;
      end;
      PEdsPoint = ^EdsPoint;
      

  5.   

    其实就是C++中&转delphi中相对应的符号
      

  6.   

    err:=EdsCreateMemoryStream(bufferSize,stream);
      

  7.   

    感谢 gzmhero
    EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomPosition, 0 , sizeof(zoomPosition), @zoomPosition);
    这个好像用同样的方法不行
    该怎么写呢
      

  8.   

    不知道EdsGetPropertyData定义是怎样的。
    这样使用应该可以,其他调用的也都这样处理。EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomPosition, 0 , sizeof(zoomPosition), Pointer(@zoomPosition)); 
      

  9.   

    这样定义
    { -----------------------------------------------------------------------------
      Function : EdsGetPropertyData  Description:
            Gets property information from the object designated in inRef.   Parameters:
           In: inRef            - The reference of the item.
               inPropertyID     - The ProprtyID
               inParam          - Additional information of property.
                                  We use this parameter in order to specify an index
                                  in case there are two or more values over the same ID.
                inPropertySize  - The number of bytes of the prepared buffer
                                  for receive property-value.
           Out: outPropertyData - The buffer pointer to receive property-value.  Returns:
            Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas.
    ----------------------------------------------------------------------------- }
    function EdsGetPropertyData( inRef : EdsBaseRef;
                                 inPropertyID : EdsPropertyID;
                                 inParam : EdsInt32;
                                 inPropertySize : EdsUInt32;
    //                             var outPropertyData : EdsUInt32 ) : EdsError ; stdcall; external edsdk;
                                 var outPropertyData : Pointer ) : EdsError ; stdcall; external edsdk;
      

  10.   

    这个是你自己定义的函数吧你问关键的,我回答关键,对&在Delphi中,定义时,使用var 参数调用时,在变量前加@
      

  11.   

    在Delphi中,定义为var的 参数 ,调用的时候在变量前不需要加@。
      

  12.   

    &参数,其时就是引用调用
      

  13.   

    想问一下,
    typedef struct __EdsObject*    EdsBaseRef;
    中结构体类型__EdsObject的定义是什么,想将这个转到delphi下,不知道它的具体定义,搜也搜不到,弄不下去了,还请各位大牛帮忙呀!
      

  14.   

    试过6楼的方法,将其定义为__EdsObject = Pointer;编译没有问题,但是得不到正确的结果
      

  15.   

    &c里表示取地址,用在函数参数中表示变量传进去后值是可改变的,该符号对应delphi是@
    用在函数参数中,delphi的var就可以,var表示函数变量可改变输出,
      

  16.   

    挖坟贴,我手上有单反系列和G系列,爱国者系列的相机SDK,delphi语言
    支持智能识别和连接相机....