/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Runtime.InteropServices;
using Native = Interop.CameraSettings;
using static Interop.Camera;
namespace Tizen.Multimedia
{
///
/// The camera setting class provides methods/properties to get and
/// set basic camera attributes.
///
public class CameraSettings
{
internal readonly Camera _camera;
private readonly Range? _brightnessRange;
private readonly Range? _contrastRange;
private readonly Range? _panRange;
private readonly Range? _tiltRange;
private readonly Range? _exposureRange;
private readonly Range? _zoomRange;
internal CameraSettings(Camera camera)
{
_camera = camera;
_contrastRange = GetRange(Native.GetContrastRange);
_brightnessRange = GetRange(Native.GetBrightnessRange);
_exposureRange = GetRange(Native.GetExposureRange);
_zoomRange = GetRange(Native.GetZoomRange);
_panRange = GetRange(Native.GetPanRange);
_tiltRange = GetRange(Native.GetTiltRange);
}
private delegate CameraError GetRangeDelegate(IntPtr handle, out int min, out int max);
private Range? GetRange(GetRangeDelegate func)
{
CameraErrorFactory.ThrowIfError(func(_camera.GetHandle(), out int min, out int max),
"Failed to initialize the camera settings");
if (min > max)
{
return null;
}
return new Range(min, max);
}
#region Auto Focus
///
/// Sets the auto focus area.
///
/// 3
///
/// should not be the .
///
/// X position.
/// Y position.
/// In case of invalid parameters.
/// In case of any invalid operations.
/// The camera already has been disposed of.
public void SetAutoFocusArea(int x, int y)
{
CameraErrorFactory.ThrowIfError(Native.SetAutoFocusArea(_camera.GetHandle(), x, y),
"Failed to set the autofocus area.");
}
///
/// Sets the auto focus area.
///
/// 3
///
/// should not be the .
///
/// structure including X, Y position.
/// In case of invalid parameters.
/// In case of any invalid operations.
/// The camera already has been disposed of.
public void SetAutoFocusArea(Point pos)
{
CameraErrorFactory.ThrowIfError(Native.SetAutoFocusArea(_camera.GetHandle(), pos.X, pos.Y),
"Failed to set the autofocus area.");
}
///
/// Clears the auto focus area.
///
/// 3
/// The camera already has been disposed of.
public void ClearFocusArea()
{
CameraErrorFactory.ThrowIfError(Native.ClearAutoFocusArea(_camera.GetHandle()),
"Failed to clear the autofocus area.");
}
///
/// The auto focus mode.
///
/// 3
/// A that specifies the auto focus mode.
/// The camera already has been disposed of.
public CameraAutoFocusMode AutoFocusMode
{
get
{
CameraAutoFocusMode val = CameraAutoFocusMode.None;
CameraErrorFactory.ThrowIfError(Native.GetAutoFocusMode(_camera.GetHandle(), out val),
"Failed to get camera autofocus mode");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraAutoFocusMode), value);
CameraErrorFactory.ThrowIfError(Native.SetAutoFocusMode(_camera.GetHandle(), value),
"Failed to set camera autofocus mode.");
}
}
#endregion Auto Focus
#region Contrast
///
/// The contrast level of the camera.
///
/// 3
/// The camera already has been disposed of.
public int Contrast
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetContrast(_camera.GetHandle(), out int val),
"Failed to get camera contrast value");
return val;
}
set
{
CameraErrorFactory.ThrowIfError(Native.SetContrast(_camera.GetHandle(), value),
"Failed to set camera contrast value.");
}
}
///
/// The auto contrast.
/// If true auto contrast is enabled, otherwise false.
///
/// 3
/// The camera already has been disposed of.
public bool AutoContrast
{
get
{
CameraErrorFactory.ThrowIfError(Native.IsEnabledAutoContrast(_camera.GetHandle(), out bool val),
"Failed to get camera auto contrast");
return val;
}
set
{
CameraErrorFactory.ThrowIfError(Native.EnableAutoContrast(_camera.GetHandle(), value),
"Failed to set camera enable auto contrast.");
}
}
///
/// Gets the available contrast level.
///
/// 3
///
/// If the mininum value is greater than the maximum value, it means this feature is not supported.
///
/// In case of this feature is not supported.
public Range ContrastRange
{
get
{
if (!_contrastRange.HasValue)
{
throw new NotSupportedException("Contrast is not supported.");
}
return _contrastRange.Value;
}
}
#endregion Contrast
#region Brightness
///
/// The brightness level of the camera.
///
/// 3
/// The camera already has been disposed of.
public int Brightness
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetBrightness(_camera.GetHandle(), out int val),
"Failed to get camera brightness value");
return val;
}
set
{
CameraErrorFactory.ThrowIfError(Native.SetBrightness(_camera.GetHandle(), value),
"Failed to set camera brightness value.");
}
}
///
/// Gets the available brightness level.
///
/// 3
///
/// If the minimum value is greater than the maximum value, it means this feature is not supported.
///
/// In case of this feature is not supported.
public Range BrightnessRange
{
get
{
if (!_brightnessRange.HasValue)
{
throw new NotSupportedException("Brightness is not supported.");
}
return _brightnessRange.Value;
}
}
#endregion Brightness
#region Exposure
///
/// The exposure value.
///
/// 3
/// The camera already has been disposed of.
public int Exposure
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetExposure(_camera.GetHandle(), out int val),
"Failed to get camera exposure value");
return val;
}
set
{
CameraErrorFactory.ThrowIfError(Native.SetExposure(_camera.GetHandle(), value),
"Failed to set camera exposure value.");
}
}
///
/// The exposure mode.
///
/// 3
/// A that specifies the exposure mode.
/// The camera already has been disposed of.
public CameraExposureMode ExposureMode
{
get
{
CameraExposureMode val = CameraExposureMode.Off;
CameraErrorFactory.ThrowIfError(Native.GetExposureMode(_camera.GetHandle(), out val),
"Failed to get camera exposure mode");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraExposureMode), value);
CameraErrorFactory.ThrowIfError(Native.SetExposureMode(_camera.GetHandle(), value),
"Failed to set camera exposure mode.");
}
}
///
/// Gets the available exposure value.
///
/// 3
///
/// If the minimum value is greater than the maximum value, it means this feature is not supported.
///
/// In case of this feature is not supported.
public Range ExposureRange
{
get
{
if (!_exposureRange.HasValue)
{
throw new NotSupportedException("Exposure is not supported.");
}
return _exposureRange.Value;
}
}
#endregion Exposure
#region Zoom
///
/// The zoom level.
/// The range for the zoom level is received from the ZoomRange property.
///
/// 3
/// The camera already has been disposed of.
public int ZoomLevel
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetZoom(_camera.GetHandle(), out int val),
"Failed to get zoom level");
return val;
}
set
{
CameraErrorFactory.ThrowIfError(Native.SetZoom(_camera.GetHandle(), value),
"Failed to set zoom level.");
}
}
///
/// Gets the available zoom level.
///
/// 3
///
/// If the minimum value is greater than the maximum value, it means this feature is not supported.
///
/// In case of this feature is not supported.
public Range ZoomRange
{
get
{
if (!_zoomRange.HasValue)
{
throw new NotSupportedException("Zoom is not supported.");
}
return _zoomRange.Value;
}
}
#endregion Zoom
///
/// The white balance mode.
///
/// 3
/// A that specifies the white balance mode.
/// The camera already has been disposed of.
public CameraWhiteBalance WhiteBalance
{
get
{
CameraWhiteBalance val = CameraWhiteBalance.None;
CameraErrorFactory.ThrowIfError(Native.GetWhiteBalance(_camera.GetHandle(), out val),
"Failed to get camera whitebalance");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraWhiteBalance), value);
CameraErrorFactory.ThrowIfError(Native.SetWhitebalance(_camera.GetHandle(), value),
"Failed to set camera whitebalance.");
}
}
///
/// The ISO level.
///
/// 3
/// A that specifies the ISO level.
/// The camera already has been disposed of.
public CameraIsoLevel IsoLevel
{
get
{
CameraIsoLevel val = CameraIsoLevel.Auto;
CameraErrorFactory.ThrowIfError(Native.GetIso(_camera.GetHandle(), out val),
"Failed to get camera Iso level");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraIsoLevel), value);
CameraErrorFactory.ThrowIfError(Native.SetIso(_camera.GetHandle(), value),
"Failed to set camera Iso level.");
}
}
///
/// The quality of the image.
/// The range for the image quality is 1 to 100.
///
/// 3
/// The camera already has been disposed of.
public int ImageQuality
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetImageQuality(_camera.GetHandle(), out int val),
"Failed to get image quality");
return val;
}
set
{
if (value < 1 || value > 100)
{
throw new ArgumentException("Valid value is from 1(lowest quality) to 100(highest quality)");
}
CameraErrorFactory.ThrowIfError(Native.SetImageQuality(_camera.GetHandle(), value),
"Failed to set image quality.");
}
}
#region Resolution, Format, Fps of preview, capture
///
/// The preview frame rate.
///
/// 3
/// A that specifies the preview frame rate.
/// The camera already has been disposed of.
public CameraFps PreviewFps
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetPreviewFps(_camera.GetHandle(), out var val),
"Failed to get camera preview fps");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraFps), value);
CameraErrorFactory.ThrowIfError(Native.SetPreviewFps(_camera.GetHandle(), value),
"Failed to set preview fps.");
}
}
///
/// Gets or sets the resolution of the preview.
///
/// 3
/// In case of invalid parameters.
/// The camera already has been disposed of.
public Size PreviewResolution
{
get
{
CameraErrorFactory.ThrowIfError(GetPreviewResolution(_camera.GetHandle(), out int width, out int height),
"Failed to get camera preview resolution");
return new Size(width, height);
}
set
{
CameraErrorFactory.ThrowIfError(SetPreviewResolution(_camera.GetHandle(), value.Width, value.Height),
"Failed to set preview resolution.");
}
}
///
/// Gets the recommended preview resolution.
///
/// 3
///
/// Depending on the capture resolution aspect ratio and the display resolution,
/// the recommended preview resolution is determined.
///
/// The camera already has been disposed of.
public Size RecommendedPreviewResolution
{
get
{
CameraErrorFactory.ThrowIfError(GetRecommendedPreviewResolution(_camera.GetHandle(), out int width, out int height),
"Failed to get recommended preview resolution");
return new Size(width, height);
}
}
///
/// The preview data format.
///
/// 3
/// A that specifies the pixel format of the preview data.
/// In case of invalid parameters.
/// The camera already has been disposed of.
public CameraPixelFormat PreviewPixelFormat
{
get
{
CameraErrorFactory.ThrowIfError(GetPreviewPixelFormat(_camera.GetHandle(), out var val),
"Failed to get preview format");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraPixelFormat), value);
CameraErrorFactory.ThrowIfError(SetPreviewPixelFormat(_camera.GetHandle(), value),
"Failed to set preview format.");
}
}
///
/// Resolution of the captured image.
///
/// 3
/// In case of invalid parameters.
/// The camera already has been disposed of.
public Size CaptureResolution
{
get
{
CameraErrorFactory.ThrowIfError(GetCaptureResolution(_camera.GetHandle(), out int width, out int height),
"Failed to get camera capture resolution");
return new Size(width, height);
}
set
{
Size res = value;
CameraErrorFactory.ThrowIfError(SetCaptureResolution(_camera.GetHandle(), res.Width, res.Height),
"Failed to set capture resolution.");
}
}
///
/// Format of an image to be captured.
///
/// 3
/// A that specifies the pixel format of captured image.
/// In case of invalid parameters.
/// The camera already has been disposed of.
public CameraPixelFormat CapturePixelFormat
{
get
{
CameraErrorFactory.ThrowIfError(GetCaptureFormat(_camera.GetHandle(), out var val),
"Failed to get camera capture formats");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraPixelFormat), value);
CameraErrorFactory.ThrowIfError(SetCaptureFormat(_camera.GetHandle(), value),
"Failed to set capture format.");
}
}
#endregion Resolution, Format, Fps of preview, capture
#region Encoded preview
///
/// The bit rate of the encoded preview.
///
/// 3
/// The camera already has been disposed of.
public int EncodedPreviewBitrate
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetBitrate(_camera.GetHandle(), out int val),
"Failed to get preview bitrate");
return val;
}
set
{
CameraErrorFactory.ThrowIfError(Native.SetBitrate(_camera.GetHandle(), value),
"Failed to set encoded preview bitrate.");
}
}
///
/// The GOP(Group Of Pictures) interval of the encoded preview.
///
/// 3
/// The camera already has been disposed of.
public int EncodedPreviewGopInterval
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetGopInterval(_camera.GetHandle(), out int val),
"Failed to get preview gop interval");
return val;
}
set
{
CameraErrorFactory.ThrowIfError(Native.SetGopInterval(_camera.GetHandle(), value),
"Failed to set encoded preview gop intervals.");
}
}
#endregion Encoded preview
///
/// The theater mode.
///
/// 3
/// A that specifies the theater mode.
///
/// If you want to display the preview image on the external display with the full screen mode,
/// use this property.
///
/// The camera already has been disposed of.
public CameraTheaterMode TheaterMode
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetTheaterMode(_camera.GetHandle(), out var val),
"Failed to get camera theater mode");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraTheaterMode), value);
CameraErrorFactory.ThrowIfError(Native.SetTheaterMode(_camera.GetHandle(), value),
"Failed to set camera theater mode.");
}
}
///
/// The camera effect mode.
///
/// 3
/// A that specifies the effect mode.
/// The camera already has been disposed of.
public CameraEffectMode Effect
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetEffect(_camera.GetHandle(), out var val),
"Failed to get camera effect");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraEffectMode), value);
CameraErrorFactory.ThrowIfError(Native.SetEffect(_camera.GetHandle(), value),
"Failed to set camera effect.");
}
}
///
/// The scene mode.
///
/// 3
/// A that specifies the scene mode.
/// The camera already has been disposed of.
public CameraSceneMode SceneMode
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetSceneMode(_camera.GetHandle(), out var val),
"Failed to get camera scene mode");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraSceneMode), value);
CameraErrorFactory.ThrowIfError(Native.SetSceneMode(_camera.GetHandle(), value),
"Failed to set camera scene mode.");
}
}
///
/// The camera's flash mode.
///
/// 3
/// A that specifies the flash mode.
/// The camera already has been disposed of.
public CameraFlashMode FlashMode
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetFlashMode(_camera.GetHandle(), out var val),
"Failed to get camera flash mode");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraFlashMode), value);
CameraErrorFactory.ThrowIfError(Native.SetFlashMode(_camera.GetHandle(), value),
"Failed to set camera flash mode.");
}
}
///
/// Gets the camera lens orientation angle.
///
/// 3
/// The camera already has been disposed of.
public int LensOrientation
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetLensOrientation(_camera.GetHandle(), out var val),
"Failed to get camera lens orientation");
return val;
}
}
///
/// The stream rotation.
///
/// 3
/// A that specifies the rotation of camera device.
/// The camera already has been disposed of.
public Rotation StreamRotation
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetStreamRotation(_camera.GetHandle(), out var val),
"Failed to get camera stream rotation");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(Rotation), value);
CameraErrorFactory.ThrowIfError(Native.SetStreamRotation(_camera.GetHandle(), value),
"Failed to set camera stream rotation.");
}
}
///
/// The stream flip.
///
/// 3
/// A that specifies the camera flip type.
/// The camera already has been disposed of.
public Flips StreamFlip
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetFlip(_camera.GetHandle(), out var val),
"Failed to get camera stream flip");
return val;
}
set
{
ValidationUtil.ValidateFlagsEnum(value, Flips.Horizontal | Flips.Vertical, nameof(Flips));
CameraErrorFactory.ThrowIfError(Native.SetFlip(_camera.GetHandle(), value),
"Failed to set camera flip.");
}
}
///
/// The mode of the HDR(High dynamic range) capture.
///
/// 3
/// A that specifies the HDR mode.
///
/// Taking multiple pictures at different exposure levels and intelligently stitching them together,
/// so that we eventually arrive at a picture that is representative in both dark and bright areas.
/// If this attribute is set, then event handler set for the HdrCaptureProgress event is invoked.
///
/// The camera already has been disposed of.
public CameraHdrMode HdrMode
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetHdrMode(_camera.GetHandle(), out var val),
"Failed to get camera hdr mode");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraHdrMode), value);
CameraErrorFactory.ThrowIfError(Native.SetHdrMode(_camera.GetHandle(), value),
"Failed to set camera hdr mode.");
}
}
///
/// The anti shake feature.
/// If true, the antishake feature is enabled, otherwise false.
///
/// 3
/// The camera already has been disposed of.
public bool AntiShake
{
get
{
CameraErrorFactory.ThrowIfError(Native.IsEnabledAntiShake(_camera.GetHandle(), out bool val),
"Failed to get camera anti shake value");
return val;
}
set
{
CameraErrorFactory.ThrowIfError(Native.EnableAntiShake(_camera.GetHandle(), value),
"Failed to set camera anti shake value.");
}
}
///
/// Enables or disables the video stabilization feature.
/// If true, video stabilization is enabled, otherwise false.
///
/// 3
///
/// If video stabilization is enabled, zero shutter lag is disabled.
/// This feature is used to record a video.
///
/// The camera already has been disposed of.
public bool VideoStabilization
{
get
{
CameraErrorFactory.ThrowIfError(Native.IsEnabledVideoStabilization(_camera.GetHandle(), out bool val),
"Failed to get camera video stabilization");
return val;
}
set
{
CameraErrorFactory.ThrowIfError(Native.EnableVideoStabilization(_camera.GetHandle(), value),
"Failed to set camera video stabilization.");
}
}
///
/// Turn the shutter sound on or off, if it is permitted by policy.
///
/// 3
/// Shutter sound On/Off flag
///
/// If this value is true, shutter sound will be disabled, otherwise enabled.
/// In some countries, this operation is not permitted.
///
/// Disabling shutter sound is not permitted.
/// The camera already has been disposed of.
public void DisableShutterSound(bool shutterSound)
{
CameraErrorFactory.ThrowIfError(Native.DisableShutterSound(_camera.GetHandle(), shutterSound),
"Failed to set disable shutter sound.");
}
#region PTZ(Pan Tilt Zoom), Pan, Tilt
///
/// Sets the type of the PTZ(Pan Tilt Zoom). Mechanical or electronic.
///
/// 3
/// A that specifies the type of the PTZ.
/// The camera already has been disposed of.
public CameraPtzType PtzType
{
set
{
ValidationUtil.ValidateEnum(typeof(CameraPtzType), value);
CameraErrorFactory.ThrowIfError(Native.SetPtzType(_camera.GetHandle(), value),
"Failed to set camera ptz type.");
}
}
///
/// Sets the position to move horizontally.
///
/// 3
/// The PTZ move type. .
/// The pan step.
/// In case of invalid parameters.
/// The camera already has been disposed of.
public void SetPan(CameraPtzMoveType type, int panStep)
{
ValidationUtil.ValidateEnum(typeof(CameraPtzMoveType), type, nameof(type));
CameraErrorFactory.ThrowIfError(Native.SetPan(_camera.GetHandle(), type, panStep),
"Failed to set the camera pan type.");
}
///
/// Gets the current position of the camera.
///
/// 3
/// Returns the camera's horizontal position.
/// The camera already has been disposed of.
public int GetPan()
{
CameraErrorFactory.ThrowIfError(Native.GetPan(_camera.GetHandle(), out int val),
"Failed to get the camera pan step.");
return val;
}
///
/// Sets the position to move vertically.
///
/// 3
/// the PTZ move type.
/// The tilt step.
/// In case of invalid parameters.
/// The camera already has been disposed of.
public void SetTilt(CameraPtzMoveType type, int tiltStep)
{
ValidationUtil.ValidateEnum(typeof(CameraPtzMoveType), type, nameof(type));
CameraErrorFactory.ThrowIfError(Native.SetTilt(_camera.GetHandle(), type, tiltStep),
"Failed to set the camera tilt type\t.");
}
///
/// Gets the current position of the camera.
///
/// 3
/// Returns the current vertical position.
/// The camera already has been disposed of.
public int GetTilt()
{
CameraErrorFactory.ThrowIfError(Native.GetTilt(_camera.GetHandle(), out int val),
"Failed to set the camera current position.");
return val;
}
///
/// Gets the lower limit and the upper limit for the pan position.
///
/// 3
///
/// If the minimum value is greater than the maximum value, it means this feature is not supported.
///
/// In case of this feature is not supported.
public Range PanRange
{
get
{
if (!_panRange.HasValue)
{
throw new NotSupportedException("Pan is not supported.");
}
return _panRange.Value;
}
}
///
/// Gets the lower limit and the upper limit for the tilt position.
///
/// 3
///
/// If the minimum value is greater than the maximum value, it means this feature is not supported.
///
/// In case of this feature is not supported.
public Range TiltRange
{
get
{
if (!_tiltRange.HasValue)
{
throw new NotSupportedException("Tilt is not supported.");
}
return _tiltRange.Value;
}
}
#endregion PTZ(Pan Tilt Zoom), Pan, Tilt
#region EXIF tag
///
/// The scene mode.
///
/// true if EXIF tags are enabled in the JPEG file, otherwise false.
/// 3
/// The camera already has been disposed of.
public bool EnableTag
{
get
{
CameraErrorFactory.ThrowIfError(Native.IsEnabledTag(_camera.GetHandle(), out bool val),
"Failed to get camera enable tag");
return val;
}
set
{
CameraErrorFactory.ThrowIfError(Native.EnableTag(_camera.GetHandle(), value),
"Failed to set camera enable tag.");
}
}
///
/// The camera image description in the EXIF tag.
///
/// 3
/// The camera already has been disposed of.
public string ImageDescriptionTag
{
get
{
IntPtr val = IntPtr.Zero;
try
{
CameraErrorFactory.ThrowIfError(Native.GetImageDescription(_camera.GetHandle(), out val),
"Failed to get image description");
return Marshal.PtrToStringAnsi(val);
}
finally
{
LibcSupport.Free(val);
}
}
set
{
CameraErrorFactory.ThrowIfError(Native.SetImageDescription(_camera.GetHandle(), value),
"Failed to set image description.");
}
}
///
/// The software information in the EXIF tag.
///
/// 3
/// The camera already has been disposed of.
public string SoftwareTag
{
get
{
IntPtr val = IntPtr.Zero;
try
{
CameraErrorFactory.ThrowIfError(Native.GetTagSoftware(_camera.GetHandle(), out val),
"Failed to get tag software");
return Marshal.PtrToStringAnsi(val);
}
finally
{
LibcSupport.Free(val);
}
}
set
{
CameraErrorFactory.ThrowIfError(Native.SetTagSoftware(_camera.GetHandle(), value),
"Failed to set tag software.");
}
}
///
/// The geo tag(GPS data) in the EXIF tag.
///
/// 3
/// The camera already has been disposed of.
public Location GeoTag
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetGeotag(_camera.GetHandle(),
out double latitude, out double longitude, out double altitude), "Failed to get tag");
return new Location(latitude, longitude, altitude);
}
set
{
CameraErrorFactory.ThrowIfError(Native.SetGeotag(_camera.GetHandle(),
value.Latitude, value.Longitude, value.Altitude), "Failed to set geo tag.");
}
}
///
/// Removes the geo tag(GPS data) in the EXIF(EXchangeable Image File format) tag.
///
/// 3
/// The camera already has been disposed of.
public void RemoveGeoTag()
{
CameraErrorFactory.ThrowIfError(Native.RemoveGeotag(_camera.GetHandle()),
"Failed to remove the geotag\t.");
}
///
/// The camera orientation in the tag.
///
/// 3
/// The camera already has been disposed of.
public CameraTagOrientation OrientationTag
{
get
{
CameraErrorFactory.ThrowIfError(Native.GetTagOrientation(_camera.GetHandle(), out var val),
"Failed to get camera tag orientation");
return val;
}
set
{
ValidationUtil.ValidateEnum(typeof(CameraTagOrientation), value);
CameraErrorFactory.ThrowIfError(Native.SetTagOrientation(_camera.GetHandle(), value),
"Failed to set camera tag orientation.");
}
}
#endregion EXIF tag
}
}