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. Graphic problem?

Graphic problem?

Scheduled Pinned Locked Moved C#
questioncsharpwinformsgraphicshelp
2 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.
  • A Offline
    A Offline
    Alan Zhao
    wrote on last edited by
    #1

    Hello everyone, how do I save and print a graphic created by GDI+, using C#? I just want to save and print the graphic not including the form where graphic was drawn. Thank!!!:)

    K 1 Reply Last reply
    0
    • A Alan Zhao

      Hello everyone, how do I save and print a graphic created by GDI+, using C#? I just want to save and print the graphic not including the form where graphic was drawn. Thank!!!:)

      K Offline
      K Offline
      kayhustle
      wrote on last edited by
      #2

      This is how you save something. Lets just say the class UI is the user control that you want to save. Printing is a bit more complicated. I gotta go now, but if I come back and nobody has answered I will show you. //Lets say this is the user control you want to save or print public class UI:System.Windows.Forms.UserControl { public void UI_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { //code to paint to e.Graphics } public event PaintEventHandler paint = new PaintEventHandler(UI_Paint); public void Save() { //Pretty straightforward, get a new bitmap equal to the same size Bitmap b = new Bitmap(this.Width,this.Height,this.CreateGraphics()); PaintEventArgs pe = new PaintEventArgs(Graphics.FromImage(b),this.ClientRectangle); //raise the paint event but paint to the bitmap paint(this,pe); b.Save("filename",System.Drawing.Imaging.ImageFormat.Jpeg); } } } You can save it to any format you want, there are quite a few you can pull from ImageFormat.

      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