Results 1 to 4 of 4

Thread: Save drawing from PictureBox

Threaded View

  1. #1

    Thread Starter
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Resolved Save drawing from PictureBox

    Hey there,

    I'm trying to save the lines I drew in a PictureBox as a bitmap, but it just returns blank images...

    This is the code I have now:
    vb Code:
    1. 'Draw a grid on PictureBox named draw
    2. For x As Integer = 0 To bWidth
    3.     For y As Integer = 0 To bHeight
    4.         draw.CreateGraphics.DrawLine(Pens.Black, New Point(xStart + x * bScale, yStart), New Point(xStart + x * bScale, yStart + ySize))
    5.         draw.CreateGraphics.DrawLine(Pens.Black, New Point(xStart, yStart + y * bScale), New Point(xStart + xSize, yStart + y * bScale))
    6.     Next
    7. Next
    8.  
    9. 'Save as BMP-file
    10. Dim bmp As New Bitmap(draw.Width, draw.Height)
    11. draw.DrawToBitmap(bmp, New Rectangle(0, 0, draw.Width, draw.Height))
    12. bmp.Save("D:\output.png", Imaging.ImageFormat.Png)
    13. bmp.Dispose()
    The file output.png in now a blank image, the size of the PictureBox. If I try to save the entire form with Me.DrawToBitmap(), I get the form itself but the PictureBox is blank, while the grid is visible on screen.

    WHAT DO?!

    Thanks for your help,
    Alexander.
    Last edited by arsmakman; Jun 4th, 2011 at 03:50 AM. Reason: Issue resolved
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width