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}
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}
解决方案 »
- 如何模拟点击这样的图片按钮?
- 关于窗体style的问题...
- 使用两个ADOConnection分别连接两个异构数据库,如何用sql语句进行数据的导入/导出工作?
- PaintBox的错误!(100分)
- 急啊!向导程序用不起!大哥大姐帮帮忙!
- 我们这样的公司真的能开发软件吗?
- MTS/COM+三层问题(续)
- cxgrid的默认把0.1显示为.1,0没有显示出来
- 急!大分相送!我的Delphi 5.0数据库驱动(Database Driver)MSSQL怎么没有了?如何把它给装上?
- 我有如下定义ColNum:integer,且给ColNum给了初值,有如下式:Col<>5 ,报错类型不匹配,这是为什么?
- delphi 7 程序设置不了断点了,SOS;
- delphi如何根据数组的值得大小进行排序(百分求解)
中的&符号不知道在DELPHI中如何表示
引用的时候对应VAR
表示地址的时候对应@
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;
里边的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;
EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomPosition, 0 , sizeof(zoomPosition), @zoomPosition);
这个好像用同样的方法不行
该怎么写呢
这样使用应该可以,其他调用的也都这样处理。EdsGetPropertyData(evfImage, kEdsPropID_Evf_ZoomPosition, 0 , sizeof(zoomPosition), Pointer(@zoomPosition));
{ -----------------------------------------------------------------------------
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;
typedef struct __EdsObject* EdsBaseRef;
中结构体类型__EdsObject的定义是什么,想将这个转到delphi下,不知道它的具体定义,搜也搜不到,弄不下去了,还请各位大牛帮忙呀!
用在函数参数中,delphi的var就可以,var表示函数变量可改变输出,
支持智能识别和连接相机....