Exemple #1
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Save in new destination?", "Save", MessageBoxButtons.YesNoCancel);

            if (dr == DialogResult.Cancel)
            {
                return;
            }
            string strFolder = "";

            if (dr == DialogResult.Yes)
            {
                if (DialogResult.OK != FBD.Browse(out strFolder, true))
                {
                    strFolder = "";
                }
            }
            using (TabPage tp = SelectedTab)
            {
                PictureBox pb          = tp.PB();
                FileInfo   fi          = tp.FI();
                string     strFilename = strFolder != "" ? strFolder + "\\" + fi.Name : fi.FullName;
                pb.Image.Save(strFilename, ImageFormat.Jpeg);
                unmarkChanged(tp);
            }
        }
Exemple #2
0
 private void toolStripRotate_KeyUp(object sender, KeyEventArgs e)
 {
     toolStripRotate.Text = Regex.Replace(toolStripRotate.Text, "\\D", "");
     if (!string.IsNullOrEmpty(toolStripRotate.Text) && int.Parse(toolStripRotate.Text) > 0)
     {
         TabPage    tp  = SelectedTab;
         PictureBox pb  = tp.PB();
         FileInfo   fi  = tp.FI();
         Image      img = pb.Image;
         using (Graphics g = Graphics.FromImage(img))
         {
             // Set world transform of graphics object to translate.
             Point p = new Point(int.Parse(Math.Floor(float.Parse(img.Width.ToString()) / 2).ToString()), int.Parse(Math.Floor(float.Parse(img.Height.ToString()) / 2).ToString()));
             //g.RenderingOrigin = p;
             //g.TranslateTransform(p.X,p.Y);
             g.TranslateTransform(p.X * -1, p.Y);
             //g.FillRectangle(Brushes.White, 0, 0, 9000, 9000);
             g.RotateTransform(float.Parse(toolStripRotate.Text));
             g.DrawImage(img, 0, 0);
             //g.Save();
         }
         pb.Image = img;
         pb.Refresh();
         markChanged(tp);
     }
 }
Exemple #3
0
        private void toolStripWidth_KeyUp(object sender, KeyEventArgs e)
        {
            bool bPercent = toolStripWidth.Text.Contains("%");

            toolStripWidth.Text = Regex.Replace(toolStripWidth.Text, "\\D", "");
            if (!string.IsNullOrEmpty(toolStripWidth.Text) && int.Parse(toolStripWidth.Text) > 0)
            {
                TabPage    tp = SelectedTab;
                PictureBox pb = tp.PB();
                FileInfo   fi = tp.FI();
                if (uniformToolStripMenuItem.Checked)
                {
                    toolStripHeight.Text = Math.Floor(pb.Image.Height * (float.Parse(toolStripWidth.Text) / pb.Image.Width)).ToString();
                }
                if (int.Parse(toolStripHeight.Text) > 0)
                {
                    pb.Image = new Bitmap(Bitmap.FromFile(fi.FullName) as Image, new Size(int.Parse(toolStripWidth.Text), int.Parse(toolStripHeight.Text)));
                    markChanged(tp);
                }
            }
        }
Exemple #4
0
        private void ResizePicture(object state)
        {
            TabPage tp = state as TabPage;

            tp.Select();
            PictureBox pb = tp.PB();
            FileInfo   fi = tp.FI();

            System.GC.Collect();
            if (pb.Image == null)
            {
                pb.Image = new Bitmap(Bitmap.FromFile(fi.FullName) as Image);
            }
            this.Invoke((MethodInvoker) delegate
            {
                System.GC.Collect();
                pb.Image = new Bitmap(Bitmap.FromFile(fi.FullName) as Image, int.Parse(Math.Floor(pb.Image.Width * .5).ToString()), int.Parse(Math.Floor(pb.Image.Height * .5).ToString()));
                pb.Refresh();
                markChanged(tp);
                System.GC.Collect();
            });
        }