Example #1
0
        /// <summary>
        /// Creates a new instance of the <see cref="SDKStream"/> class with an underlying SDK memory stream.
        /// Note that this stream will not resize itself
        /// </summary>
        /// <param name="buffer">Pointer to the memory buffer to use for the stream</param>
        /// <param name="length">The size of the memory buffer in bytes</param>
        public SDKStream(IntPtr buffer, long length)
        {
            if (buffer == IntPtr.Zero)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            ErrorCode err;

            if (CanonSDK.IsVerGE34)
            {
                err = CanonSDK.EdsCreateMemoryStreamFromPointer(buffer, length, out _Reference);
            }
            else
            {
                err = CanonSDK.EdsCreateMemoryStreamFromPointer(buffer, (int)length, out _Reference);
            }
            ErrorHandler.CheckError(err);
        }
Example #2
0
        /// <summary>
        /// Creates a new instance of the <see cref="SDKStream"/> class with an underlying SDK memory stream.
        /// Note that this stream will not resize itself
        /// </summary>
        /// <param name="buffer">The memory buffer to use for the stream</param>
        public SDKStream(byte[] buffer)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            ErrorCode err;

            if (CanonSDK.IsVerGE34)
            {
                err = CanonSDK.EdsCreateMemoryStreamFromPointer(buffer, buffer.LongLength, out _Reference);
            }
            else
            {
                err = CanonSDK.EdsCreateMemoryStreamFromPointer(buffer, (int)buffer.LongLength, out _Reference);
            }
            ErrorHandler.CheckError(err);
        }