Ti ringrazio della risposta.
Purtroppo non ho risolto il problema.
Sia il tuo codice sia il mio funziona perfettamente con windows Xp, ma non con windows 7 (con vista non ho provato)
Questo il codice di prova
codice:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Drawing;
using System.Drawing.Text;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace a
{
class Program
{
static void Main(string[] args)
{
using(Bitmap bmp = new Bitmap(@"c:\tmp\prova.jpg"))
{
Graphics g = ImgConvertNegativeMatrix(bmp);
Graphics g2 = Graphics.FromImage(bmp);
g2.DrawImage(bmp, 0, 0);
bmp.Save(@"c:\tmp\prova1.jpg");
}
}
static 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();
}
}
}