Release 4.0.0-preview1-00172
[platform/core/csapi/tizenfx.git] / src / Tizen.Content.MediaContent / Tizen.Content.MediaContent / ImageInfo.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Diagnostics;
19
20 namespace Tizen.Content.MediaContent
21 {
22     /// <summary>
23     /// Represents the image media stored in the device.
24     /// </summary>
25     public class ImageInfo : MediaInfo
26     {
27         internal ImageInfo(Interop.MediaInfoHandle handle) : base(handle)
28         {
29             IntPtr imageHandle = IntPtr.Zero;
30
31             try
32             {
33                 Interop.MediaInfo.GetImage(handle, out imageHandle).ThrowIfError("Failed to retrieve data");
34
35                 Debug.Assert(imageHandle != IntPtr.Zero);
36
37                 Width = InteropHelper.GetValue<int>(imageHandle, Interop.ImageInfo.GetWidth);
38                 Height = InteropHelper.GetValue<int>(imageHandle, Interop.ImageInfo.GetHeight);
39
40                 Orientation = InteropHelper.GetValue<Orientation>(imageHandle, Interop.ImageInfo.GetOrientation);
41
42                 DateTaken = InteropHelper.GetString(imageHandle, Interop.ImageInfo.GetDateTaken);
43                 BurstId = InteropHelper.GetString(imageHandle, Interop.ImageInfo.GetBurstId);
44                 ExposureTime = InteropHelper.GetString(imageHandle, Interop.ImageInfo.GetExposureTime);
45
46                 FNumber = InteropHelper.GetValue<double>(imageHandle, Interop.ImageInfo.GetFNumber);
47                 Iso = InteropHelper.GetValue<int>(imageHandle, Interop.ImageInfo.GetISO);
48
49                 Model = InteropHelper.GetString(imageHandle, Interop.ImageInfo.GetModel);
50
51                 IsBurstShot = InteropHelper.GetValue<bool>(imageHandle, Interop.ImageInfo.IsBurstShot);
52
53             }
54             finally
55             {
56                 Interop.ImageInfo.Destroy(imageHandle);
57             }
58         }
59
60         /// <summary>
61         /// Gets the image width in pixels.
62         /// </summary>
63         /// <value>The image width in pixels.</value>
64         public int Width { get; }
65
66         /// <summary>
67         /// Gets the image height in pixels.
68         /// </summary>
69         /// <value>The image height in pixels.</value>
70         public int Height { get; }
71
72         /// <summary>
73         /// Gets the orientation of image.
74         /// </summary>
75         /// <value>The orientation of image.</value>
76         public Orientation Orientation { get; }
77
78         /// <summary>
79         /// Gets the date of the creation time as a formatted string.
80         /// </summary>
81         /// <value>The date of the creation time as a formatted string.</value>
82         public string DateTaken { get; }
83
84         /// <summary>
85         /// Gets the burst shot ID.
86         /// </summary>
87         /// <value>The burst shot ID if it is a burst shot, otherwise an empty string.</value>
88         /// <seealso cref="IsBurstShot"/>
89         public string BurstId { get; }
90
91         /// <summary>
92         /// Gets the exposure time from EXIF.
93         /// </summary>
94         /// <value>The exposure time from EXIF.</value>
95         public string ExposureTime { get; }
96
97         /// <summary>
98         /// Gets the FNumber from EXIF.
99         /// </summary>
100         /// <value>The FNumber from exif.</value>
101         public double FNumber { get; }
102
103         /// <summary>
104         /// Gets the ISO from EXIF.
105         /// </summary>
106         /// <value>The iso from EXIF.</value>
107         public int Iso { get; }
108
109         /// <summary>
110         /// Gets the model from EXIF.
111         /// </summary>
112         /// <value>The model from EXIF.</value>
113         public string Model { get; }
114
115         /// <summary>
116         /// Gets the value indicating whether the media is a burst shot image.
117         /// </summary>
118         /// <value>true if the media is a burst shot image, otherwise false.</value>
119         public bool IsBurstShot { get; }
120     }
121 }