Bind StorageFile to Image source RRS feed

  • Question

  •  Hi All,

                 I am developing an App in windows phone 8.1 , which contains thousands of storage files binding to images in listview.

    I am first getting stream from file and preparing in to bitmap in converter class and return bitmap to imagesource property which takes lot of time and memory exception,Is there any best way to achieve this , i.e can I directly bind storagefile/filepath to image Source, if yes please give an example.



    • Edited by SARVESH.RVN Monday, January 19, 2015 1:52 PM
    Monday, January 19, 2015 1:51 PM


All replies

  • Hi!

    I think the Converter part where you set the image source of your solution is correct. The problem is that you are getting the full image, that's no good. You should really use the GetThumbnailAsync method to get a smaller thunmbail of the image. This post by Amar Nityananda should help if case you have any doubts with the implementation.

    Hope it helps.



    Monday, January 19, 2015 2:13 PM
  •  Hi sameer,

                  I am using GetThumbnailAsync for thumbnails it was OK , but I want to load full image also.


    Monday, January 19, 2015 2:16 PM
  • I see...

    Did you set the bitmaps DecodePixelHeight and DecodePixelWidth properties?

    The JPEG and Portable Network Graphics (PNG) codecs natively decode the image to the specified size; other codecs decode the image at its original size and scale the image to the desired size.

    These properties can help by minimizing the data being retrieved from storage.



    Monday, January 19, 2015 2:30 PM
  •   Yes , I have used them....:)

                  How can I clear bitmap cache? On Image unloaded I am giving null to image source still the memory problem cant reduce.....


    Monday, January 19, 2015 2:50 PM
  • Have you checked if that Unloaded Event is actually being called?

    Another thing you may try is to only really render the images that are displayed on screen. I am assuming that you load all of those images but not all of them are visible at the same time.



    Monday, January 19, 2015 4:06 PM
  •  yes, it was calling....


    Thursday, January 22, 2015 7:29 AM
  • Hi Sarvesh,

    I found a thread talking about this similar question, please refer to the following link to see more. https://social.msdn.microsoft.com/Forums/windowsapps/en-US/51c43447-0289-4b93-9ba7-a5f1ef57d1a6/how-to-bind-image-into-into-listview-template-image-location-is-in-library-folder-?forum=winappswithcsharp. Note it is a store app thread, but you can use the code snippet in your phone project.

    Feel free to let me know if you have any concerns.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Tuesday, February 3, 2015 7:58 AM