negative filter problem?
-
i want to create a negative filter of any image.. i am trying this... public void Negative() { Bitmap copy=new Bitmap(m.Width,m.Height); ImageAttributes ia = new ImageAttributes(); ColorMatrix cm = new ColorMatrix(); cm.Matrix00 = cm.Matrix11 = cm.Matrix22 = 0.99f; cm.Matrix33 = cm.Matrix44 = 1; cm.Matrix40 = cm.Matrix41 = cm.Matrix42 = .04f; ia.SetColorMatrix(cm); Graphics g=Graphics.FromImage(copy); g.DrawImage(m,new Rectangle(0, 0,m.Width, m.Height), 0, 0, m.Width, m.Height, GraphicsUnit.Pixel, ia); g.Dispose(); m.Dispose(); } but here is some error occur in this....... error is: Error 2 Argument '2': cannot convert from 'I_M_Editor.Rectangle' to 'System.Drawing.Rectangle' D:\dot.net.programs.using.c#\0eh066\I'M Editor\I'M Editor\frmEditable.cs 688 15 I'M Editor and Error 1 The best overloaded method match for 'System.Drawing.Graphics.DrawImage(System.Drawing.Image, System.Drawing.Rectangle, float, float, float, float, System.Drawing.GraphicsUnit, System.Drawing.Imaging.ImageAttributes)' has some invalid arguments D:\dot.net.programs.using.c#\0eh066\I'M Editor\I'M Editor\frmEditable.cs 688 1 I'M Editor }
hghghgh
-
i want to create a negative filter of any image.. i am trying this... public void Negative() { Bitmap copy=new Bitmap(m.Width,m.Height); ImageAttributes ia = new ImageAttributes(); ColorMatrix cm = new ColorMatrix(); cm.Matrix00 = cm.Matrix11 = cm.Matrix22 = 0.99f; cm.Matrix33 = cm.Matrix44 = 1; cm.Matrix40 = cm.Matrix41 = cm.Matrix42 = .04f; ia.SetColorMatrix(cm); Graphics g=Graphics.FromImage(copy); g.DrawImage(m,new Rectangle(0, 0,m.Width, m.Height), 0, 0, m.Width, m.Height, GraphicsUnit.Pixel, ia); g.Dispose(); m.Dispose(); } but here is some error occur in this....... error is: Error 2 Argument '2': cannot convert from 'I_M_Editor.Rectangle' to 'System.Drawing.Rectangle' D:\dot.net.programs.using.c#\0eh066\I'M Editor\I'M Editor\frmEditable.cs 688 15 I'M Editor and Error 1 The best overloaded method match for 'System.Drawing.Graphics.DrawImage(System.Drawing.Image, System.Drawing.Rectangle, float, float, float, float, System.Drawing.GraphicsUnit, System.Drawing.Imaging.ImageAttributes)' has some invalid arguments D:\dot.net.programs.using.c#\0eh066\I'M Editor\I'M Editor\frmEditable.cs 688 1 I'M Editor }
hghghgh
You may have a problem with namespace and refer to wrong Rectangle. Try adding the namespace like:
maifs wrote:
g.DrawImage(m,new Rectangle(0, 0,m.Width, m.Height), 0, 0, m.Width, m.Height, GraphicsUnit.Pixel, ia);
g.DrawImage(m,new **System.Drawing.**Rectangle(0, 0,m.Width, m.Height), 0, 0, m.Width, m.Height, GraphicsUnit.Pixel, ia);
The need to optimize rises from a bad design
-
You may have a problem with namespace and refer to wrong Rectangle. Try adding the namespace like:
maifs wrote:
g.DrawImage(m,new Rectangle(0, 0,m.Width, m.Height), 0, 0, m.Width, m.Height, GraphicsUnit.Pixel, ia);
g.DrawImage(m,new **System.Drawing.**Rectangle(0, 0,m.Width, m.Height), 0, 0, m.Width, m.Height, GraphicsUnit.Pixel, ia);
The need to optimize rises from a bad design
-
it doesnt effect on picture dear... i think ,it happens for reason of picturebox. actually picture is in picturebox.. if soo then what should i do?
hghghgh
I really don't understand your question. You have the following line in the code:
g.DrawImage(m,new Rectangle(0, 0,m.Width, m.Height), 0, 0, m.Width, m.Height, GraphicsUnit.Pixel, ia);
and the compiler reports an error:
Error 2 Argument '2':
cannot convert from 'I_M_Editor.Rectangle' to 'System.Drawing.Rectangle'
D:\dot.net.programs.using.c#\0eh066\I'M Editor\I'M Editor\frmEditable.cs 688 15 I'M EditorSo what I believe is that you have defined a class named
Rectangle
in your namespace (I_M_Editor
) and the compiler tries to use it instead of the expectedSystem.Drawing.Rectangle
class. That's why I suggested adding the namespace information to the call to new Rectangle class.The need to optimize rises from a bad design