public void redrawBitmap()
        {
            if (cdR == null || cdG == null || cdB == null)
            {
                return;
            }

            int width  = cdR.Width;
            int height = cdR.Height;

            int[,] r = new int[width, height], g = new int[width, height], b = new int[width, height];

            channelHelper(cdR.InterpolationPoints, r);
            channelHelper(cdG.InterpolationPoints, g);
            channelHelper(cdB.InterpolationPoints, b);

            bmp = new UnsafeBitmap(width, height);
            bmp.LockBitmap();
            PixelData pd;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    pd.R = (byte)r[x, y];
                    pd.G = (byte)g[x, y];
                    pd.B = (byte)b[x, y];
                    bmp.SetPixel(x, y, pd);
                }
            }
            bmp.UnlockBitmap();
        }
Beispiel #2
0
        private void prepareChannels()
        {
            UnsafeBitmap bm = new UnsafeBitmap(_input);

            bm.LockBitmap();

            _redChannel   = new byte[bm.Width, bm.Height];
            _greenChannel = new byte[bm.Width, bm.Height];
            _blueChannel  = new byte[bm.Width, bm.Height];

            for (int i = 0; i < bm.Width; ++i)
            {
                for (int j = 0; j < bm.Height; ++j)
                {
                    PixelData pd = bm.GetPixel(i, j);
                    _blueChannel[i, j]  = pd.B;
                    _greenChannel[i, j] = pd.G;
                    _redChannel[i, j]   = pd.R;
                }
            }
            bm.UnlockBitmap();
        }
Beispiel #3
0
        public bool Decompress()
        {
            if (_redChannelData == null || _blueChannelData == null || _greenChannelData == null)
            {
                return(false);
            }

            Console.WriteLine("Decompressing image data");

            Decompressor decompressor = new Decompressor();

            _redChannel = decompressor.Decompress(_redChannelData);

            _greenChannel = decompressor.Decompress(_greenChannelData);

            _blueChannel = decompressor.Decompress(_blueChannelData);

            Console.WriteLine("Tworzenie koñcowej bitmapy");
            Bitmap       bmp          = new Bitmap(_blueChannel.GetLength(0), _blueChannel.GetLength(1), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            UnsafeBitmap unsafeBitmap = new UnsafeBitmap(bmp);

            unsafeBitmap.LockBitmap();

            for (int i = 0; i < unsafeBitmap.Width; ++i)
            {
                for (int j = 0; j < unsafeBitmap.Height; ++j)
                {
                    PixelData pd = new PixelData((byte)_redChannel[i, j], (byte)_greenChannel[i, j], (byte)_blueChannel[i, j]);
                    unsafeBitmap.SetPixel(i, j, pd);
                }
            }
            unsafeBitmap.UnlockBitmap();

            Console.WriteLine("Tworzenie koñcowej bitmapy zakoñczone");
            _output = bmp;

            return(true);
        }