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