none
How to load BMP image files into ImageSource of Image control with less memory usage and with good performance RRS feed

  • Question

  • We want to load BMP images in our application. Please suggest how to load BMP image files into ImageSource of Image control with less memory usage and with good performance ?
    We used below codes, we are able to load the images but it takes huge time to load with more memory usage (even with the usage of DecodePixelHeight/Width )

    var image = new BitmapImage();
    image.BeginInit();
    image.CacheOption = BitmapCacheOption.OnLoad;
    image.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
    image.UriSource = new Uri(FullName);     //FullName is image name with path
    image.DecodePixelHeight = 150;
    image.EndInit();
    image.Freeze();
    ImageSource = image;

    We need to load a folder of size 1GB of bmp files (each of size 5-10 MB). As of now initial load takes 6 minutes. But others images like JPG and PNG files of 1 GB data loads below 30 seconds

    Thursday, July 12, 2018 3:37 AM

All replies

  • Hi Dot,

    What is your ImageSouce Control?

    Do you develop with Winfrom, WPF or any Asp.Net project?

    It would be helpful if you could share us more information about your issue.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 12, 2018 5:02 AM
  • Hi Tao,

    Thanks for responding immediately i have provided more details below.

    We are developing our application by using WPF and C#.
    Our requirement is to load all the files from the selected directory and display those file in listbox.
    For us listbox each item is Image control.
    We are using ImageSource type property in a CS class and this property is binded to Image control Source property in Xaml part.

    By using above code, we are loading image type files from the selected directory and storing into ImageSource property which is directly binded to Xaml Image control as explained above.

    Loading 1GB files of type JPG/PNG/PANO etc takes less than 30 secs.
    But loading BMP type images takes 6 minutes, Because in above code we used DecodePixelHeight to load image this future is not supported by BMP.

    So we looking for other options to load BMP images with good performance ?

    Thursday, July 12, 2018 7:04 AM
  • Hi DotNetTeamX,

    Thanks for your post.

    This forum is used to discuss about WCF Developing issue, for WPF issue, I suggest you go to forum below:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wpf

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 17, 2018 7:36 AM