Permalink
Browse files

Clean up temp file

  • Loading branch information...
Collins, Sean Collins, Sean
Collins, Sean authored and Collins, Sean committed Apr 12, 2012
1 parent dad5a1a commit ec3e1eb663cdb4c279589c2d7ade49f71b4560b5
Showing with 40 additions and 38 deletions.
  1. +40 −38 src/Enhance/Models/EnhanceImage.cs
@@ -1,38 +1,40 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Imaging;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Windows.Media.Imaging;
-using Phoenix;
-
-namespace Enhance.Models
-{
- public class EnhanceImage: ViewModelBase
- {
- public Bitmap Bitmap { get; set; }
- public BitmapImage Image { get { return ConvertImageToBitmapImage(Bitmap); } }
-
- public string Filename { get; set; }
-
- private BitmapImage ConvertImageToBitmapImage(Image bitmap)
- {
- if (bitmap == null) return null;
-
- string fileName = Path.GetTempFileName();
- File.Delete(fileName);
-
- bitmap.Save(fileName, ImageFormat.Bmp);
-
- var bitmapImage = new BitmapImage();
-
- bitmapImage.BeginInit();
- bitmapImage.StreamSource = new FileStream(fileName, FileMode.Open, FileAccess.Read);
- bitmapImage.EndInit();
-
- return bitmapImage;
- }
- }
-}
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Imaging;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Windows.Media.Imaging;
+using Phoenix;
+
+namespace Enhance.Models
+{
+ public class EnhanceImage: ViewModelBase
+ {
+ public Bitmap Bitmap { get; set; }
+ public BitmapImage Image { get { return ConvertImageToBitmapImage(Bitmap); } }
+
+ public string Filename { get; set; }
+
+ private BitmapImage ConvertImageToBitmapImage(Image bitmap)
+ {
+ if (bitmap == null) return null;
+
+ string fileName = Path.GetTempFileName();
+ File.Delete(fileName);
+
+ bitmap.Save(fileName, ImageFormat.Bmp);
+
+ var bitmapImage = new BitmapImage();
+
+ bitmapImage.BeginInit();
+ bitmapImage.StreamSource = new FileStream(fileName, FileMode.Open, FileAccess.Read);
+ bitmapImage.EndInit();
+ if(File.Exists(fileName))
+ File.Delete(fileName);
+
+ return bitmapImage;
+ }
+ }
+}

0 comments on commit ec3e1eb

Please sign in to comment.