Beispiel #1
0
        internal SWIGTYPE_p_unsigned_char GetBuffer()
        {
            global::System.IntPtr    cPtr = NDalicPINVOKE.PixelBuffer_GetBuffer(swigCPtr);
            SWIGTYPE_p_unsigned_char ret  = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false);

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Beispiel #2
0
        public static PixelBuffer LoadImageFromBuffer(System.IO.Stream stream, Size2D size)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (size == null)
            {
                throw new ArgumentNullException(nameof(size));
            }
            long streamLength = stream.Length - stream.Position;

            if (streamLength <= 0)
            {
                throw new InvalidOperationException("stream lenght is <= 0");
            }

            // Read data from stream
            byte[] streamData = new byte[streamLength];
            stream.Read(streamData, 0, (int)streamLength);

            // Allocate buffer that internal DALi engine can read
            VectorUnsignedChar buffer = new VectorUnsignedChar();

            buffer.Resize((uint)streamLength);
            var bufferBegin = buffer.Begin();

            global::System.Runtime.InteropServices.HandleRef bufferRef = SWIGTYPE_p_unsigned_char.getCPtr(bufferBegin);

            // Copy data from stream to buffer
            System.Runtime.InteropServices.Marshal.Copy(streamData, 0, bufferRef.Handle, (int)streamLength);

            var         uSize = new Uint16Pair((uint)size.Width, (uint)size.Height);
            PixelBuffer ret   = new PixelBuffer(Interop.ImageLoading.LoadImageFromBuffer(VectorUnsignedChar.getCPtr(buffer), Uint16Pair.getCPtr(uSize)), true);

            uSize.Dispose();
            buffer.Dispose();
            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Beispiel #3
0
        /// <summary>
        /// Get VectorUnsignedChar from System.IO.Stream.
        /// This funcion exist only for Constructor.
        /// </summary>
        /// This will not be public opened.
        private static VectorUnsignedChar GetRawBuffrFromStreamHelper(System.IO.Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }
            if (!stream.CanRead)
            {
                throw new InvalidOperationException("stream don't support to read");
            }

            // Copy stream to memoryStream
            System.IO.MemoryStream memoryStream = new System.IO.MemoryStream();
            stream.CopyTo(memoryStream);
            memoryStream.Seek(0, System.IO.SeekOrigin.Begin);

            long streamLength = memoryStream.Length;

            if (streamLength <= 0)
            {
                throw new InvalidOperationException("stream length is <= 0");
            }

            // Allocate buffer that internal DALi engine can read
            VectorUnsignedChar buffer = new VectorUnsignedChar();

            buffer.Resize((uint)streamLength);
            var bufferBegin = buffer.Begin();

            global::System.Runtime.InteropServices.HandleRef bufferRef = SWIGTYPE_p_unsigned_char.getCPtr(bufferBegin);

            // Copy data from memoryStream to buffer
            System.Runtime.InteropServices.Marshal.Copy(memoryStream.GetBuffer(), 0, bufferRef.Handle, (int)streamLength);

            memoryStream.Dispose();

            return(buffer);
        }
Beispiel #4
0
 internal PixelBuffer(SWIGTYPE_p_unsigned_char pointer) : this(NDalicPINVOKE.new_PixelBuffer__SWIG_2(SWIGTYPE_p_unsigned_char.getCPtr(pointer)), true)
 {
     if (NDalicPINVOKE.SWIGPendingException.Pending)
     {
         throw NDalicPINVOKE.SWIGPendingException.Retrieve();
     }
 }