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. Visual Basic
  4. Save drawing to an image in VB.NET

Save drawing to an image in VB.NET

Scheduled Pinned Locked Moved Visual Basic
helpcsharpgraphicstutorial
3 Posts 3 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.
  • H Offline
    H Offline
    hsprasain
    wrote on last edited by
    #1

    Hey, I've drawn a drawing in form. For example I have drawn line or circle or ... My problem is I want to save this drawing as image file. Can anybody give me an idea how I can do this? I appreciate your help. hsprasain

    C G 2 Replies Last reply
    0
    • H hsprasain

      Hey, I've drawn a drawing in form. For example I have drawn line or circle or ... My problem is I want to save this drawing as image file. Can anybody give me an idea how I can do this? I appreciate your help. hsprasain

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Draw it onto an Image or Bitmap, then call it's Save method. If you're already drawing in the Paint event, then just create a member Bitmap, draw onto that, and draw that in your Paint event.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • H hsprasain

        Hey, I've drawn a drawing in form. For example I have drawn line or circle or ... My problem is I want to save this drawing as image file. Can anybody give me an idea how I can do this? I appreciate your help. hsprasain

        G Offline
        G Offline
        GuyThiebaut
        wrote on last edited by
        #3

        In my code I creat a piechart. What I have done is stripped down the code to show you what goes where (This code will not work as it needs declarations and values...). This code will in effect make the picture 'stick' to the form - so that it does not get erased as you move the form. Panel1 is where the piechart is being drawn. Width and Height are variables you need to set to the size of the picture you want. You will also need to include the Panel1.CreateGraphics.DrawImage(b1, 0, 0) command in the Paint event of the objetct you are drawing onto - in fact this is where the magic of this method is... Give this a go and good luck... Regards Guy Cambridge UKPublic b1 As Bitmap Public g1 As Graphics b1 = New Bitmap(Width, Height, Panel1.CreateGraphics()) g1 = Graphics.FromImage(b1) g1.DrawPie(Pen:=myPen, rect:=New Rectangle _ (x:=x + XAdjust, y:=y + yAdjust, Width:=Width, Height:=Height), _ startAngle:=startPos, sweepAngle:=sweep)

        Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint Panel1.CreateGraphics.DrawImage(b1, 0, 0) End Sub

        You always pass failure on the way to success.

        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