コード例 #1
0
        /// <summary>
        /// Associate the JPEG image of length <code>imageSize</code> bytes stored in  <code>jpegImage</code> with this
        /// decompressor instance.  This image will be used as the source image for subsequent decompress operations.
        /// </summary>
        /// <param name="jpegImage"> JPEG image buffer</param>
        public void SetJpegImage(byte[] jpegImage)
        {
            Contract.Requires(jpegImage != null);

            this.jpegBuffer = jpegImage;
            int         width;
            int         height;
            Subsampling chroma;
            Colourspace colourspace;

            if (NativeMethods.decompressHeader(this.Handle,
                                               this.jpegBuffer,
                                               this.jpegBuffer.Length,
                                               out width,
                                               out height,
                                               out chroma,
                                               out colourspace) != 0)
            {
                throw new Exception(Marshal.PtrToStringAnsi(NativeMethods.getErrorMessage()));
            }

            this.jpegWidth       = width;
            this.jpegHeight      = height;
            this.jpegSubsampling = chroma;
            this.JpegColourspace = colourspace;
        }
コード例 #2
0
 internal static extern int decompressHeader(IntPtr handle,
                                             [In][MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.U1)]
                                             byte[] sourceBuffer,
                                             int size,
                                             out int width,
                                             out int height,
                                             [MarshalAs(UnmanagedType.I4)] out Subsampling chroma,
                                             [MarshalAs(UnmanagedType.I4)] out Colourspace colourspace);
コード例 #3
0
        /// <summary>
        /// Associate the JPEG image of length <code>imageSize</code> bytes stored in  <code>jpegImage</code> with this
        /// decompressor instance.  This image will be used as the source image for subsequent decompress operations.
        /// </summary>
        /// <param name="jpegImage"> JPEG image buffer</param>
        public void SetJpegImage(byte[] jpegImage)
        {
            Contract.Requires(jpegImage != null);

            this.jpegBuffer = jpegImage;
            int width;
            int height;
            Subsampling chroma;
            Colourspace colourspace;

            if (NativeMethods.decompressHeader(this.Handle,
                                                  this.jpegBuffer,
                                                  this.jpegBuffer.Length,
                                                  out width,
                                                  out height,
                                                  out chroma,
                                                  out colourspace) != 0)
            {
                throw new Exception(Marshal.PtrToStringAnsi(NativeMethods.getErrorMessage()));
            }

            this.jpegWidth = width;
            this.jpegHeight = height;
            this.jpegSubsampling = chroma;
            this.JpegColourspace = colourspace;
        }