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 public class ImageTransformer : IDisposable
28 /// Initializes a new instance of the <see cref="ImageTransformer"/> class.
30 public ImageTransformer()
35 /// Transforms an image with <see cref="ImageTransform"/>.
37 /// <param name="source"><see cref="MediaPacket"/> to transform. The <see cref="MediaPacket.Format"/> of this <paramref name="source"/> must be <see cref="VideoMediaFormat"/>.</param>
38 /// <param name="item"><see cref="ImageTransform"/> to apply.</param>
39 /// <returns>A task that represents the asynchronous transforming operation.</returns>
40 /// <exception cref="ArgumentNullException">
41 /// <paramref name="source"/> is null.\n
43 /// <paramref name="item"/> is null.
45 /// <exception cref="ObjectDisposedException">The <see cref="ImageTransformer"/> has already been disposed of.</exception>
46 /// <exception cref="InvalidOperationException">Failed to apply <see cref="ImageTransform"/>.</exception>
47 public Task<MediaPacket> TransformAsync(MediaPacket source, ImageTransform item)
51 throw new ObjectDisposedException(nameof(ImageTransformer));
56 throw new ArgumentNullException(nameof(source));
61 throw new ArgumentNullException(nameof(item));
64 return item.ApplyAsync(source);
67 #region IDisposable Support
68 private bool _disposed = false;
71 /// Releases the unmanaged resources used by the ImageTransformer.
73 /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
74 protected virtual void Dispose(bool disposing)
83 /// Releases all resources used by the ImageTransformer.