コード例 #1
0
ファイル: Utils.cs プロジェクト: b9chris/ArpanJpegEncoder
        public static byte[,,] Fill_Image_Buffer(Bitmap bmp, IProgress progress, ICurrentOperation operation)
        {
            if (operation != null)
                operation.SetOperation(CurrentOperation.FillImageBuffer);

            Point originalSize = GetActualDimension(new Point(bmp.Width, bmp.Height));
            byte[,,] Bitmap_Buffer = new byte[originalSize.X,originalSize.Y, 3];

            IntPtr hbmScreen = IntPtr.Zero;
            IntPtr hBmpInput = bmp.GetHbitmap();

            InteropGDI.BITMAP bmpInput = new InteropGDI.BITMAP();
            InteropGDI.GetObject(hBmpInput, 24, ref bmpInput);
            InteropGDI.BITMAPINFOHEADER bi;

            bi.biSize = 40;
            bi.biWidth = bmpInput.bmWidth;
            bi.biHeight = -bmpInput.bmHeight; // Negative to reverse the scan order.
            bi.biPlanes = 1;
            bi.biBitCount = 32;
            bi.biCompression = (uint)InteropGDI.BMP_Compression_Modes.BI_RGB;
            bi.biSizeImage = 0;
            bi.biXPelsPerMeter = 0;
            bi.biYPelsPerMeter = 0;
            bi.biClrUsed = 0;
            bi.biClrImportant = 0;

            ulong bitmapLengthBytes = (ulong)(((bmpInput.bmWidth * bi.biBitCount + 31) / 32) * 4 * bmpInput.bmHeight);

            byte[] bitmap_array = new byte[bitmapLengthBytes];

            IntPtr hdcWindow = InteropGDI.CreateCompatibleDC(IntPtr.Zero);

            InteropGDI.GetDIBits(hdcWindow, hBmpInput, (uint)0,
                (uint)bmpInput.bmHeight,
                bitmap_array,
                ref bi, (uint)InteropGDI.DIB_COLORS.DIB_RGB_COLORS);

            int k = 0, wd = bmpInput.bmWidth, ht = bmpInput.bmHeight;

            for (int j = 0; j < ht; j++)
            {
                if (progress != null)
                    progress.SetProgress((int)bitmapLengthBytes, k);

                for (int i = 0; i < wd; i++)
                {
                    Bitmap_Buffer[i, j, 2] = bitmap_array[k++];
                    Bitmap_Buffer[i, j, 1] = bitmap_array[k++];
                    Bitmap_Buffer[i, j, 0] = bitmap_array[k++];
                    k++;
                }
            }

            InteropGDI.DeleteObject(hdcWindow);
            InteropGDI.DeleteObject(hbmScreen);
            InteropGDI.DeleteObject(hBmpInput);

            return Bitmap_Buffer;
        }
コード例 #2
0
 public UploadsController(
     ICommandHandler commandHandler,
     IStorageProvider storageProvider,
     ICurrentOperation currentOperation,
     IFileMetadataReader fileMetadataReader)
 {
     _commandHandler     = commandHandler;
     _storageProvider    = storageProvider;
     _currentOperation   = currentOperation;
     _fileMetadataReader = fileMetadataReader;
 }
コード例 #3
0
 public ProfileController(
     EfContext dbContext,
     ICommandHandler commandHandler,
     IStorageProvider storageProvider,
     ICurrentOperation currentOperation,
     IFileMetadataReader fileMetadataReader,
     IMemoryCache memoryCache)
 {
     _dbContext          = dbContext;
     _commandHandler     = commandHandler;
     _storageProvider    = storageProvider;
     _currentOperation   = currentOperation;
     _fileMetadataReader = fileMetadataReader;
     _cache = memoryCache;
 }
コード例 #4
0
ファイル: Utils.cs プロジェクト: b9chris/ArpanJpegEncoder
        public static Bitmap Write_Bmp_From_Data(byte [,,] pixel_data, Point dimensions, IProgress progress, ICurrentOperation operation)
        {
            operation.SetOperation(Utils.CurrentOperation.WriteChannelImages);

            int k = 0;
            Bitmap bmp = new Bitmap(dimensions.X,dimensions.Y);
            IntPtr hBmpOutput = bmp.GetHbitmap();
            byte[, ,] Bitmap_Buffer = new byte[dimensions.X, dimensions.Y, 3];

            InteropGDI.BITMAPINFOHEADER bi;

            bi.biSize = 40;
            bi.biWidth = dimensions.X;
            bi.biHeight = -dimensions.Y;
            bi.biPlanes = 1;
            bi.biBitCount = 32;
            bi.biCompression = (uint)InteropGDI.BMP_Compression_Modes.BI_RGB;
            bi.biSizeImage = 0;
            bi.biXPelsPerMeter = 0;
            bi.biYPelsPerMeter = 0;
            bi.biClrUsed = 0;
            bi.biClrImportant = 0;

            ulong bitmapLengthBytes = (ulong)(((dimensions.X * bi.biBitCount + 31) / 32) * 4 * dimensions.Y);

            byte[] bitmap_array = new byte[bitmapLengthBytes];

            for (int j = 0; j < dimensions.Y; j++)
            {
                progress.SetProgress((int)bitmapLengthBytes, k);
                for (int i = 0; i < dimensions.X; i++)
                {
                    bitmap_array[k++] = pixel_data[i, j, 2];
                    bitmap_array[k++] = pixel_data[i, j, 1];
                    bitmap_array[k++] = pixel_data[i, j, 0];
                    k++;
                }
            }

            IntPtr hdcWindow = InteropGDI.CreateCompatibleDC(IntPtr.Zero);

            InteropGDI.SetDIBits(hdcWindow, hBmpOutput, (uint)0,
                (uint)dimensions.Y,
                bitmap_array,
                ref bi, (uint)InteropGDI.DIB_COLORS.DIB_RGB_COLORS);

            bmp = Bitmap.FromHbitmap(hBmpOutput);

            InteropGDI.DeleteObject(hBmpOutput);
            InteropGDI.DeleteObject(hdcWindow);

            return bmp;
        }