Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. negative filter problem?

negative filter problem?

Scheduled Pinned Locked Moved C#
graphicscsharphelpregexquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maifs
    wrote on last edited by
    #1

    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

    W 1 Reply Last reply
    0
    • M maifs

      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

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • W Wendelius

        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

        M Offline
        M Offline
        maifs
        wrote on last edited by
        #3

        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

        W 1 Reply Last reply
        0
        • M maifs

          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

          W Offline
          W Offline
          Wendelius
          wrote on last edited by
          #4

          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 Editor

          So 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 expected System.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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups