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

  • SEARCH
  • Home
  • 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 6888347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:00:11+00:00 2026-05-27T06:00:11+00:00

For reading a picture from a folder with my Silverlight application, I Set the

  • 0

For reading a picture from a folder with my Silverlight application, I Set the source of a Bitmap image with the stream of the file. See the code below:

string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Images", String.Format("{0}.jpg", _imageName));
if (File.Exists(path))
{
    Image = new BitmapImage();
    Image.SetSource(new MemoryStream(File.ReadAllBytes(path)));
}

The problem is that the image take a lot of time to show up and when I load a lot of pictures ( >400), I may get a insufficient memory error. I never had this error when loading a picture by the URI and I was wondering if it was possible to load it by the URI from a path. The code I tried:

string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Images", String.Format("{0}.jpg", _imageName));
if (File.Exists(path))
{
    Image = new BitmapImage()
                {
                    UriSource = new Uri(path),
                    CreateOptions = BitmapCreateOptions.DelayCreation
                };
}

Do you have any hints to provide ?

Thank you!

Philippe

  • 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-05-27T06:00:12+00:00Added an answer on May 27, 2026 at 6:00 am

    I realized that loading even when I loaded the pictures by the URI, it wasn’t loading every pictures. The software stopped loading pictures when it was taking 1.6gig of ram (out of 6gig). The difference with loading the picture by the stream is that it seems there is no protection against insufficient memory.

    As I don’t display all the images ( I realized I have over 8000 pictures when they are loaded correctly) I only load in memory the image I need to display.

    So every time I want a picture, I load it from the Hard Drive. When the pictures is no more displayed, the garbage collection get rid of them. This way, the application’s memory is always stable at around 300 meg.

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

Sidebar

Related Questions

Reading source code of sample projects, such as Beast and Bort, are recommended as
In my application I sometimes generate a new picture. After reading comments here I
Abstract: reading images from file with toggled bits to make unusable for preview tools
Reading this question I found this as (note the quotation marks) code to solve
reading excel files from C# working well in 32 bit version server. It is
I'm building an asp.net MVC application where users can attach a picture to their
I'm trying to get a System.Drawing.Image (generated in a .NET dll) into a picture
In my video chat I transfer picture, voice and text from client to server.
I was reading this article Build Your First Cloud Application Using Visual Studio 2010
I need to process pixeldata from a 1000x1000px *.bmp image (~1MiB) in javascript At

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.