I am creating wpf application. I am showing the preview image(which is taken by cam) in Image control. The image get saved by default. If the user want to retake the photo i am deleting the current image.
int imageCount = Directory.GetFiles(imgDir, "*",SearchOption.TopDirectoryOnly).Length;
ImageFormat imgFormat = (ImageFormat)GetValue(SnapshotFormatProperty);
string filePath = Path.Combine(imgDir, "IMAGE_" + ++imageCount + ".Jpeg");
using (Bitmap bmp = new Bitmap(panelWidth, panelHeight))
{
using (Graphics graphics = Graphics.FromImage(bmp))
{
}
bmp.Save(filePath, imgFormat);
}
globalFilePath = filePath;
showing image in Image Control
string strUri = String.Format(WebCamControl.globalFilePath);
previewImage.Source = BitmapFromUri(new Uri(strUri));
public static ImageSource BitmapFromUri(Uri source)
{
var bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.UriSource = source;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
return bitmap;
}
previewImage.Source = null;
if (System.IO.File.Exists(WebCamControl.globalFilePath))
{
System.IO.File.Delete(WebCamControl.globalFilePath);
}
else
{
MessageBox.Show("File Not Exists");
}
After Completing this process when i take the new image the Image control shows the previous image which was deleted. Is the Image Control caching the previus Image??Kindly give me the solution.