图片的放大和缩小

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了图片的放大和缩小相关的知识,希望对你有一定的参考价值。

点击放大,图片变大,点击缩小,图片缩小

技术分享

 

代码

技术分享
 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel;
 4 using System.Data;
 5 using System.Drawing;
 6 using System.Text;
 7 using System.Linq;
 8 using System.Threading.Tasks;
 9 using System.Windows.Forms;
10 using DevExpress.XtraEditors;
11 using Com.HuaQin.DBHelper;
12 using System.Drawing;
13 using System.Drawing.Imaging;
14 using System.Reflection;
15 
16 namespace Com.HuaQin.WKStationPlugin
17 {
18     public partial class xFrmQueryChild : DevExpress.XtraEditors.XtraForm
19     {
20         private Image myBitmap;
21         Point op, np;
22         Picture pic;
23         myPoint mousePoint = new myPoint();
24         Boolean flag = true;
25         Boolean mouseDown;
26         Shift sft = new Shift();
27         int scale =1;
28         public xFrmQueryChild(Image bit)
29         {
30             InitializeComponent();
31             pictureEdit1.Image = bit;
32             //pictureBox1.Image = bit;
33             
34             //this.pictureBox1.Image = myBitmap;
35             //pic = new Picture(bit, pictureBox1);
36             //pictureEdit1.ContextMenu = GetMenu(pictureEdit1);
37         }
38 
39         private void toolStripButton2_Click(object sender, EventArgs e)
40         {
41             //InvokeMenuMethod(GetMenu(pictureEdit1) ,"zoomTo");
42             //
43         }
44 
45         private DevExpress.XtraEditors.Controls.PictureMenu GetMenu(DevExpress.XtraEditors.PictureEdit edit)
46         {
47             PropertyInfo pi = typeof(DevExpress.XtraEditors.PictureEdit).GetProperty("Menu", BindingFlags.NonPublic | BindingFlags.Instance);
48             if (pi != null)
49                 return pi.GetValue(edit, null) as DevExpress.XtraEditors.Controls.PictureMenu;
50             return null;
51         }
52         private void InvokeMenuMethod(DevExpress.XtraEditors.Controls.PictureMenu menu, string name)
53         {
54             MethodInfo mi = typeof(DevExpress.XtraEditors.Controls.PictureMenu).GetMethod(name, BindingFlags.NonPublic | BindingFlags.Instance);
55             if (mi != null && menu != null)
56                 mi.Invoke(menu, new object[] { menu, new EventArgs() });
57         }
58 
59         private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
60         {
61             var menu = GetMenu(pictureEdit1);
62             InvokeMenuMethod(menu, "OnZoomIn");
63             //"OnZoomOut"
64         }
65 
66         private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
67         {
68             var menu = GetMenu(pictureEdit1);
69             InvokeMenuMethod(menu, "OnZoomOut");
70         }
71        
72     }
73 }
View Code

 

以上是关于图片的放大和缩小的主要内容,如果未能解决你的问题,请参考以下文章

图片的放大和缩小

求一个简单的点击图片放大缩小的JS代码

JS控制图片放大和缩小怎么改

javascript高手请进!关于就js控制网页图片放大缩小的问题

vb 如何放大或缩小图片,用Picture控件

在网页里点开放大了一张图片后,怎么实现随鼠标滚轮放大缩小?