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. Graphics
  4. Saving a picturebox control to jpg with VB 2005

Saving a picturebox control to jpg with VB 2005

Scheduled Pinned Locked Moved Graphics
graphicswinformshelpquestion
1 Posts 1 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.
  • R Offline
    R Offline
    RobKon
    wrote on last edited by
    #1

    Hi all, I have written a program that draws graphics to a picturebox control with GDI+ graphics. I want to be able to save the graphics as a jpg file. What I have done is create a temporary bitmap object and using the pictureboxs DrawToBitmap method copying the picturebox to the bitmap. Then I have used the bitmap objects Save method to write the jpg file. When I view the the jpg all I see is black with none of the graphics that are on the picturebox control.

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
    Dim bmpMap As New Bitmap(924, 722)
    Dim Rect As Rectangle = imgMap.DisplayRectangle
    imgMap.DrawToBitmap(bmpMap, Rect)
    bmpMap.Save("C:\STARS!\Map.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)

    End Sub

    This code compiles without errors, but the result is not what I expected. Can anyone help please? Thanks in advance Rob.

    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