×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Apr 2013
    Posts
    3

    1280x768 Dynamic LockScreen Wallpaper from Background Agent

    We are trying since two weeks to find a way to generate a high definition lock screen image overlay-ed with text and images for weather App in Periodic background agent on Windows Phone 8, and we are facing outOfMemoryException.

    The background agent is limited to 11.5 MB of memory and when we try to initialize the Writable-bitmap and generate the image the agent will run out of memory so we need help to find another workaround to generated a dynamic image with less memory consumption, so if anyone can help us please share.


    The below code is a snippet of the used code, you can download the full project below, and note that if we commented the part the app will generated the image with black artifacts.
    //bitmap.Invalidate()

    Code:
    StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx://" + "/TestingImage.jpg"));
                Stream s = await file.OpenStreamForReadAsync();
    
                Deployment.Current.Dispatcher.BeginInvoke(delegate {
                    WriteableBitmap bitmap = PictureDecoder.DecodeJpeg(s);
    
                    ////////////////
                    //////////////// WE NEED THIS PART
                    //bitmap.Invalidate();
    
                    file = null;
                    MemoryManagementHelper.freeUpMemory();
    
                    s.Close();
                    s.Dispose();
                    s = null;
    
                    TextBlock t = new TextBlock();
                    t.Text = "55°";
                    t.FontSize = 66;
                    t.Foreground = new SolidColorBrush(Colors.White);
                    t.FontFamily = new FontFamily("Segoe WP SemiLight");
    
                    TextBlock t2 = new TextBlock();
                    t2.Text = "47";
                    t2.FontSize = 150;
                    t2.Foreground = new SolidColorBrush(Colors.White);
                    t2.FontFamily = new FontFamily("Segoe WP SemiLight");
    
                    TextBlock t3 = new TextBlock();
                    t3.Text = "47";
                    t3.FontSize = 150;
                    t3.Foreground = new SolidColorBrush(Colors.White);
    
                    TextBlock t4 = new TextBlock();
                    t4.Text = "47";
                    t4.FontSize = 150;
                    t4.Foreground = new SolidColorBrush(Colors.White);
    
                    TextBlock t5 = new TextBlock();
                    t5.Text = "47";
                    t5.FontSize = 150;
                    t5.Foreground = new SolidColorBrush(Colors.White);
                    t5.FontFamily = new FontFamily("Segoe WP SemiLight");
    
    
                    TextBlock t6 = new TextBlock();
                    t6.Text = "47";
                    t6.FontSize = 150;
                    t6.Foreground = new SolidColorBrush(Colors.White);
                    t6.FontFamily = new FontFamily("Segoe WP SemiLight");
    
                    TextBlock t7 = new TextBlock();
                    t7.Text = "47";
                    t7.FontSize = 150;
                    t7.Foreground = new SolidColorBrush(Colors.White);
                    t7.FontFamily = new FontFamily("Segoe WP SemiLight");
    
                    bitmap.Render(t, new TranslateTransform() {
                        X = 10,
                        Y = 10
                    });
    
                    bitmap.Render(t2, new TranslateTransform() {
                        X = 100,
                        Y = 100
                    });
    
                    bitmap.Render(t3, new TranslateTransform() {
                        X = 300,
                        Y = 300
                    });
    
                    bitmap.Render(t4, new TranslateTransform() {
                        X = 500,
                        Y = 500
                    });
    
                    bitmap.Render(t5, new TranslateTransform() {
                        X = 700,
                        Y = 700
                    });
    
                    bitmap.Invalidate();
    
                    MemoryManagementHelper.freeUpMemory();
    
                    Save(handleToFileName, bitmap);
    
                    MemoryManagementHelper.DebugOutputMemoryUsage("After Saving Image");
    
                    evt.Set();
                });
    
                evt.WaitOne();
    Path1: SpeedyShare

    Path2: JumpShare

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

    Re: 1280x768 Dynamic LockScreen Wallpaper from Background Agent

    Can you take a look at this thread and see if you problem is related? http://www.developer.nokia.com/Commu...riteableBitmap

  3. #3
    Registered User
    Join Date
    Apr 2013
    Posts
    3

    Re: 1280x768 Dynamic LockScreen Wallpaper from Background Agent

    Quote Originally Posted by joaocardoso View Post
    Can you take a look at this thread and see if you problem is related? http://www.developer.nokia.com/Commu...riteableBitmap
    We already did, and that does not solve our case, we are trying to generate a full lock screen image with around 1280x768 rather than a live tile of size 691x336 px.

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2011
    Location
    Portugal
    Posts
    948

    Re: 1280x768 Dynamic LockScreen Wallpaper from Background Agent

    Quote Originally Posted by windowsPhoneCoder View Post
    We already did, and that does not solve our case, we are trying to generate a full lock screen image with around 1280x768 rather than a live tile of size 691x336 px.
    What is the size of the source image? 1280x768 or larger that you want to resize?

  5. #5
    Registered User
    Join Date
    Apr 2013
    Posts
    3

    Re: 1280x768 Dynamic LockScreen Wallpaper from Background Agent

    Quote Originally Posted by joaocardoso View Post
    What is the size of the source image? 1280x768 or larger that you want to resize?
    its 1280x768, you can check the sample path1 or path2!

  6. #6
    Registered User
    Join Date
    Jul 2011
    Posts
    20

    Re: 1280x768 Dynamic LockScreen Wallpaper from Background Agent

    I found that DecodeJpeg is not a good idea for Background Agent. In my app I checked both this way and BitmapImage loading from stream and the second one had less memory footprint.
    Did you try old fashioned way with BitmapImage?
    If you're still out of limits, you can try rendering 2 parts of the image (top and bottom) and them merging them.

Similar Threads

  1. Dynamic text on a wallpaper issue (S40)
    By powerpixels in forum [Archived] Flash Lite on Nokia Devices
    Replies: 3
    Last Post: 2010-01-12, 18:46
  2. App Background Wallpaper
    By diptendulkar in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2009-01-28, 04:18
  3. How to set Wallpaper as Theme Background ?
    By A Cloud in forum Streaming and Video
    Replies: 0
    Last Post: 2007-06-22, 02:32
  4. Agent appplication with should run in background
    By alonish in forum Mobile Java General
    Replies: 8
    Last Post: 2007-01-08, 14:50
  5. Wallpaper & running background
    By Tixxx in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2004-12-20, 08:30

Posting Permissions

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