private void loadFirstFileToolStripMenuItem_Click(object sender, EventArgs e) { if (FOpen.ShowDialog() != DialogResult.OK) { return; } try { MPEGData[0] = new DataManager(); Image image = Image.FromStream(FOpen.OpenFile()); MPEGData[0].SetLeftPicture(image); MPEGData[0].box = leftPicture; MPEGData[0].rbox = rightPicture; leftPicture.Image = MPEGData[0].LeftImageBitmap; MemoryStream ms = new MemoryStream(); image.Save(ms, ImageFormat.Bmp); int bytes = (int)ms.Length; SetSizeToolStrip(bytes); ms.Close(); } catch (Exception ex) { MessageBox.Show(@"Error: Could not read file from disk. Original error: " + ex.Message); } MPEGData[0].SplitBytesIntoColorSpaces(); MPEGData[0].DrawYcbcrOnRightBitmap(1); }
/// <summary> /// Loads output.dct /// initializes data /// uses DctImageProcessor::UncoProcess /// in a thread to display a JPEG image /// </summary> /// <param name="sender">c# params</param> /// <param name="e">c# params</param> private void openCompressedToolStripMenuItem_Click(object sender, EventArgs e) { if (FOpen.ShowDialog() != DialogResult.OK) { return; } try { Stream raw = FOpen.OpenFile(); using (MemoryStream ms = new MemoryStream()) { raw.CopyTo(ms); Manager = new DataManager(); leftPicture.Image = null; rightPicture.Image = null; Manager.LoadedData = ms.ToArray().Select(s => (sbyte)s).ToArray(); SetSizeToolStrip(Manager.LoadedData.Length); Manager.box = leftPicture; Manager.rbox = rightPicture; } } catch (Exception ex) { MessageBox.Show(@"Error: Could not read file from disk. Original error: " + ex.Message); } DctImageProcessor processor = new DctImageProcessor(Manager); Task.Run(() => processor.UndoProcess()); }
/// <summary> /// Loads an image and uses /// splits it into YCBCR arrays /// subsamples CB and CR using 4:2:0 /// DctImageProcessor::Process function to /// compress image with /// DCT => QUantize => ZigZag => RLE => File (output.dct) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void compressToolStripMenuItem_Click(object sender, EventArgs e) { if (FOpen.ShowDialog() != DialogResult.OK) { return; } try { Image image = Image.FromStream(FOpen.OpenFile()); Manager.SetLeftPicture(image); leftPicture.Image = Manager.LeftImageBitmap; MemoryStream ms = new MemoryStream(); image.Save(ms, ImageFormat.Bmp); int bytes = (int)ms.Length; SetSizeToolStrip(bytes); ms.Close(); } catch (Exception ex) { MessageBox.Show(@"Error: Could not read file from disk. Original error: " + ex.Message); } Manager.SplitBytesIntoColorSpaces(); Manager.DrawYcbcrOnRightBitmap(1); rightPicture.Image = Manager.RightImageBitmap; DctImageProcessor imageProcessor = new DctImageProcessor(Manager); Task.Run(() => imageProcessor.Process()); }
public void ReadFile(string filePath, string fileName) { string[] arr = new string[3]; try { using (System.IO.StreamReader file = new System.IO.StreamReader(filePath + fileName)) { for (int i = 0; i < 3; i++) { arr[i] = file.ReadLine(); } file.Close(); } } catch (Exception) { FOpenError?.Invoke(); return; } Name = arr[0]; Sex = arr[1]; DateTime.TryParse(arr[2], out DateTime birth); Birthday = birth; FOpen?.Invoke(); }
private void SetRightImage() { if (FOpen.ShowDialog() != DialogResult.OK) { return; } if (FOpen.FileName != null) { rightPicture.Image = new Bitmap(FOpen.FileName); } }
public static Boolean Isload(Form f) { foreach (Form FOpen in Application.OpenForms) { if (FOpen.Name == f.Name) { FOpen.Show(); return(true); } } return(false); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { FOpen.Filter = "Wave File (*.wav)|*.wav"; if (FOpen.ShowDialog() == DialogResult.OK) { pcm = new WaveFileReader(FOpen.FileName); readToArrays(pcm); BytesToNewAlloc(); foreach (var point in left) { chart1.Series["LChannel"].Points.AddY(point); } } }
private void HandleRightContext(object sender, ToolStripItemClickedEventArgs e) { if (e.ClickedItem.Text == @"Set Image") { contextMenuStrip2.Hide(); SetRightImage(); } else if (e.ClickedItem.Text == @"Open Compressed") { contextMenuStrip2.Hide(); if (FOpen.ShowDialog() != DialogResult.OK) { return; } try { Stream raw = FOpen.OpenFile(); using (MemoryStream ms = new MemoryStream()) { raw.CopyTo(ms); Manager = new DataManager(); leftPicture.Image = null; rightPicture.Image = null; Manager.LoadedData = ms.ToArray().Select(s => (sbyte)s).ToArray(); SetSizeToolStrip(Manager.LoadedData.Length); Manager.box = leftPicture; Manager.rbox = rightPicture; } } catch (Exception ex) { MessageBox.Show(@"Error: Could not read file from disk. Original error: " + ex.Message); } DctImageProcessor processor = new DctImageProcessor(Manager); Task.Run(() => processor.UndoProcess()); } else { contextMenuStrip2.Hide(); RightImageClear(); } }
/// <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)); }