zoukankan      html  css  js  c++  java
  • 图形技术(局部图片的复制)

    using System.Drawing;
    using System.Drawing.Imaging;

    namespace Ex04_03
    {
        public partial class Form1 : Form
        {
            string str;
            public Form1()
            {
                InitializeComponent();
            }

    //选择图片

            private void button1_Click(object sender, EventArgs e)
            {
                openFileDialog1.Filter = "*.jpg,*.jpeg,*.bmp,*.gif,*.ico,*.png,*.tif,*.wmf|*.jpg;*.jpeg;*.bmp;*.gif;*.ico;*.png;*.tif;*.wmf";
                openFileDialog1.ShowDialog();
                str = openFileDialog1.FileName;
                Image myImage = System.Drawing.Image.FromFile(str);
                pictureBox1.Image = myImage;
                button2.Enabled = true;
            }

    //执行图片复制操作

            private void button2_Click(object sender, EventArgs e)
            {
                if (textBox1.Text == string.Empty || textBox2.Text == string.Empty || textBox3.Text == string.Empty || textBox4.Text == string.Empty)
                {
                    MessageBox.Show("请将要拷贝区域的资料填写完整!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBox1.Focus();
                }
                else
                {
                    Graphics graphics = this.CreateGraphics();
                    Bitmap bitmap = new Bitmap(str);
                    Rectangle rectangle = new Rectangle(Convert.ToInt32(textBox1.Text.Trim()), Convert.ToInt32(textBox2.Text.Trim()),
                        Convert.ToInt32(textBox3.Text.Trim()), Convert.ToInt32(textBox4.Text.Trim()));
                    Bitmap cloneBitmap = bitmap.Clone(rectangle, PixelFormat.DontCare);
                    pictureBox2.Image = cloneBitmap;
                }
            }
        }
    }

  • 相关阅读:
    剑指offer[19]——顺时针打印矩阵
    剑指offer[17]——树的子结构
    剑指offer[16]——合并两个排序的链表
    剑指offer[15]——反转链表
    剑指offer[14]——链表中倒数第k个结点
    剑指offer[13]——调整数组顺序使奇数位于偶数前面
    剑指offer[12]——数值的整数次方
    剑指offer[11]——二进制中1的个数
    剑指offer[10]——矩形覆盖
    linux的基本命令
  • 原文地址:https://www.cnblogs.com/msAspnet/p/2097192.html
Copyright © 2011-2022 走看看