Ejemplo n.º 1
0
        public object GetImageArray(Bitmap bmp, SensorType sensorType, LumaConversionMode conversionMode)
        {
            this.imageWidth = bmp.Width;
            this.imageHeight = bmp.Height;

            if (sensorType == SensorType.Monochrome)
                return NativeHelpers.GetMonochromePixelsFromBitmap(bmp, conversionMode);
            else if (sensorType == SensorType.Color)
                return NativeHelpers.GetColourPixelsFromBitmap(bmp);
            else
                throw new NotSupportedException(string.Format("Sensor type {0} is not currently supported.", sensorType));
        }
Ejemplo n.º 2
0
 public object GetImageArray(Bitmap bmp, SensorType sensorType, LumaConversionMode conversionMode, out byte[] bitmapBytes)
 {
     this.imageWidth  = bmp.Width;
     this.imageHeight = bmp.Height;
     if (sensorType == SensorType.Monochrome)
     {
         return(this.nativeHelpers.GetMonochromePixelsFromBitmap(bmp, conversionMode, this.GetFlipMode(), out bitmapBytes));
     }
     if (sensorType == SensorType.Color)
     {
         return(this.nativeHelpers.GetColourPixelsFromBitmap(bmp, this.GetFlipMode(), out bitmapBytes));
     }
     throw new NotSupportedException(string.Format("Sensor type {0} is not currently supported.", (object)sensorType));
 }
Ejemplo n.º 3
0
        internal object GetMonochromePixelsFromBitmap(Bitmap bitmap, LumaConversionMode conversionMode, FlipMode flipMode, out byte[] rawBitmapBytes)
        {
            int[,] bitmapPixels = new int[bitmap.Width, bitmap.Height];
            rawBitmapBytes      = new byte[bitmap.Width * bitmap.Height * 3 + 40 + 14 + 1];
            IntPtr hbitmap = bitmap.GetHbitmap();

            try
            {
                this.GetMonochromePixelsFromBitmap(bitmap.Width, bitmap.Height, 8, flipMode, hbitmap, ref bitmapPixels, ref rawBitmapBytes, (int)conversionMode);
            }
            finally
            {
                NativeHelpers.DeleteObject(hbitmap);
            }
            return((object)bitmapPixels);
        }
Ejemplo n.º 4
0
        public static object GetMonochromePixelsFromBitmap(Bitmap bitmap, LumaConversionMode conversionMode)
        {
            int[,] bitmapBytes = new int[bitmap.Width, bitmap.Height];

            IntPtr hBitmap = bitmap.GetHbitmap();
            try
            {
                GetMonochromePixelsFromBitmap(bitmap.Width, bitmap.Height, 8, hBitmap, bitmapBytes, (int)conversionMode);
            }
            finally
            {
                DeleteObject(hBitmap);
            }

            return bitmapBytes;
        }
        internal static object GetMonochromePixelsFromBitmap(Bitmap bitmap, LumaConversionMode conversionMode, FlipMode flipMode, out byte[] rawBitmapBytes)
        {
            int[,] bitmapPixels = new int[bitmap.Width, bitmap.Height];
            rawBitmapBytes      = new byte[(bitmap.Width * bitmap.Height * 3) + 40 + 14 + 1];

            IntPtr hBitmap = bitmap.GetHbitmap();

            try
            {
                GetMonochromePixelsFromBitmap(bitmap.Width, bitmap.Height, 8, flipMode, hBitmap, bitmapPixels, rawBitmapBytes, (int)conversionMode);
            }
            finally
            {
                DeleteObject(hBitmap);
            }

            return(bitmapPixels);
        }