Example #1
0
        public PictureSetting(string guid, Bitmap bitmap, ICutPicture iCutPicture, string filePath)
        {
            InitializeComponent();
            this.bitmap      = bitmap;
            this._filePath   = filePath;
            panelBack.Width  = bitmap.Width;
            panelBack.Height = bitmap.Height;

            picBitmap.Image = bitmap;
            picBitmap.Size  = new Size(bitmap.Width, bitmap.Height);
            picBitmap.Left  = 0;
            picBitmap.Top   = 0;
            //设置选中区域的最大和最小
            picWidth.Maximum  = bitmap.Width;
            picHeight.Maximum = bitmap.Height > 100 ? 100 : bitmap.Height;
            picWidth.Value    = 32;
            picHeight.Value   = 32;
            //设置控件可移动
            SetItemEvent(btnSize);
            SetBtn();
            btnSize.Left      = 0;
            btnSize.Top       = 0;
            btnSize.Width     = 32;
            btnSize.Height    = 32;
            this._iCutPicture = iCutPicture;
            this._guid        = guid;

            var newBitmap = ImageTool.GetCutPic(bitmap, btnSize.Left, btnSize.Top, btnSize.Width, btnSize.Height);

            _iCutPicture?.GetCutPicture(guid, new PictureSettingParameter()
            {
                Bitmap = newBitmap, UserControl = this
            });
        }
Example #2
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);
     }
 }
Example #3
0
 private void btnSize_MouseMove(object sender, MouseEventArgs e)
 {
     if (_mouseDown)
     {
         var newBitmap = ImageTool.GetCutPic(bitmap, btnSize.Left, btnSize.Top, btnSize.Width, btnSize.Height);
         _iCutPicture?.GetCutPicture(_guid, new PictureSettingParameter()
         {
             Bitmap = newBitmap, UserControl = this
         });
     }
 }
Example #4
0
        /// <summary>
        /// 生成二维码的图片
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        private Bitmap GetQrcodeBitmap(QrcodeSettingParameter para)
        {
            QrCodeEncodingOptions option = new QrCodeEncodingOptions()
            {
                CharacterSet = para.QrcodeType,
                Width        = para.PicSize,
                Height       = para.PicSize
            };
            BarcodeWriter bw = new BarcodeWriter()
            {
                Options = option, Format = BarcodeFormat.QR_CODE
            };

            return(ImageTool.ConvertBitmapTo8(bw.Write(para.Content)));
        }
Example #5
0
        /// <summary>
        /// 生成条形码
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        private Bitmap GetBarcodeBitmap(BarcodeSettingParameter para)
        {
            QrCodeEncodingOptions option = new QrCodeEncodingOptions()
            {
                CharacterSet = "utf8bom",
                Width        = 50,
                Height       = para.PicSize
            };
            BarcodeWriter bw = new BarcodeWriter()
            {
                Options = option, Format = BarcodeFormat.CODABAR
            };

            return(ImageTool.ConvertBitmapTo8(bw.Write(para.Content)));
        }
Example #6
0
 private void picHeight_ValueChanged(object sender, EventArgs e)
 {
     try
     {
         btnSize.Height = (int)picHeight.Value;
         var newBitmap = ImageTool.GetCutPic(bitmap, btnSize.Left, btnSize.Top, btnSize.Width, btnSize.Height);
         _iCutPicture?.GetCutPicture(_guid,
                                     new PictureSettingParameter()
         {
             Bitmap = newBitmap, UserControl = this
         });
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Example #7
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);
     }
 }