CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2006
    Posts
    7

    Resolved [RESOLVED] Problem with savefiledialog

    Hi,

    When I save my picturebox no matter what the background colour is, it gets set to black. Does anyone know why it is doing this?

    Here is the saving code:
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim saveFileDialog1 As New SaveFileDialog()
    saveFileDialog1.Filter = "JPeg Image|*.jpg"
    saveFileDialog1.Title = "Save an Image File"
    saveFileDialog1.ShowDialog()


    If saveFileDialog1.FileName <> "" Then

    Dim fs As System.IO.FileStream = CType _
    (saveFileDialog1.OpenFile(), System.IO.FileStream)

    Select Case saveFileDialog1.FilterIndex
    Case 1
    Me.PictureBox1.Image.Save(fs, _
    System.Drawing.Imaging.ImageFormat.Jpeg)


    End Select

    fs.Close()
    End If
    End Sub


    The rest of this of the code is basically just comboboxes and a little reset code.


    Thanks in Advance
    Last edited by Splatch; July 20th, 2006 at 08:31 AM.

  2. #2
    Join Date
    Dec 2002
    Posts
    305

    Re: Problem with savefiledialog

    try

    Case 0

  3. #3
    Join Date
    Jul 2006
    Posts
    7

    Re: Problem with savefiledialog

    I tried it, but when i had saved it, the saved picture just showed up as an error icon in picture manager.

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Problem with savefiledialog


  5. #5
    Join Date
    Jul 2006
    Posts
    7

    Re: Problem with savefiledialog

    Thanks, that has helped.

    It has got rid of the black, but it does that by not saving the background, is there a way to get it to save the background color.

  6. #6
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Problem with savefiledialog

    OK, what I then would advise you, is to fill the background of the picture box, as a rectangle, to the same dimensions of the height and witdh of the picturebox.

    Then save!

    I'm attaching a project for you, it's update especially for you!

    Have a look at the Background Button, it changes the picturebox's background to blue Note that the 248 specified there is 248 for the height and 248 for the width of the picturebox.
    Click save. Open the picture, your background will be blue.

    have fun!
    Last edited by HanneSThEGreaT; December 19th, 2008 at 03:08 AM.

  7. #7
    Join Date
    Jul 2006
    Posts
    7

    Re: Problem with savefiledialog

    Thanks, I've got it working now

  8. #8
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Problem with savefiledialog

    You're welcome!

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

Featured