Drawing and saving a plot

This is a discussion on Drawing and saving a plot within the C# Programming forums, part of the General Programming Boards category; My boss suggested I write a program/algorithm. He wants it to paint an image(similar to an Excel plot with labels) ...

  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    197

    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
    Location
    Hannover, Germany
    Posts
    3,139
    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
    hth
    -nv

    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
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21