Ejemplo n.º 1
0
 /// <summary>
 ///     Displays data that we get from the compressed file.
 /// </summary>
 public void DisplayDecompressedData()
 {
     LeftImageBitmap = new Bitmap(ImageSize, ImageSize);
     CombineYcbcrToRgb(4);
     ColorListToLeftBitmap();
     UncutBitmap     = new Bitmap(LeftImageBitmap);
     LoadedData      = null;
     LumList         = null;
     CrList          = null;
     CbList          = null;
     ColorList       = null;
     LeftImageBitmap = Padder.CropImage(LeftImageBitmap, new Rectangle(0, 0, RealWidth, RealHeight));
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     Sets the left picture to the image passed in.
        ///     Clears ColorList and Chrome list.
        ///     Sets the bitmap representing the right image
        ///     to be the same as the left image.
        /// </summary>
        /// <param name="i"></param>
        public void SetLeftPicture(Image i)
        {
            ColorList = new List <Color>();

            // ChromeList = new List<List<Ycbcr>>();
            LumList = new List <List <float> >();
            CrList  = new List <List <float> >();
            CbList  = new List <List <float> >();

            ImageHeight = System.BitConverter.GetBytes(i.Height).Select(b => (sbyte)b).ToArray();
            ImageWidth  = System.BitConverter.GetBytes(i.Width).Select(b => (sbyte)b).ToArray();

            LeftImageBitmap  = new Bitmap(Padder.PadImage(i));
            RightImageBitmap = new Bitmap(LeftImageBitmap);
            _subSampled420   = false;
            _imageIsSplit    = false;
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Method to decompress MPEG
        ///     opens a file selector
        ///     reads data
        ///     initializes its data
        ///     sends it off to DctImageProcessor::UntoRippeg function
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void decompressToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            if (FOpen.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            try {
                Stream raw = FOpen.OpenFile();
                using (MemoryStream ms = new MemoryStream()) {
                    raw.CopyTo(ms);
                    MPEGData[0] = new DataManager();

                    leftPicture.Image      = null;
                    rightPicture.Image     = null;
                    MPEGData[0].LoadedData = ms.ToArray().Select(s => (sbyte)s).ToArray();
                    SetSizeToolStrip(MPEGData[0].LoadedData.Length);
                    MPEGData[0].box = leftPicture;
                }
            }
            catch (Exception ex) {
                MessageBox.Show(@"Error: Could not read file from disk. Original error: " + ex.Message);
            }

            DctImageProcessor processor = new DctImageProcessor(MPEGData[0]);

            await Task.Run(() => processor.UndoRippeg());

            //now we just have to use the vector info to move blocks around.
            Bitmap newmap = new Bitmap(MPEGData[0].ImageSize, MPEGData[0].ImageSize);

            for (int i = 0; i < MPEGData[0].ImageSize; i++)
            {
                for (int j = 0; j < MPEGData[0].ImageSize; j++)
                {
                    newmap.SetPixel(i, j, MPEGData[0].UncutBitmap.GetPixel(i, j));
                }
            }

            using (Graphics g = Graphics.FromImage(newmap)) {
                Pen p2 = new Pen(Color.White, 1);
                Pen p  = new Pen(Color.Black, 2);
                foreach (Tuple <Point, Point> mV in MPEGData[0].MVs)
                {
                    for (int i = 0; i < 16; i++)
                    {
                        for (int j = 0; j < 16; j++)
                        {
                            newmap.SetPixel(
                                i + mV.Item2.X, j + mV.Item2.Y,
                                MPEGData[0].UncutBitmap.GetPixel(i + mV.Item1.X, j + mV.Item1.Y)
                                );
                        }
                    }
                    g.DrawLine(p, mV.Item1, mV.Item2);
                    g.DrawLine(p2, mV.Item1, mV.Item2);
                }
            }

            rightPicture.Image = Padder.CropImage(newmap,
                                                  new Rectangle(0, 0, MPEGData[0].RealWidth, MPEGData[0].RealHeight));
        }