canon SDk Article by Johannes Bildstein

我的梦境 提交于 2019-12-11 19:05:50

问题


In Canon SDK sample, how can I take a photo with certain resolution such as 200-300 dpi or change the resolution programmatically, and save the taken photo in another file type, here I need to save in .TIF format? I can't find any function to do it.


回答1:


author of the article here. you can change the image resolution by setting the PropID_ImageQuality with one of the ImageQuality enums. Note that not every camera supports every enum value and the actual image resolution depends on the camera and sensor. If you need a pixel-exact image you'll have to resize it yourself.

Also, the image you download from the camera is not modified by the SDK so you can only get the image format that the camera has, usually CR2 and/or Jpg.

To get a tif from a raw file you can use the SDKs image methods. To create a raw image use the EdsCreateImageRef method and to save it use the EdsSaveImage method. As a target you can use EdsTargetImageType.TIFF (or TIFF16 for 16bit per channel).

EDIT:

quick sample for saving an image to tiff (not tested):

IntPtr imgRef;
//Open image
IntPtr inStream;
EDSDK.EdsCreateFileStream("inFile.cr2", EdsFileCreateDisposition.OpenExisting, FileAccess.Read, out inStream);
EDSDK.EdsCreateImageRef(inStream, out imgRef);
EDSDK.EdsRelease(inStream);

//do whatever you like with imgRef now

//Save image
IntPtr outStream;
var settings = new EdsSaveImageSetting();
EDSDK.EdsCreateFileStream("outFile.tif", EdsFileCreateDisposition.CreateAlways, EdsFileAccess.Write, out outStream);
EDSDK.EdsSaveImage(imgRef, EdsTargetImageType.TIFF, settings, outStream);
EDSDK.EdsRelease(outStream);



回答2:


To get a TIFF image, shoot in RAW format and after downloading the image use the EdsSaveImage function with the EdsTargetImageType set to kEdsTargetImageType_TIFF. The DPI resolution is not relevant directly, but you can always use tools like Exiftool to set the DPI explicitly.



来源:https://stackoverflow.com/questions/35100159/canon-sdk-article-by-johannes-bildstein

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!