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.Diagnostics;
19 using static Interop.ImageUtil;
20 using static Interop.ImageUtil.Transform;
22 namespace Tizen.Multimedia.Util
27 /// <seealso cref="Rotation"/>
28 /// <since_tizen> 4 </since_tizen>
29 public class RotateTransform : ImageTransform
31 private Rotation _rotation;
34 /// Initializes a new instance of the <see cref="RotateTransform"/> class.
36 /// <param name="rotation">The value how to rotate an image.</param>
37 /// <exception cref="ArgumentException"><paramref name="rotation"/> is invalid.</exception>
38 /// <exception cref="ArgumentOutOfRangeException"><paramref name="rotation"/> is <see cref="Rotation.Rotate90"/>.</exception>
39 /// <since_tizen> 4 </since_tizen>
40 public RotateTransform(Rotation rotation)
46 /// Gets or sets the value how to rotate an image.
48 /// <exception cref="ArgumentException"><paramref name="value"/> is invalid.</exception>
49 /// <exception cref="ArgumentOutOfRangeException"><paramref name="value"/> is <see cref="Rotation.Rotate90"/>.</exception>
50 /// <since_tizen> 4 </since_tizen>
51 public Rotation Rotation
53 get { return _rotation; }
56 ValidationUtil.ValidateEnum(typeof(Rotation), value, nameof(Rotation));
58 if (value == Rotation.Rotate0)
60 throw new ArgumentOutOfRangeException(nameof(value), "Rotation can't be Rotate0.");
67 internal override string GenerateNotSupportedErrorMessage(VideoMediaFormat format)
68 => $"'{format.MimeType}' is not supported by RotateTransform.";
70 internal override void Configure(TransformHandle handle)
72 SetRotation(handle, GetImageRotation());
75 private ImageRotation GetImageRotation()
79 case Rotation.Rotate90: return ImageRotation.Rotate90;
80 case Rotation.Rotate180: return ImageRotation.Rotate180;
81 case Rotation.Rotate270: return ImageRotation.Rotate270;
84 Debug.Fail("Rotation is invalid value!");
85 return ImageRotation.Rotate0;