locked
Don't Cache Image Source URI?

    Question

  • Is it possible to set an image source to a URI without the app caching the image to disk?  I am streaming a JPEG file that is rewritten every 40ms and I want to refresh the image source to playback like a video but it's only loading the image once and never refreshing it. 

    Thanks,
    Gavin

    EDIT I should note that this is my code. I am using the IgnoreImageCache option but it's not doing aything:

    BitmapImage bmp = new BitmapImage(new Uri("http://192.168.94.53/image.jpeg"));
    bmp.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
    IMAGE.Source = bmp;

    Also tried this and it didn't work:
    IMAGE.Source = null;
    BitmapImage bmp = new BitmapImage();
    bmp.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
    bmp.UriSource = new Uri("http://192.168.94.53/image.jpeg");
    IMAGE.Source = bmp;

    Monday, March 23, 2015 7:19 PM

Answers

  • Hi im.thatoneguy,

    Try this:

            private void Button_Click(object sender, RoutedEventArgs e)
            {
                image.Source = null;
                BitmapImage bmp = new BitmapImage();
                bmp.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
                bmp.UriSource = new Uri(@"http://10.168.196.118/iis-85.png?" + DateTime.Now);
                image.Source = bmp;
            }

    Tested locally, works fine, adding timespan as GET request can help to refresh.

    --James


    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, March 24, 2015 8:19 AM
    Moderator

All replies

  • Hi im.thatoneguy,

    Try this:

            private void Button_Click(object sender, RoutedEventArgs e)
            {
                image.Source = null;
                BitmapImage bmp = new BitmapImage();
                bmp.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
                bmp.UriSource = new Uri(@"http://10.168.196.118/iis-85.png?" + DateTime.Now);
                image.Source = bmp;
            }

    Tested locally, works fine, adding timespan as GET request can help to refresh.

    --James


    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, March 24, 2015 8:19 AM
    Moderator
  • Neat hack!  I can't actually test it, but I can't see any reason why it wouldn't work.  It is a unique URI so it shouldn't use the cached URI.   Since asking this question I ended up just using an WebRequest and saving the output to a MemoryStream then loading from the memory stream instead of the URI.     

    My one concern with this trick would be that would it save a new version to your application cache every time you request an image?  If I was pulling 60fps jpegs it would fill the hard drive with junk pretty quick if WinRT was storing a cached JPEG each time. 

    I've since moved on to a TCP stream where the server is just dumping JPEGs into a TCP stream on demand which is substantially better all around.   Thank you again though!
    Wednesday, March 25, 2015 6:15 PM