×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    111

    BitmapImage Memory Footprint

    I'm trying to reduce the amount of memory a 3000x4000 jpeg image takes when shown full screen.

    I'm not sure which method is better. Should I:

    1. Create a separate, smaller thumbnail file and load that instead.

    2. Just load the original jpeg using DecodePixelWidth

    Code:
    _fullResolutionBitmapImage = new BitmapImage();
    _fullResolutionBitmapImage.ImageOpened += OnFullSizeImageOpened;
    _fullResolutionBitmapImage.CreateOptions = BitmapCreateOptions.BackgroundCreation;
    _fullResolutionBitmapImage.DecodePixelWidth = 480;
    _fullResolutionBitmapImage.SetSource(streamFromFile);
    Are these are equivalent?
    Last edited by leemcpherson; 2014-01-19 at 15:22.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2011
    Location
    Portugal
    Posts
    946

    Re: BitmapImage Memory Footprint

    Why do you need to display the full picture? Why not resize your picture and display it to the maximum resolution your device screen supports?

    If you are dealing with large files, I would also like to recommend that you use Nokia Imaging SDK as it uses much less memory on picture operations and its also faster.

  3. #3
    Regular Contributor
    Join Date
    Dec 2012
    Posts
    66

    Re: BitmapImage Memory Footprint

    Hi leemcpherson,

    Look at the "Limit image size" section here.

    Regards,
    Vinay

  4. #4
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    111

    Re: BitmapImage Memory Footprint

    I'm not sure you understand exactly what I need to do. I do need it to fit the dimension of the phone screen so I do want to resize it. I am just curious whether it is better to create an actual thumbnail file (in an earlier process) or whether it is just as good to load the image using a DecodePixelWidth=480 (for an XVGA screen, for example). I do want to be able to zoom into the picture, and I have code that can reload the original when zoomed in. I'll try the DecodePixelWidth case and see whether that helps first.

    I do agree that using the Nokia Imaging SDK would be much better in this case, but I didn't want to have to recreate all of the behavior that I get through a Scrollviewer and ViewportControl. I'll probably use it in my next iteration.

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    511

    Re: BitmapImage Memory Footprint

    I'm not sure wether zooming will really be a smooth experience if you have to reload data from storage while doing so. As for displaying a thumbnail: DecodePixelWidth should memory-wise be absolutely sufficient. Compute wise separate thumbnails should perform better but I don't know how much faster it would get. If you decide to do a performance comparison I'd be glad to see your results.

  6. #6
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    296

    Re: BitmapImage Memory Footprint

    Creating a smaller thumbnail is a good idea,
    I think you'll have a clear answer to your issue from this article
    Memory-efficient Navigation in Very High Resolution Images on Windows Phone

  7. #7
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    111

    Re: BitmapImage Memory Footprint

    I think I might know where my problems are coming from. I need to do a lot more experimentation, but I believe the massive amounts of memory are coming from using the ViewportControl. There must be BitmapCaching going on for scrolling to be so smooth, even though I did not set it explicitly. This would double the amount of memory each image takes. In any case, I'm also using a technique to unload BitmapImages from memory much more quickly than just setting it to null and garbage collecting.

    Using Nokia Imaging SDK doesn't make a lot of sense for my app. I tried using a variation of the method (#2) used in the sample from the link provided earlier. It seems to be great at displaying images that are greater than 4096x4096 dimensions, but below that, I didn't find a great advantage beyond what I was currently doing. The memory usage seems to be about the same. (I'm not going to quibble about 10 MB or so) I have a modification of a sample control from Microsoft called MediaViewer which places Images on a Canvas and lets you swipe sideways to navigate each full-screen image. The images are hosted in a ViewportControl so you can do some easy zooming and panning. The images are virtualized though, so no more than 3 are in memory at one time (current, previous, and next). Replacing each image in those virtualized items with a canvas being draw onto using Nokia Imaging SDK didn't give me much of a drop in memory usage. Maybe I wasn't doing it correctly, but I'm happy with what I have now anyways.

    In this particular case, I'm going to stick with plain images and just be very careful about managing memory. I think the Nokia Imaging SDK might be more useful if the images were bigger, or if I was using filters. Not in the comic book app, but I'm definitely using it in my molecule modeling app

  8. #8
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    511

    Re: BitmapImage Memory Footprint

    Basically the Imaging SDK has two advantages: quite good management of opening really big images without memory issues, which seems not to be an issue you run into and secondly it does a lot better than the WriteableBitmap class at freeing up memory afterwards. If I understood correctly you're using regular BitmapImages and those don't seem to have big issues so you should be fine for your use case. If you directly manipulate images I would suggest to go with the Imaging SDK over WritableBitmaps and only use the later for display of the resulting information.

  9. #9
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    111

    Re: BitmapImage Memory Footprint

    Not sure if this is kosher for this forum, but if anyone wants to see the results of my struggling with memory management and large images, you can download my free app

    http://www.windowsphone.com/s?appid=...0-a349a90dfb8b

    There's a link to a free comic in the "about" pivot for testing...

    When the average image size in these comic book files are 1920x2951 (sometimes double the width), on my Lumia 920 there's about 180MB of memory in use for the viewer (3 images loaded). That doesn't work for Low Memory devices, so I had to downscale images, but can live with that.

  10. #10
    Nokia Developer Moderator
    Join Date
    Oct 2006
    Location
    Finland
    Posts
    4,541

    Re: BitmapImage Memory Footprint

    FYI, this Discussion has been featured the details of which you will find here

    Thanks guyz for the wonderful discussion!!

  11. #11
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    473

    Re: BitmapImage Memory Footprint

    Quote Originally Posted by leemcpherson View Post
    I have a modification of a sample control from Microsoft called MediaViewer which places Images on a Canvas and lets you swipe sideways to navigate each full-screen image. The images are hosted in a ViewportControl so you can do some easy zooming and panning. The images are virtualized though, so no more than 3 are in memory at one time (current, previous, and next). Replacing each image in those virtualized items with a canvas being draw onto using Nokia Imaging SDK didn't give me much of a drop in memory usage. Maybe I wasn't doing it correctly, but I'm happy with what I have now anyways.
    Have you the link of the sample?
    Windows 8, Windows phone 8 or Nokia Asha developer? Go to DVLUP

  12. #12
    Regular Contributor
    Join Date
    Oct 2013
    Location
    Pennsauken, NJ, USA
    Posts
    111

    Re: BitmapImage Memory Footprint

    Quote Originally Posted by yan_ View Post
    Have you the link of the sample?
    This is what I started with...
    http://code.msdn.microsoft.com/wpapp...ample-359fda1b

Similar Threads

  1. How to convert from PhotoResult or BitmapImage to Bitmap?
    By rahulroy9202 in forum Windows Phone Imaging
    Replies: 2
    Last Post: 2013-11-03, 10:36
  2. Replies: 2
    Last Post: 2012-01-28, 08:12
  3. Replies: 2
    Last Post: 2004-05-05, 12:01
  4. nokia 12 footprint dimensions
    By paulnolan1 in forum General Development Questions
    Replies: 0
    Last Post: 2004-01-14, 01:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×