人人范文网 范文大全

C#图片处理总结——叠加、缩放、鼠标拖动[材料]

发布时间:2020-03-03 06:36:48 来源:范文大全 收藏本文 下载本文 手机版

C#图片处理总结——叠加、缩放、鼠标拖动

2011-05-03 12:37 1265人阅读 评论(2) 收藏 举报

c#floatimageobjectstringnull

/////////////用到的命名空间////////////

using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging;

/////两张图片叠加,float fImage(0—1)透明度///////////////

private void getMixImage(float fImage, string strFrontImage, string strBackImage) { this.m_image.Dispose(); Bitmap background = new Bitmap(strBackImage); Bitmap frontImage = new Bitmap(strFrontImage); int iwidth = background.Width > frontImage.Width ? background.Width : frontImage.Width; int iheight = background.Height > frontImage.Height ? background.Height : frontImage.Height; Bitmap mixImage2 = new Bitmap(iwidth, iheight); //this.mixImage.Width = iwidth; //this.mixImage.Height = iheight; Graphics g = Graphics.FromImage(mixImage2); float[][] colormatrix ={ new float[]{1,0,0,0,0},//代表了R new float[]{0,1,0,0,0},//代表了G new float[]{0,0,1,0,0},//代表了B new float[]{0,0,0,fImage,0},//代表了A new float[]{0,0,0,0,1} }; ColorMatrix cm = new ColorMatrix(colormatrix); ImageAttributes imageAtt = new ImageAttributes(); imageAtt.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); g.DrawImage(background, new Point(0, 0)); g.DrawImage(frontImage, new Rectangle(0, 0, frontImage.Width, frontImage.Height), 0, 0, frontImage.Width, frontImage.Height, GraphicsUnit.Pixel, imageAtt); this.pictureBox1.Image = mixImage2; this.pictureBox1.Update(); this.m_ChangeSize = mixImage2; }

//////////////图片的缩放/////////////

public Form1() { InitializeComponent(); /////////////写在初始化时,提高运算速度////////////

base.SetStyle(ControlStyles.OptimizedDoubleBuffer |ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); base.SetStyle(ControlStyles.ResizeRedraw | ControlStyles.Selectable, true); } /////////////放大////////////

private void buttonPicSizeEnlarge_Click(object sender, EventArgs e) { this.nPicSize++; if (this.nPicSize 6) { MeageBox.Show(\"无法再增强\"); this.nPicSize = 6; } else {

this.picSizeColor(); if (this.nReset == 0) m_image = m_Reset; if (this.pictureBox1.Image.Width > this.splitContainer1.Panel1.Width && this.pictureBox1.Image.Height > this.splitContainer1.Panel1.Height && pictureBox1.Image.Height >= m_image.Height * 4) { MeageBox.Show(\"已是最大\"); } else { this.nReset = this.nReset + 1; Rectangle oldrct; Bitmap bmp = (Bitmap)this.pictureBox1.Image; oldrct = new Rectangle(0, 0, bmp.Width, bmp.Height); this.pictureBox1.Image = bmp; Bitmap tmpbmp = null; tmpbmp = new Bitmap(bmp.Width * 2, bmp.Height * 2); if (bmp.Width

/////////////缩小////////////

private void buttonPicSizeNarrow_Click(object sender, EventArgs e) { this.nPicSize--; if (this.nPicSize 6) { MeageBox.Show(\"无法再增大\"); this.nPicSize = 6; } else { this.picSizeColor(); if (this.nReset == 0) m_image = m_Reset; if (pictureBox1.Image.Width

M_int_mx = Math.Min(0, Math.Max(M_int_maxX, M_int_mx)); M_int_my = Math.Min(0, Math.Max(M_int_maxY, M_int_my)); Graphics g = pictureBox1.CreateGraphics(); g.DrawImage(tmpbmp, new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height), new Rectangle(-M_int_mx, -M_int_my, pictureBox1.Width, pictureBox1.Height), GraphicsUnit.Pixel); M_pot_p = e.Location; } else { Cursor = Cursors.Default; } }

试着拖动你们的鼠标

小学信息技术鼠标拖动操作 教学设计

C#总结

数字图像处理图像翻转,平移,缩放

数字图像处理图像翻转,平移,缩放

图片处理教学计划

电力拖动总结

c#基础总结

C#实习总结

C#个人总结

C#图片处理总结——叠加、缩放、鼠标拖动[材料]
《C#图片处理总结——叠加、缩放、鼠标拖动[材料].doc》
将本文的Word文档下载到电脑,方便编辑。
推荐度:
点击下载文档
相关专题 c 鼠标
点击下载本文文档