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

其他工作总结 时间:2020-02-28 11:54:27 收藏本文下载本文
【www.daodoc.com - 其他工作总结】

C#图片处理总结——叠加、缩放、鼠标拖动[材料]由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“c”。

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#图片处理总结——叠加、缩放、鼠标拖动[材料]word格式文档
下载C#图片处理总结——叠加、缩放、鼠标拖动[材料].doc
将本文档下载到自己电脑,方便修改和收藏。
点此处下载文档

文档为doc格式

相关专题 c 鼠标 缩放 拖动
    热门文章
      整站推荐
        点击下载本文