Ejemplo n.º 1
0
 private void cropPic_Click(object sender, EventArgs e)
 {
     
     int centreX = (pictureBox1.Height / 2) - (212 / 2);
     int centreY = (pictureBox1.Width / 2) - (160 / 2);
     cropBox = new CropBox(new Rectangle(centreY, centreX, 160, 212));
     cropBox.SetPictureBox(pictureBox1);
     cropBox.allowDeformingDuringMovement = true; //if mouse can set cropbox beond Main picturebox
     pictureBox1.Invalidate();
 }
Ejemplo n.º 2
0
        private void cropPic_Click(object sender, EventArgs e)
        {
            int centreX = (pictureBox1.Height / 2) - (212 / 2);
            int centreY = (pictureBox1.Width / 2) - (160 / 2);

            cropBox = new CropBox(new Rectangle(centreY, centreX, 160, 212));
            cropBox.SetPictureBox(pictureBox1);
            cropBox.allowDeformingDuringMovement = true; //if mouse can set cropbox beond Main picturebox
            pictureBox1.Invalidate();
        }
Ejemplo n.º 3
0
        private void mainSave_Click(object sender, EventArgs e)
        {
            CropBox.TakePic(pictureBox1, snapShot);

            if (Properties.Settings.Default.SaveLocation == "")
            {
                saveLocation = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            }

            else
            {
                saveLocation = Properties.Settings.Default.SaveLocation;
            }

            if (Properties.Settings.Default.scaleEnabled == true)
            {
                int scaleWidth  = Convert.ToInt32(Properties.Settings.Default.scaleWidth);
                int scaleHeight = Convert.ToInt32(Properties.Settings.Default.scaleHeight);
                var destRect    = new Rectangle(0, 0, scaleWidth, scaleHeight);
                var destImage   = new Bitmap(scaleWidth, scaleHeight);

                destImage.SetResolution(snapShot.Image.HorizontalResolution, snapShot.Image.VerticalResolution);

                using (var graphics = Graphics.FromImage(destImage))
                {
                    graphics.CompositingMode    = CompositingMode.SourceCopy;
                    graphics.CompositingQuality = CompositingQuality.HighQuality;
                    graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    graphics.SmoothingMode      = SmoothingMode.HighQuality;
                    graphics.PixelOffsetMode    = PixelOffsetMode.HighQuality;

                    using (var wrapMode = new ImageAttributes())
                    {
                        wrapMode.SetWrapMode(WrapMode.TileFlipXY);
                        graphics.DrawImage(snapShot.Image, destRect, 0, 0, snapShot.Image.Width, snapShot.Image.Height, GraphicsUnit.Pixel, wrapMode);
                    }
                }
                destImage.Save(saveLocation + "\\Photo_" + DateTime.Now.ToString("yyyyMMdd_hh_mm_ss") + ".jpg", ImageFormat.Jpeg);
            }
            else
            {
                snapShot.Image.Save(saveLocation + "\\Photo_" + DateTime.Now.ToString("yyyyMMdd_hh_mm_ss") + ".jpg", ImageFormat.Jpeg);
            }
        }
Ejemplo n.º 4
0
 //take picture button
 private void takePic_Click(object sender, EventArgs e)
 {
     CropBox.TakePic(pictureBox1, snapShot);
 }