/*
* Copyright(c) 2020 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using System.ComponentModel;
namespace Tizen.NUI
{
///
/// The PixelData object holds a pixel buffer.
/// The PixelData takes over the ownership of the pixel buffer.
/// The buffer memory must not be released outside of this class, instead,
/// the PixelData object will release it automatically when the reference count falls to zero.
///
/// Please DO NOT use! This will be deprecated!
/// PixelData class requires externally allocated pixel memory buffer and this buffer loses its ownershop by native DALi.
/// And this would make some problem, because dotnet runtime would change the address of memory allocated.
/// So this is required to be removed.
/// currently no use. will be added later
/// 5
/// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public class PixelData : BaseHandle
{
///
/// Creates a PixelData object.
///
/// The raw pixel data.
/// The size of the buffer in bytes.
/// Buffer width in pixels.
/// Buffer height in pixels.
/// The pixel format.
/// The function used to release the memory.
/// 5
/// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public PixelData(byte[] buffer, uint bufferSize, uint width, uint height, PixelFormat pixelFormat, PixelData.ReleaseFunction releaseFunction) : this(Interop.PixelData.New(buffer, bufferSize, width, height, (int)pixelFormat, (int)releaseFunction), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal PixelData(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PixelData.Upcast(cPtr), cMemoryOwn)
{
}
///
/// Enumeration for function to release the pixel buffer.
///
/// 5
/// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public enum ReleaseFunction
{
///
/// Use free function to release the pixel buffer.
///
Free,
///
/// Use delete[] operator to release the pixel buffer.
///
DeleteArray
}
///
/// Get URI from pixel data.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public Uri Uri
{
get
{
string Uri = "";
Uri = Interop.PixelData.GenerateUrl(this.swigCPtr.Handle);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
return new Uri(Uri);
}
}
///
/// Gets the width of the buffer in pixels.
///
/// The width of the buffer in pixels.
/// 5
/// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public uint GetWidth()
{
uint ret = Interop.PixelData.GetWidth(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Gets the height of the buffer in pixels.
///
/// The height of the buffer in pixels.
/// 5
/// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public uint GetHeight()
{
uint ret = Interop.PixelData.GetHeight(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
///
/// Gets the pixel format.
///
/// The pixel format.
/// 5
/// This will be released at Tizen.NET API Level 5, so currently this would be used as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
public PixelFormat GetPixelFormat()
{
PixelFormat ret = (PixelFormat)Interop.PixelData.GetPixelFormat(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PixelData obj)
{
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
{
Interop.PixelData.DeletePixelData(swigCPtr);
}
}
}