LuckyStrike
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Люди, плиз..помогите...вот написал код для изменении картинки цветов RGB, которая находиться в pictureBox...но как-то не аккуратно работает((( просмотрите плиз вот: 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; using System.Drawing.Imaging; using System.Drawing.Drawing2D; namespace PhotoLom { public partial class Form3 : Form { protected Image image; public Form3() { InitializeComponent(); } private void Form3_Load(object sender, EventArgs e) { } private void button3_Click(object sender, EventArgs e)изменение зелёного { ImageAttributes ia = new ImageAttributes(); float[][] matrix = { new float[] { (float)vScrollBar2.Value/255.0f, 0, 0, 0, 0 }, new float[] {0, 0, 0, 0, 0}, new float[] {0, 1, 0, 0, 0}, new float[] {0, 0, 0, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {0, 0, 0, 0, 1} }; ColorMatrix cm = new ColorMatrix(matrix); ia.SetColorMatrix(cm); Bitmap bmp = new Bitmap(pictureBox1.Image); Graphics g = Graphics.FromImage(bmp); g.DrawImage(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, ia); pictureBox1.Image = (Image)bmp; } private void button4_Click(object sender, EventArgs e)//изменение синего { ImageAttributes ia = new ImageAttributes(); float[][] matrix = { new float[] { (float)vScrollBar3.Value/255.0f, 0, 0, 0, 0 }, new float[] {0, 0, 0, 0, 0}, new float[] {0, 0, 0, 0, 0}, new float[] {0, 0, 1, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {0, 0, 0, 0, 1} }; ColorMatrix cm = new ColorMatrix(matrix); ia.SetColorMatrix(cm); Bitmap bmp = new Bitmap(pictureBox1.Image); Graphics g = Graphics.FromImage(bmp); g.DrawImage(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, ia); pictureBox1.Image = (Image)bmp; } private void button2_Click_1(object sender, EventArgs e) //изменение красного { ImageAttributes ia = new ImageAttributes(); float[][] matrix = { new float[] { (float)vScrollBar1.Value/255.0f, 0, 0, 0, 0 }, new float[] {1, 0, 0, 0, 0}, new float[] {0, 1, 0, 0, 0}, new float[] {1, 0, 0, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {1, 0, 0, 0, 1} }; ColorMatrix cm = new ColorMatrix(matrix); ia.SetColorMatrix(cm); Bitmap bmp = new Bitmap(pictureBox1.Image); Graphics g = Graphics.FromImage(bmp); g.DrawImage(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, ia); pictureBox1.Image = (Image)bmp; } } } } |