Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9193295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:07:40+00:00 2026-06-17T21:07:40+00:00

I have a function in my VB project where i scan an image and

  • 0

I have a function in my VB project where i scan an image and then I can change the contrast.
I scan it and saves it C:\temp\my_img.tif.

In the winform the image is displayed in a PictureBox.

If I in the contrast function set like img.Save("C:\temp\my_img.tif", ImageFormat.Tiff) I get “A generic error occurred in GDI+.”. If I however set the filename to something else, it works just fine.

So, how do I release the used image before saving it?

The whole function, in short:

Sub setContrast(ByVal C As Single)
    'filename(1) ia a "global" variable that stores the used file path, in this case "C:\temp\my_img.tif"

    Dim img As Image = Image.FromFile(filename(1)) '<--- I get the image

    'A bunch of contrast stuff in some rows.....

    'Here, i should release the image...

    img.Save(filename(1), ImageFormat.Tiff) '<---Tries to save

    PictureBox1.Refresh()
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:07:42+00:00Added an answer on June 17, 2026 at 9:07 pm

    Save it using a different file name, and then, if necessary, delete the old file and rename the new file to match the old, having Disposed of the Image beforehand.

    From Image.FromFile:

    The file remains locked until the Image is disposed.

    There’s no wording anywhere else that says that this is somehow worked around if the same Image instance is trying to Save back to the file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function like this: p() { cd ~/Clients/$1/Projects/$2; } Then I can
I have problem with my C# winform project. I have function that draw squares:
I have a search function in my project. In the searchable.xml, i would like
In my PHP project I have two different models that have a function with
I have the following function (from the opensource project recast navigation ): /// Derives
In a C project, I have a main() function in several files. When I
$(.container).hover( function(){ $(.child-1).hide(0); $(.child-2).show(0); },function(){ $(.child-1).show(0); $(.child-2).hide(0); }); A project I have requires that
In my project I have a function named GetObject that is wrapped in one
i have this function in my project public function changeFormItemsLabelWidth(form:Form, width:int):void { var formItemsArray:Array
I have the following recursive function for project euler question no. 74 : chain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.