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. bitmap.save(filename) - A generic error occurred in GDI+.

bitmap.save(filename) - A generic error occurred in GDI+.

Scheduled Pinned Locked Moved Visual Basic
graphicshelpwinformsquestion
3 Posts 2 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
    H3rman
    wrote on last edited by
    #1

    I'm not very good at programing, and when i tries to save the bitmap to a file i get the "A generic error occurred in GDI+." what am i doing wrong? I wrote a smal app to demonstrate what my problem is. In the real app it modifies some exif data and are then supposed to save the file. Public Class frmSaveFile Private _bitmap As Bitmap Private _filename As String = "d:\husvagn.jpg" Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click _bitmap = New Bitmap(_filename) btnOpen.Enabled = False btnClose.Enabled = True End Sub Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click _bitmap.Save(_filename) btnClose.Enabled = False btnOpen.Enabled = True End Sub End Class

    D 1 Reply Last reply
    0
    • H H3rman

      I'm not very good at programing, and when i tries to save the bitmap to a file i get the "A generic error occurred in GDI+." what am i doing wrong? I wrote a smal app to demonstrate what my problem is. In the real app it modifies some exif data and are then supposed to save the file. Public Class frmSaveFile Private _bitmap As Bitmap Private _filename As String = "d:\husvagn.jpg" Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click _bitmap = New Bitmap(_filename) btnOpen.Enabled = False btnClose.Enabled = True End Sub Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click _bitmap.Save(_filename) btnClose.Enabled = False btnOpen.Enabled = True End Sub End Class

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      It errors out because the original file is locked by the Bitmap object that you loaded the image into. You can get around it by loading the image using a FileStream instead. See this[^] MS KB article for a sample.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      H 1 Reply Last reply
      0
      • D Dave Kreskowiak

        It errors out because the original file is locked by the Bitmap object that you loaded the image into. You can get around it by loading the image using a FileStream instead. See this[^] MS KB article for a sample.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        H Offline
        H Offline
        H3rman
        wrote on last edited by
        #3

        You saved my day, Thanks.. I learn something new everyday! :D

        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