Qui:
La tua sub diventa una funzione che ritorna un'oggetto graphics.
[code]
public Graphics ImgConvertNegativeMatrix(System.Drawing.Bitmap bitmap)
{
System.Drawing.Rectangle bounds = new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height);
float[][] values = { new float[] { -1, 0, 0, 0, 0 }, new float[] { 0, -1, 0, 0, 0 }, new float[] { 0, 0, -1, 0, 0 }, new float[] { 0, 0, 0, 1, 0 }, new float[] { 0, 0, 0, 0, 1 } };
System.Drawing.Imaging.ColorMatrix matrix = new System.Drawing.Imaging.ColorMatrix(values);
System.Drawing.Imaging.ImageAttributes attributes = new System.Drawing.Imaging.ImageAttributes();
attributes.SetColorMatrix(matrix);
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
graphics.DrawImage(bitmap, bounds, 0, 0, bitmap.Width, bitmap.Height, System.Drawing.GraphicsUnit.Pixel, attributes);
return graphics;
graphics.Dispose();
}
[code]
Po la applichi:
codice:private void button1_Click(object sender, EventArgs e) { Graphics g = ImgConvertNegativeMatrix(PictureBox1.Image); Graphics g2 = PictureBox2.CreateGraphics; g2.DrawImage(PictureBox1.Image, 0, 0); } :ciauz:

Rispondi quotando