Esempio n. 1
0
        public List <byte> LoadImageData(Block <byte> yChannel, Block <byte> cbChannel, Block <byte> crChannel)
        {
            List <byte> rawImageData = new List <byte>();

            for (int j = 0; j < yChannel.GetHeight(); j++)
            {
                for (int i = 0; i < yChannel.GetWidth(); i++)
                {
                    Color rgb = ColourConverter.YCCToRGB(yChannel.GetCell(i, j), cbChannel.GetCell(i, j), crChannel.GetCell(i, j));
                    rawImageData.Add(rgb.B);
                    rawImageData.Add(rgb.G);
                    rawImageData.Add(rgb.R);
                }
            }

            return(rawImageData);
        }
Esempio n. 2
0
        public List <byte> Compress()
        {
            List <Block <short> > yccChannels = ColourConverter.BitmapRGBToYCC(this.bitmap, 8);

            Block <short> cbCulled = yccChannels[1].CullBlockToBlockFactor(2, 8);
            Block <short> crCulled = yccChannels[2].CullBlockToBlockFactor(2, 8);

            List <Block <short> > yBlocks  = DCT.DCTChannel(yccChannels[0], 8);
            List <Block <short> > cbBlocks = DCT.DCTChannel(cbCulled, 8);
            List <Block <short> > crBlocks = DCT.DCTChannel(crCulled, 8);

            Quantizer   quantizer = new Quantizer();
            List <byte> yStream   = RunLength.RLE(yBlocks, quantizer.GetLumiQT());
            List <byte> cbStream  = RunLength.RLE(cbBlocks, quantizer.GetChromaQT());
            List <byte> crStream  = RunLength.RLE(crBlocks, quantizer.GetChromaQT());

            yStream.AddRange(cbStream);
            yStream.AddRange(crStream);

            return(yStream);
        }