C#(winform)实现图片的无损放大缩小【点击鼠标滚动键放大缩小】

usingSystem;//来源于www.uzhanbao.comusingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Drawing;usingSystem.D...
摘要由CSDN通过智能技术生成

using System;//来源于www.uzhanbao.com
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;

namespace ImageLoader
{
    public partial class Form1 : Form
    {

        private Rectangle selectedArea;
        private Image loadedImage;
        private Color selectionColor;
        private int count = 10;

        public Form1()
        {
            InitializeComponent();
            this.MouseWheel +=new MouseEventHandler(picBox1_MouseWheel);
            picBox1.SizeMode = PictureBoxSizeMode.Zoom;
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if (loadedImage != null)
                {
                    loadedImage.Dispose();
                }
                try
                {

                    loadedImage = Image.FromFile(openFileDialog1.FileName);

                    //Get a contrasting color for the image selection marker
                    using (Bitmap bmp = new Bitmap(loadedImage))
                    {
                        selectionColor = GetDominantColor(bmp, false);
                        selectionColor = CalculateOppositeColor(selectionColor);
                    }

                    ///tZoom.Value = 1;

                    //resizePictureArea();



                    //Map the area selected in the thumbail to the actual image size
                    Rectangle zoomArea = new Rectangle();
                    Rectangle l

  • 2
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值