• 大小: 61KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-23
  • 语言: C#
  • 标签: C#  

资源简介

用C#打开TIF文件,实现图片的缩放、移动等基本操作

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;


namespace PicKeyin2
{
    public partial class frmMain : Form
    {
        string PicWorkPath = string.Empty;//图片所在文件夹 工作区
        Bitmap SourcePic;
        private Point mouseDownPoint = new Point();
        private bool isSelected = false;
        double curZoomRate = 1;//当前放缩比率

        public frmMain()
        {
            InitializeComponent();

             Screen[] screens = Screen.AllScreens;// 显示设备的集合
             Screen screen = screens[0];// 获取第一个显示设备

             this.Left = 0;
             this.Top = 0;
             this.Height = screen.WorkingArea.Height;//获取桌面的工作区   高度
             this.Width = screen.WorkingArea.Width;//获取桌面的工作区 宽度   

             IniComponent();

             this.pictureBox1.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseWheel);

        }

        private void pictureBox1_MouseWheel(object sender System.Windows.Forms.MouseEventArgs e)
        {
            if (SourcePic == null) return;
            int numberOfTextLinesToMove = e.Delta * SystemInformation.MouseWheelScrollLines / 120;

            if (numberOfTextLinesToMove > 0)
            {
                //for (int i = 0; i < numberOfTextLinesToMove; i++)
                //{
                //    max();
                //}
                max();
            }
            else if (numberOfTextLinesToMove < 0)
            {
                //for (int i = 0; i > numberOfTextLinesToMove; i--)
                //{
                //    min();
                //}
                min();
            }
        }

        private void IniComponent()
        {
            lbFolder.Text = ““;
            cbFiles.Items.Clear();
            ButtonEnableedFalse(false);

            DataTable dt = new DataTable();
            dt.Columns.Add(“Name“);
            dt.Columns.Add(“Value“);
            int i=10;
            while (i <= 300)
            {
                dt.Rows.Add(new string[] { Convert.ToString(i) + “%“ Convert.ToString(i) });
                i = i + 5;
            }

            this.cbZoom.DataSource = dt;
            this.cbZoom.DisplayMember = “Name“;
            this.cbZoom.ValueMember = “Value“;
        }
        private void ButtonEnableedFalse(bool bl)
        {
            btNext.Enabled = bl;
            btPrior.Enabled = bl;

            btZoom75.Enabled = bl;
            btZoom100.Enabled = bl;
            btZoom125.Enabled = bl;
            btZoom150.Enabled = bl;
            btZoom200.Enabled = bl;
        }        

        private void btFolder_Click(object sender EventArgs e)
        {
            List files = new List();

            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2011-08-30 11:43  PicKeyin2\
     目录           0  2011-08-30 11:44  PicKeyin2\PicKeyin2\
     文件         869  2011-08-30 11:43  PicKeyin2\PicKeyin2.sln
     文件       19968  2011-08-30 16:39  PicKeyin2\PicKeyin2.suo
     目录           0  2011-08-30 11:44  PicKeyin2\PicKeyin2\bin\
     目录           0  2011-08-30 11:52  PicKeyin2\PicKeyin2\bin\Debug\
     文件       19456  2011-08-30 16:25  PicKeyin2\PicKeyin2\bin\Debug\PicKeyin2.exe
     文件       36352  2011-08-30 16:25  PicKeyin2\PicKeyin2\bin\Debug\PicKeyin2.pdb
     文件       11600  2011-08-30 16:39  PicKeyin2\PicKeyin2\bin\Debug\PicKeyin2.vshost.exe
     目录           0  2011-08-30 11:44  PicKeyin2\PicKeyin2\bin\Release\
     文件       12552  2011-08-30 16:25  PicKeyin2\PicKeyin2\frmMain.cs
     文件       15584  2011-08-30 16:13  PicKeyin2\PicKeyin2\frmMain.Designer.cs
     文件        6229  2011-08-30 16:13  PicKeyin2\PicKeyin2\frmMain.resx
     目录           0  2011-08-30 11:43  PicKeyin2\PicKeyin2\obj\
     目录           0  2011-08-30 11:43  PicKeyin2\PicKeyin2\obj\x86\
     目录           0  2011-08-30 16:25  PicKeyin2\PicKeyin2\obj\x86\Debug\
     文件        6223  2011-08-30 16:25  PicKeyin2\PicKeyin2\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件         256  2011-08-30 16:13  PicKeyin2\PicKeyin2\obj\x86\Debug\GenerateResource.read.1.tlog
     文件         618  2011-08-30 16:13  PicKeyin2\PicKeyin2\obj\x86\Debug\GenerateResource.write.1.tlog
     文件         720  2011-08-30 16:39  PicKeyin2\PicKeyin2\obj\x86\Debug\PicKeyin2.csproj.FileListAbsolute.txt
     文件       19456  2011-08-30 16:25  PicKeyin2\PicKeyin2\obj\x86\Debug\PicKeyin2.exe
     文件         180  2011-08-30 16:13  PicKeyin2\PicKeyin2\obj\x86\Debug\PicKeyin2.frmMain.resources
     文件       36352  2011-08-30 16:25  PicKeyin2\PicKeyin2\obj\x86\Debug\PicKeyin2.pdb
     文件         180  2011-08-30 11:52  PicKeyin2\PicKeyin2\obj\x86\Debug\PicKeyin2.Properties.Resources.resources
     目录           0  2011-08-30 11:43  PicKeyin2\PicKeyin2\obj\x86\Debug\TempPE\
     文件        3687  2011-08-30 11:44  PicKeyin2\PicKeyin2\PicKeyin2.csproj
     文件         492  2011-08-30 11:44  PicKeyin2\PicKeyin2\Program.cs
     目录           0  2011-08-30 11:43  PicKeyin2\PicKeyin2\Properties\
     文件        1350  2011-08-30 11:43  PicKeyin2\PicKeyin2\Properties\AssemblyInfo.cs
     文件        2868  2011-08-30 11:43  PicKeyin2\PicKeyin2\Properties\Resources.Designer.cs
     文件        5612  2011-08-30 11:43  PicKeyin2\PicKeyin2\Properties\Resources.resx
............此处省略2个文件信息

评论

共有 条评论