2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.Generic;
20 using NativeTransform = Interop.ImageUtil.Transform;
22 namespace Tizen.Multimedia.Util
25 /// Changes the colorspace of an image.
27 /// <seealso cref="ColorSpace"/>
28 /// <since_tizen> 4 </since_tizen>
29 public class ColorSpaceTransform : ImageTransform
31 private ImageColorSpace _imageColorSpace;
34 /// Initializes a new instance of the <see cref="ColorSpaceTransform"/> class.
36 /// <param name="colorSpace">The colorspace of output image.</param>
37 /// <exception cref="ArgumentException"><paramref name="colorSpace"/> is invalid.</exception>
38 /// <exception cref="NotSupportedException"><paramref name="colorSpace"/> is not supported.</exception>
39 /// <seealso cref="SupportedColorSpaces"/>
40 /// <since_tizen> 4 </since_tizen>
41 public ColorSpaceTransform(ColorSpace colorSpace)
43 ColorSpace = colorSpace;
47 /// Gets or sets the colorspace of the result image.
49 /// <exception cref="ArgumentException"><paramref name="value"/> is invalid.</exception>
50 /// <exception cref="NotSupportedException"><paramref name="value"/> is not supported.</exception>
51 /// <seealso cref="SupportedColorSpaces"/>
52 /// <since_tizen> 4 </since_tizen>
53 public ColorSpace ColorSpace
55 get { return _imageColorSpace.ToCommonColorSpace(); }
58 ValidationUtil.ValidateEnum(typeof(ColorSpace), value, nameof(ColorSpace));
60 _imageColorSpace = value.ToImageColorSpace();
64 internal override string GenerateNotSupportedErrorMessage(VideoMediaFormat format)
65 => $"Converting colorspace from '{format.MimeType}' to '{ColorSpace.ToString()}' is not supported.";
67 internal override void Configure(TransformHandle handle)
69 NativeTransform.SetColorspace(handle, _imageColorSpace);
74 /// Gets the supported colorspaces for <see cref="ColorSpaceTransform"/>.
76 /// <since_tizen> 4 </since_tizen>
77 public static IEnumerable<ColorSpace> SupportedColorSpaces
81 foreach (ImageColorSpace value in Enum.GetValues(typeof(ImageColorSpace)))
83 yield return value.ToCommonColorSpace();