当前位置:   article > 正文

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

c#图片无损放大

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/962201
推荐阅读
相关标签
  

闽ICP备14008679号