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(); }
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); }