Fill Image from response.GetStream

Discussion in 'Questions (Windows Mobile)' started by cvanlith, Nov 22, 2007.

  1. cvanlith

    cvanlith New Member Licensed User

    Is it possible to fill an image from response.GetStream without writing it out to a file first?

    Thanks in advance
    Chris
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    No. You will need to save it as a temporary file first.
     
  3. cvanlith

    cvanlith New Member Licensed User

    Thanks.

    So I tried writing it out. Unfortunately when I try to write out a new version of the image it does not allow me that as the file is locked. The lock is caused by Image1.Image = "MapImage.gif".

    So the first time it works, the second time FileOpen fails because of the lock. I tried pointing Image1 to another image and FileCopy, but the lock remains.

    Any thoughts?
    Chris
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    I've attached an example which uses a Bitmap object (from the ImageLib library) to load an image from a temporary file, assign it to an Image control and delete the file.
    Two 'tricks' are used:
    By calling Image1.Image = Image1.Image we are creating an internal copy of the image.
    By disposing the bitmap object we are releasing the locked file.
     

    Attached Files:

Loading...