0

I'm new to WPF and am having some trouble loading an image from a file that has been modified.

I have an image control called Image1, which I load in the following manner

        string fileName = "C:\\Users\\..\\myImage.jpg"
        BitmapImage tmp = new BitmapImage();
        tmp.BeginInit();
        tmp.UriSource = new Uri(@fileName, UriKind.Absolute);
        tmp.CacheOption = BitmapCacheOption.OnLoad;
        tmp.EndInit();
        Image1.Source = tmp;

This works the first time, but then I run a function which overwrites myImage.jpg, at which point I call this code again, expecting Image1 to update. However, the GUI remains unchanged. Does it have something to do with the cacheoption? I need that so that I can overwrite the file.

user1475729
  • 173
  • 6
  • 4
    First link on google: http://stackoverflow.com/questions/1491383/reloading-an-image-in-wpf – Yogee Jun 11 '13 at 16:52

1 Answers1

0

First of all when we want a modified image file,then we have to save first the image file by calling save method in that function where u r overwriting.

when saving also do something cleverly, like create copy of that original image file then modify that copied file,then save the file,so that when u access again that image file,u can get that modified file + original file.Because sometimes the original file will modified.

uncle_scrooge
  • 409
  • 1
  • 5
  • 28