コード例 #1
0
 private void numberScale_ValueChanged(object sender, EventArgs e)
 {
     try
     {
         var value = numberScale.Value;
         var scale = value / 100m;
         //获取新的图片
         var newBitmap = ImageTool.GetGrayPic(this._filePath, scale);
         //删除原来的图片
         if (null != this.bitmap)
         {
             bitmap.Dispose();
         }
         //
         picBitmap.Image  = newBitmap;
         picBitmap.Width  = newBitmap.Width;
         picBitmap.Height = newBitmap.Height;
         panelBack.Height = picBitmap.Height;
         panelBack.Width  = picBitmap.Width;
         this.bitmap      = newBitmap;
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #2
0
 private void btnPicture_Click(object sender, EventArgs e)
 {
     try
     {
         var dialog = new OpenFileDialog();
         dialog.Filter = "(*.jpg;*.bmp;*.jpeg)|*.jpg;*.bmp;*.jpeg";
         var flag = dialog.ShowDialog();
         if (flag == DialogResult.OK)
         {
             var filePath = dialog.FileName;
             Console.WriteLine(filePath);
             //加载图片设置的类
             this.panelSetting.Controls.Clear();
             var pictureSetting = new PictureSetting(Guid.NewGuid().ToString("N"), ImageTool.GetGrayPic(filePath, 1), this, filePath);
             pictureSetting.Dock = DockStyle.Fill;
             this.panelSetting.Controls.Add(pictureSetting);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }