picturebox save?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • patr0805
    New Member
    • Sep 2007
    • 48

    picturebox save?

    Hi I am not new to vb, but I still can't solve this problem. I have flipped the image in the form, but when I save the image then the saved image is the original unflipped one)
    [code=vb]
    Private Sub ToolStripButton 1_Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles ToolStripButton 1.Click
    If ofdOpen.Initial Directory Is Nothing Or ofdOpen.Initial Directory = String.Empty Then
    ofdOpen.Initial Directory = DXUtil.SdkMedia Path
    End If
    ofdOpen.Filter = filterText
    ofdOpen.Title = "Open media file"
    ofdOpen.ShowDia log(Me)
    If ofdOpen.FileNam e = "" Then

    Else
    Dim ext = System.IO.Path. GetExtension(of dOpen.FileName)
    If ext = ".jpg" Or ext = ".bmp" Or ext = ".gif" Or ext = ".tga" Then
    On Error Resume Next
    ourVideo.Dispos e()
    mnuPlay.Enabled = False
    mnuStop.Enabled = False
    mnuPause.Enable d = False
    Me.Width = 975
    Me.Height = 521
    PictureBox1.Vis ible = True
    Panel1.Width = 969
    Panel1.Height = 440
    MenuItem13.Enab led = True
    mnuPlay.Enabled = True
    mnuStop.Enabled = True
    mnuPause.Enable d = True
    MenuItem6.Enabl ed = True
    MenuItem9.Enabl ed = True
    MenuItem7.Enabl ed = True
    MenuItem8.Enabl ed = True
    MenuItem10.Enab led = True
    MenuItem11.Enab led = True
    ToolStripButton 3.Enabled = True
    ToolStripButton 4.Enabled = True
    ToolStripButton 2.Enabled = True
    PictureBox1.Ima geLocation = ofdOpen.FileNam e
    PictureBox1.Siz eMode = PictureBoxSizeM ode.CenterImage
    Dim b As New Bitmap(ofdOpen. FileName)
    PictureBox1.Hei ght = b.Height
    PictureBox1.Wid th = b.Width
    siW = PictureBox1.Wid th
    siH = PictureBox1.Hei ght
    imgUndo = PictureBox1.Ima ge
    Else
    ToolStripButton 3.Enabled = False
    ToolStripButton 4.Enabled = False
    ToolStripButton 2.Enabled = False
    PictureBox1.Vis ible = False
    MenuItem13.Enab led = False
    mnuPlay.Enabled = True
    mnuStop.Enabled = True
    mnuPause.Enable d = True
    MenuItem6.Enabl ed = False
    MenuItem9.Enabl ed = False
    MenuItem7.Enabl ed = False
    MenuItem8.Enabl ed = False
    MenuItem10.Enab led = False
    MenuItem11.Enab led = False
    On Error Resume Next
    ourVideo.Dispos e()
    Me.OpenFile()
    End If
    End If

    End Sub
    Private Sub ToolStripButton 3_Click(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles ToolStripButton 3.Click
    Dim i
    If System.IO.Path. GetExtension(of dOpen.FileName) = ".jpg" Then
    i = ImageFormat.Jpe g
    End If
    If System.IO.Path. GetExtension(of dOpen.FileName) = ".bmp" Then
    i = ImageFormat.Bmp
    End If
    If System.IO.Path. GetExtension(of dOpen.FileName) = ".emf" Then
    i = ImageFormat.Emf
    End If
    If System.IO.Path. GetExtension(of dOpen.FileName) = ".exif" Then
    i = ImageFormat.Exi f
    End If
    If System.IO.Path. GetExtension(of dOpen.FileName) = ".gif" Then
    i = ImageFormat.Gif
    End If
    If System.IO.Path. GetExtension(of dOpen.FileName) = ".ico" Then
    i = ImageFormat.Ico n
    End If
    If System.IO.Path. GetExtension(of dOpen.FileName) = ".png" Then
    i = ImageFormat.Png
    End If
    If System.IO.Path. GetExtension(of dOpen.FileName) = ".tiff" Then
    i = ImageFormat.Tif f
    End If
    If System.IO.Path. GetExtension(of dOpen.FileName) = ".wmf" Then
    i = ImageFormat.Wmf
    End If
    Dim pr = System.IO.Path. GetDirectoryNam e(ofdOpen.FileN ame)
    Dim fn = System.IO.Path. GetFileName(ofd Open.FileName)
    PictureBox1.Ima ge.Save(pr + fn, i)
    End Sub
    Private Sub MenuItem7_Click _1(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MenuItem7.Click
    PictureBox1.Ima ge.RotateFlip(R otateFlipType.R otate90FlipNone )
    PictureBox1.Ref resh()
    PictureBox1.Wid th = PictureBox1.Ima ge.Size.Width
    PictureBox1.Hei ght = PictureBox1.Ima ge.Size.Height
    End Sub

    Private Sub MenuItem8_Click _1(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MenuItem8.Click
    PictureBox1.Ima ge.RotateFlip(R otateFlipType.R otate270FlipNon e)
    PictureBox1.Ref resh()
    PictureBox1.Wid th = PictureBox1.Ima ge.Size.Width
    PictureBox1.Hei ght = PictureBox1.Ima ge.Size.Height
    End Sub[/code]

    This is not my entire code, but it is somewhere in this code where the error is.
    Please help
    Last edited by debasisdas; Mar 20 '08, 10:08 AM. Reason: added code=vb tags
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Where are you storing the image after flipping ?

    Comment

    • patr0805
      New Member
      • Sep 2007
      • 48

      #3
      overwriting the opened image

      Comment

      • patr0805
        New Member
        • Sep 2007
        • 48

        #4
        I have fixed the problem

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          Try using this to flip the image

          [code=vb]Picture2.PaintP icture Picture1.Pictur e, Picture1.ScaleW idth, 0, -1 * Picture1.ScaleW idth, Picture1.ScaleH eight[/code]

          Comment

          • patr0805
            New Member
            • Sep 2007
            • 48

            #6
            but how do I tell picturebox1 to close the opened file so that I can delete the file

            Comment

            • debasisdas
              Recognized Expert Expert
              • Dec 2006
              • 8119

              #7
              Use this

              Picture1.Pictur e = Nothing


              and then Kill the file

              Comment

              Working...