Release 4.0.0-preview1-00321
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Vision / MediaVision / BarcodeImageConfiguration.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
19 namespace Tizen.Multimedia.Vision
20 {
21     /// <summary>
22     /// Represents a configuration for the image to be generated by <see cref="BarcodeGenerator"/>.
23     /// </summary>
24     /// <since_tizen> 3 </since_tizen>
25     public class BarcodeImageConfiguration
26     {
27         /// <summary>
28         /// Initializes a new instance of the <see cref="BarcodeImageConfiguration"/> class.
29         /// </summary>
30         /// <remarks>
31         /// The mediastorage privilege (http://tizen.org/privilege/mediastorage) is needed if the image path is relevant to media storage.<br/>
32         /// The externalstorage privilege (http://tizen.org/privilege/externalstorage) is needed if the image path is relevant to external storage.
33         /// </remarks>
34         /// <param name="size">The <see cref="Size"/> of the generated image.</param>
35         /// <param name="path">The path to the file to be generated.</param>
36         /// <param name="imageFormat">The format of the output image.</param>
37         /// <exception cref="ArgumentOutOfRangeException">
38         ///     The width of <paramref name="size"/> is less than or equal to zero.<br/>
39         ///     -or-<br/>
40         ///     The height of <paramref name="size"/> is less than or equal to zero.
41         /// </exception>
42         /// <exception cref="ArgumentNullException"><paramref name="path"/> is null.</exception>
43         /// <exception cref="ArgumentException"><paramref name="imageFormat"/> is invalid.</exception>
44         /// <code>
45         /// BarcodeImageConfiguration imageConfig = new BarcodeImageConfiguration(new Size(500, 400), "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.JPG);
46         /// </code>
47         /// <since_tizen> 3 </since_tizen>
48         public BarcodeImageConfiguration(Size size, string path, BarcodeImageFormat imageFormat)
49         {
50             if (size.Width <= 0)
51             {
52                 throw new ArgumentOutOfRangeException(nameof(Size.Width), size.Width,
53                     "width can't be less than or equal to zero.");
54             }
55
56             if (size.Height <= 0)
57             {
58                 throw new ArgumentOutOfRangeException(nameof(Size.Height), size.Height,
59                     "height can't be less than or equal to zero.");
60             }
61
62             if (path == null)
63             {
64                 throw new ArgumentNullException(nameof(path));
65             }
66
67             ValidationUtil.ValidateEnum(typeof(BarcodeImageFormat), imageFormat);
68
69             Size = size;
70             Path = path;
71             Format = imageFormat;
72         }
73
74         /// <summary>
75         /// Initializes a new instance of the <see cref="BarcodeImageConfiguration"/> class.
76         /// </summary>
77         /// <remarks>
78         /// The mediastorage privilege (http://tizen.org/privilege/mediastorage) is needed if the image path is relevant to media storage.<br/>
79         /// The externalstorage privilege (http://tizen.org/privilege/externalstorage) is needed if the image path is relevant to external storage.
80         /// </remarks>
81         /// <param name="width">The width of the image to be generated.</param>
82         /// <param name="height">The height of the image to be generated.</param>
83         /// <param name="path">The path to the file to be generated.</param>
84         /// <param name="imageFormat">The format of the output image.</param>
85         /// <exception cref="ArgumentOutOfRangeException">
86         ///     <paramref name="width"/> is less than or equal to zero.<br/>
87         ///     -or-<br/>
88         ///     <paramref name="height"/> is less than or equal to zero.
89         /// </exception>
90         /// <exception cref="ArgumentNullException"><paramref name="path"/> is null.</exception>
91         /// <exception cref="ArgumentException"><paramref name="imageFormat"/> is invalid.</exception>
92         /// <code>
93         /// BarcodeImageConfiguration imageConfig = new BarcodeImageConfiguration(500, 400, "/opt/usr/test-barcode-generate-new", BarcodeImageFormat.JPG);
94         /// </code>
95         /// <since_tizen> 3 </since_tizen>
96         public BarcodeImageConfiguration(int width, int height, string path, BarcodeImageFormat imageFormat)
97             : this(new Size(width, height), path, imageFormat)
98         {
99         }
100
101         /// <summary>
102         /// Gets the size of the image.
103         /// </summary>
104         /// <since_tizen> 3 </since_tizen>
105         public Size Size { get; }
106
107         /// <summary>
108         /// Gets the width of the image.
109         /// </summary>
110         /// <since_tizen> 3 </since_tizen>
111         public int Width => Size.Width;
112
113         /// <summary>
114         /// Gets the height of the image.
115         /// </summary>
116         /// <since_tizen> 3 </since_tizen>
117         public int Height => Size.Height;
118
119         /// <summary>
120         /// Gets the path to the file that has to be generated.
121         /// </summary>
122         /// <remarks>
123         /// The mediastorage privilege (http://tizen.org/privilege/mediastorage) is needed if the image path is relevant to media storage.<br/>
124         /// The externalstorage privilege (http://tizen.org/privilege/externalstorage) is needed if the image path is relevant to external storage.
125         /// </remarks>
126         /// <since_tizen> 3 </since_tizen>
127         public string Path { get; }
128
129         /// <summary>
130         /// Gets the format of the output image.
131         /// </summary>
132         /// <since_tizen> 3 </since_tizen>
133         public BarcodeImageFormat Format { get; }
134     }
135 }