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.Threading.Tasks;
20 namespace Tizen.Multimedia.Util
23 /// Provides the ability to transform an image.
25 /// <since_tizen> 4 </since_tizen>
26 public class ImageTransformer : IDisposable
29 /// Initializes a new instance of the <see cref="ImageTransformer"/> class.
31 /// <since_tizen> 4 </since_tizen>
32 public ImageTransformer()
37 /// Transforms an image with <see cref="ImageTransform"/>.
39 /// <param name="source"><see cref="MediaPacket"/> to transform. The <see cref="MediaPacket.Format"/> of this <paramref name="source"/> must be <see cref="VideoMediaFormat"/>.</param>
40 /// <param name="item"><see cref="ImageTransform"/> to apply.</param>
41 /// <returns>A task that represents the asynchronous transforming operation.</returns>
42 /// <exception cref="ArgumentNullException">
43 /// <paramref name="source"/> is null.<br/>
45 /// <paramref name="item"/> is null.
47 /// <exception cref="ArgumentException"><paramref name="source"/> is not video format.</exception>
48 /// <exception cref="ObjectDisposedException">The <see cref="ImageTransformer"/> has already been disposed of.</exception>
49 /// <exception cref="InvalidOperationException">Failed to apply <see cref="ImageTransform"/>.</exception>
50 /// <exception cref="NotSupportedException">Specified transformation is not supported.</exception>
51 /// <since_tizen> 4 </since_tizen>
52 public Task<MediaPacket> TransformAsync(MediaPacket source, ImageTransform item)
56 throw new ObjectDisposedException(nameof(ImageTransformer));
61 throw new ArgumentNullException(nameof(source));
66 throw new ArgumentNullException(nameof(item));
69 if (source.Format is VideoMediaFormat == false)
71 throw new ArgumentException("source is not video format.", nameof(source));
74 return item.ApplyAsync(source);
77 #region IDisposable Support
78 private bool _disposed = false;
81 /// Releases the unmanaged resources used by the ImageTransformer.
83 /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
84 /// <since_tizen> 4 </since_tizen>
85 protected virtual void Dispose(bool disposing)
94 /// Releases all resources used by the ImageTransformer.
96 /// <since_tizen> 4 </since_tizen>