Ejemplo n.º 1
0
        private void arrayasy_TextChanged(object sender, EventArgs e)
        {
            image_cropper asy = new image_cropper();

            try
            {
                int arrayY = Int32.Parse(arrayasy.Text);
                image_cropper.Y_array = arrayY;
                if (arrayY < 1)
                {
                    arrayY        = 1;
                    arrayasy.Text = "1";
                }
                else if (arrayY > image_cropper.Y_array_max)
                {
                    arrayasy.Text = image_cropper.Y_array_max.ToString();
                    arrayY        = image_cropper.Y_array_max;
                }
            }
            catch (Exception)
            {
                // 숫자 아님 예외처리
                arrayasy.Text = "1";
            }
        }
Ejemplo n.º 2
0
        private void ApplyBT_Click(object sender, EventArgs e)
        {
            image_cropper applyview = new image_cropper();

            if (image_cropper.isimageadded == false)
            {
                applyview.no_image_loaded();
                return;
            }
            int x         = Int32.Parse(arrayasx.Text);
            int y         = Int32.Parse(arrayasy.Text);
            int cropXsize = Int32.Parse(asarraysize.Text);
            int cropYsize = Int32.Parse(asheightsize.Text);

            image_cropper.X_locate = (x * image_cropper.crop_x_size) - image_cropper.crop_x_size;
            image_cropper.Y_locate = (y * image_cropper.crop_y_size) - image_cropper.crop_y_size;

            if (checkBox1.Checked == true)
            {
                int maxXarray = image_cropper.X_size / cropXsize;
                int maxYarray = image_cropper.Y_size / cropXsize;

                image_cropper.X_array_max = maxXarray;
                image_cropper.Y_array_max = maxYarray;

                image_cropper.arraysize   = cropXsize;
                image_cropper.crop_x_size = image_cropper.crop_y_size = image_cropper.arraysize;
            }
            else if (checkBox1.Checked == false)
            {
                int maxXarray = image_cropper.X_size / cropXsize;
                int maxYarray = image_cropper.Y_size / cropYsize;

                image_cropper.X_array_max = maxXarray;
                image_cropper.Y_array_max = maxYarray;

                image_cropper.crop_x_size = cropXsize;
                image_cropper.crop_y_size = cropYsize;
            }
            CalcArrayX.Text = image_cropper.X_array_max.ToString();
            CalcArrayY.Text = image_cropper.Y_array_max.ToString();

            Croppedview.Image             = image_cropper.CropImage(image_cropper.original, image_cropper.X_locate, image_cropper.Y_locate, image_cropper.crop_x_size, image_cropper.crop_y_size);
            crop_temp.Image               = Croppedview.Image;
            Croppedview.SizeMode          = PictureBoxSizeMode.StretchImage;
            image_cropper.ispreviewloaded = true;
        }
Ejemplo n.º 3
0
        private void Saveallimage_Click(object sender, EventArgs e)
        {
            image_cropper all = new image_cropper();

            if (image_cropper.ispreviewloaded == false)
            {
                all.no_image_error();
                return;
            }
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter = "All Files| *.*";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string filename = dialog.FileName;
                arrayasx.Text = "1";
                arrayasy.Text = "1";
                int arrayX = Int32.Parse(arrayasx.Text);
                int arrayY = Int32.Parse(arrayasy.Text);
                int FC     = 1;
                try
                {
                    while (arrayY < image_cropper.Y_array_max)
                    {
                        while (arrayX < image_cropper.X_array_max)
                        {
                            Croppedview.Image = image_cropper.CropImage(image_cropper.original, image_cropper.X_locate, image_cropper.Y_locate, image_cropper.crop_x_size, image_cropper.crop_y_size);
                            crop_temp.Image   = Croppedview.Image;
                            crop_temp.Image.Save(filename + "(" + FC + ").png", System.Drawing.Imaging.ImageFormat.Png);
                            arrayX = arrayX + 1;
                            FC     = FC + 1;
                            image_cropper.X_locate = (arrayX * image_cropper.crop_x_size) - image_cropper.crop_x_size;
                            image_cropper.Y_locate = (arrayY * image_cropper.crop_y_size) - image_cropper.crop_y_size;
                        }
                        arrayY = arrayY + 1;
                        arrayX = 1;
                    }
                }
                catch
                {
                    all.err_msg_crop();
                }
                all.err_msg_complete();
            }
        }
Ejemplo n.º 4
0
        private void Saveoneimage_Click(object sender, EventArgs e)
        {
            image_cropper once = new image_cropper();

            if (image_cropper.ispreviewloaded == false)
            {
                once.no_image_error();
                return;
            }
            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter = "PNG Format| *.png";
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                crop_temp.Image.Save(dialog.FileName, System.Drawing.Imaging.ImageFormat.Png);
            }
        }
Ejemplo n.º 5
0
        private void Openbutton_Click(object sender, EventArgs e)
        {
            // 이미지 열기 초기설정
            image_cropper opener       = new image_cropper();
            PictureBox    scr_able_box = new PictureBox();

            scr_able_box.Image = image_cropper.original = null;
            string original_image = string.Empty;

            try
            {
                // 예외처리 실행 부
                OpenFileDialog dialog = new OpenFileDialog();
                //dialog.InitialDirectory = @"C:\";
                dialog.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp; *.png;)|*.jpg; *.jpeg; *.gif; *.bmp; *.png;";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    image_cropper.afilename = dialog.FileName;
                    image_cropper.original  = new Bitmap(dialog.FileName);

                    // 원본 이미지 해상도 읽는 부분
                    Originalview.Image = image_cropper.original;
                    opener.xy_size();
                    originalsize.Text = opener.res();

                    scr_able_box.Image  = image_cropper.original;
                    scr_able_box.Height = image_cropper.original.Height;
                    scr_able_box.Width  = image_cropper.original.Width;

                    scr_able_viewer.Controls.Clear();
                    scr_able_viewer.Controls.Add(scr_able_box);
                    scr_able_viewer.AutoScroll = true;
                }
            }
            catch (Exception)
            {
                opener.err_msg();
                return;
            }
            image_cropper.isimageadded = true;                            // 이미지 추가됨 플래그 지정
            Originalview.SizeMode      = PictureBoxSizeMode.StretchImage; // 미리보기 창에 이미지 크기 조절
        }
Ejemplo n.º 6
0
        public void asarraysize_TextChanged(object sender, EventArgs e)
        {
            //작두할 어레이 크기 설정
            image_cropper assize = new image_cropper();

            try
            {
                int size = Int32.Parse(asarraysize.Text);
                image_cropper.arraysize = size;
                if (size < 1)
                {
                    assize.err_under_zero();
                    asarraysize.Text = "1";
                }
            }
            catch (Exception)
            {
                // 숫자 아님 예외처리
                asarraysize.Text = "1";
            }
        }