Thread: Drawing and saving a plot

  1. #1
    Registered User
    Join Date
    Aug 2005

    Question Drawing and saving a plot

    My boss suggested I write a program/algorithm. He wants it to paint an image(similar to an Excel plot with labels) and then write that image to disk. I know C# can paint images on the screen and I would be very surprised if it did not write JEPGs to disk and do basic image conversions. Can C# paint an image to the screen, and then write that image to disk? I'm not sure how to go about this. It seems to be rather graphics intensive, at least for a relatively small algorithm. Is there a good way to do text rendering in an image? My boss would want a user-friendly stand-alone program, so I can't use GNU plot or Matlab. Is there an language alternative better than C#?

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    You can do this in C# rather easily. You need a Bitmap object. From this Bitmap object you can get a graphics object that will let you do various operations on it like drawing lines, polygons, graphs, text, whatever you would normally do with graphics.
    You can display the Bitmap on a form in a single line of code. Maybe 5 if you want it to look nice. You can also save it to a file in a single line, again maybe 5-10 to let the user select where he wants it saved.

    Is there an alternative? Probably yes. But it won't be much easier I think.

    Look up the Image, Bitmap and Graphics classes in the System.Drawing namespace

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3

Popular pages Recent additions subscribe to a feed