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.
2 Answers
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);

- 1,069
- 2
- 8
- 20
-
@Shapoor, please show what you already did and what error you had. I can help you better that way. – Johannes Bildstein Jan 31 '16 at 16:57
-
@Shapoor, all of those things are defined in the EDSDK class. The property is set like any other property with the SetSetting method in CameraHandler (see samples in article). See edit for a quick example of the tiff saving. – Johannes Bildstein Jan 31 '16 at 21:41
-
We are referring your awesome utility at [here](https://www.codeproject.com/Articles/688276/Canon-EDSDK-Tutorial-in-Csharp) our purpose is to save captured image as .TIF, In the sample application, after click on TakePhoto, it should save image as .TIF on Computer. In DownloadToFile function, we have used above code, where "input.cr2" file is captured from Camera's RAW settings. Can you please tell us exact usage of above code i.e. Correct place to add this code and exact parameter values ? - Thank you again. – Banng Feb 21 '18 at 11:16