Example #1
0
        /// <summary>
        /// Gets the doc image.
        /// </summary>
        /// <param name="side">The side.</param>
        /// <returns></returns>
        public static byte[] GetImageBytesFromRanger(RangerSides side)
        {
            RangerImageColorTypes colorType = RockConfig.Load().ImageColorType;

            int imageByteCount;

            imageByteCount = batchPage.rangerScanner.GetImageByteCount(( int )side, ( int )colorType);
            if (imageByteCount > 0)
            {
                byte[] imageBytes = new byte[imageByteCount];

                // create the pointer and assign the Ranger image address to it
                IntPtr imgAddress = new IntPtr(batchPage.rangerScanner.GetImageAddress(( int )side, ( int )colorType));

                // Copy the bytes from unmanaged memory to managed memory
                Marshal.Copy(imgAddress, imageBytes, 0, imageByteCount);

                return(imageBytes);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// Gets the doc image.
        /// </summary>
        /// <param name="side">The side.</param>
        /// <returns></returns>
        private byte[] GetImageBytesFromRanger( RangerSides side )
        {
            RangerImageColorTypes colorType = RockConfig.Load().ImageColorType;

            int imageByteCount;
            imageByteCount = batchPage.rangerScanner.GetImageByteCount( (int)side, (int)colorType );
            if ( imageByteCount > 0 )
            {
                byte[] imageBytes = new byte[imageByteCount];

                // create the pointer and assign the Ranger image address to it
                IntPtr imgAddress = new IntPtr( batchPage.rangerScanner.GetImageAddress( (int)side, (int)colorType ) );

                // Copy the bytes from unmanaged memory to managed memory
                Marshal.Copy( imgAddress, imageBytes, 0, imageByteCount );

                return imageBytes;
            }
            else
            {
                return null;
            }
        }