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.Runtime.InteropServices;
20 using Tizen.Multimedia.Util;
22 internal static partial class Interop
24 internal static partial class ImageUtil
26 internal static class Transform
28 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
29 internal delegate void TransformCompletedCallback(IntPtr resultPacket, ImageUtilError errorCode,
30 IntPtr userData = default(IntPtr));
32 [DllImport(Libraries.ImageUtil, EntryPoint = "image_util_transform_run")]
33 internal static extern ImageUtilError Run(TransformHandle handle, IntPtr srcPacket,
34 TransformCompletedCallback callback, IntPtr userData = default(IntPtr));
36 [DllImport(Libraries.ImageUtil, EntryPoint = "image_util_transform_create")]
37 internal static extern ImageUtilError Create(out TransformHandle handle);
39 [DllImport(Libraries.ImageUtil, EntryPoint = "image_util_transform_destroy")]
40 internal static extern ImageUtilError Destroy(IntPtr handle);
42 [DllImport(Libraries.ImageUtil, EntryPoint = "image_util_transform_get_colorspace")]
43 internal static extern ImageUtilError GetColorspace(TransformHandle handle, out ImageColorSpace colorspace);
45 [DllImport(Libraries.ImageUtil, EntryPoint = "image_util_transform_set_colorspace")]
46 internal static extern ImageUtilError SetColorspace(TransformHandle handle, ImageColorSpace colorspace);
48 [DllImport(Libraries.ImageUtil, EntryPoint = "image_util_transform_set_hardware_acceleration")]
49 internal static extern ImageUtilError SetHardwareAcceleration(TransformHandle handle, bool mode);
51 [DllImport(Libraries.ImageUtil, EntryPoint = "image_util_transform_set_rotation")]
52 internal static extern ImageUtilError SetRotation(TransformHandle handle, ImageRotation rotation);
54 [DllImport(Libraries.ImageUtil, EntryPoint = "image_util_transform_get_crop_area")]
55 internal static extern ImageUtilError GetCropArea(TransformHandle handle, out uint startX, out uint startY, out uint endX, out uint endY);
57 [DllImport(Libraries.ImageUtil, EntryPoint = "image_util_transform_set_crop_area")]
58 internal static extern ImageUtilError SetCropArea(TransformHandle handle, int startX, int startY, int endX, int endY);
60 [DllImport(Libraries.ImageUtil, EntryPoint = "image_util_transform_get_resolution")]
61 internal static extern ImageUtilError GetResolution(TransformHandle handle, out uint width, out uint height);
63 [DllImport(Libraries.ImageUtil, EntryPoint = "image_util_transform_set_resolution")]
64 internal static extern ImageUtilError SetResolution(TransformHandle handle, uint width, uint height);
67 internal class TransformHandle : SafeHandle
69 protected TransformHandle() : base(IntPtr.Zero, true)
73 public override bool IsInvalid => handle == IntPtr.Zero;
75 protected override bool ReleaseHandle()
77 var ret = Transform.Destroy(handle);
78 if (ret != ImageUtilError.None)
80 Log.Debug(GetType().FullName, $"Failed to release native {GetType().Name}");