|
@@ -6,9 +6,12 @@ using System.IO;
|
6
|
6
|
using System.Text;
|
7
|
7
|
using System.Threading;
|
8
|
8
|
using System.Windows;
|
|
9
|
+using System.Windows.Documents;
|
9
|
10
|
using System.Windows.Media;
|
10
|
11
|
using System.Windows.Media.Imaging;
|
11
|
12
|
|
|
13
|
+using VisioForge.Shared.Helpers;
|
|
14
|
+
|
12
|
15
|
namespace Common.system
|
13
|
16
|
{
|
14
|
17
|
/// <summary>
|
|
@@ -447,25 +450,23 @@ namespace Common.system
|
447
|
450
|
}
|
448
|
451
|
else
|
449
|
452
|
{
|
|
453
|
+ //SaveImageModel sim = new SaveImageModel();
|
|
454
|
+ //sim.encoder = new PngBitmapEncoder();
|
|
455
|
+ //sim.encoder = new PngBitmapEncoder();
|
|
456
|
+ //BitmapFrame test= encoder.Frames[0];
|
|
457
|
+ //sim.encoder.Frames.Add(BitmapFrame.Create(test));
|
|
458
|
+ ////sim.encoder.Frames[0].CopyTo(encoder.Frames[0]);
|
|
459
|
+ ////sim.encoder.CopyTo(encoder);
|
|
460
|
+ ////encoder.CopyTo(sim.encoder);
|
|
461
|
+ //sim.FilePath = filePathName;
|
|
462
|
+ ////sim.bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
|
|
463
|
+ ////bmp.CopyTo(sim.bmp);
|
|
464
|
+ //Thread t1 = new Thread(SaveImage);
|
|
465
|
+ //t1.Start(sim);
|
|
466
|
+
|
450
|
467
|
System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
|
451
|
468
|
encoder.Save(fs);
|
452
|
469
|
fs.Close();
|
453
|
|
-
|
454
|
|
- //MemoryStream memoryStream = new MemoryStream();
|
455
|
|
- //encoder.Save(memoryStream);
|
456
|
|
- //Bitmap bit = new Bitmap(memoryStream);
|
457
|
|
- //bit.Save(filePathName);
|
458
|
|
- //bit.Dispose();
|
459
|
|
-
|
460
|
|
- //using (FileStream tFileStream = new FileStream(filePathName,FileMode.Create, FileAccess.Write))
|
461
|
|
- //{
|
462
|
|
- // PngBitmapEncoder tPngBitmapEncoder = new PngBitmapEncoder();
|
463
|
|
- // tPngBitmapEncoder.Interlace = PngInterlaceOption.On;
|
464
|
|
- // tPngBitmapEncoder.Frames.Add(BitmapFrame.Create(bmp));
|
465
|
|
- // tPngBitmapEncoder.Save(tFileStream);
|
466
|
|
- // tFileStream.Close();
|
467
|
|
- //}
|
468
|
|
-
|
469
|
470
|
}
|
470
|
471
|
}
|
471
|
472
|
catch (Exception ex)
|
|
@@ -474,6 +475,20 @@ namespace Common.system
|
474
|
475
|
//Console.WriteLine(ex.Message);
|
475
|
476
|
}
|
476
|
477
|
}
|
|
478
|
+
|
|
479
|
+ private static void SaveImage(object obj)
|
|
480
|
+ {
|
|
481
|
+ SaveImageModel sim = (SaveImageModel)obj;
|
|
482
|
+ //RenderTargetBitmap bmp = sim.bmp;
|
|
483
|
+ //BitmapEncoder encoder = new PngBitmapEncoder();
|
|
484
|
+ //encoder.Frames.Add(BitmapFrame.Create(bmp));
|
|
485
|
+ BitmapEncoder encoder = sim.encoder;
|
|
486
|
+ string filePathName = sim.FilePath;
|
|
487
|
+ System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
|
|
488
|
+ encoder.Save(fs);
|
|
489
|
+ fs.Close();
|
|
490
|
+ }
|
|
491
|
+
|
477
|
492
|
#endregion
|
478
|
493
|
|
479
|
494
|
#region 去掉白边
|
|
@@ -600,4 +615,11 @@ namespace Common.system
|
600
|
615
|
}
|
601
|
616
|
#endregion
|
602
|
617
|
}
|
|
618
|
+ public class SaveImageModel
|
|
619
|
+ {
|
|
620
|
+ public string FilePath { get; set; }
|
|
621
|
+ public BitmapEncoder encoder { get; set; }
|
|
622
|
+ //public RenderTargetBitmap bmp { get; set; }
|
|
623
|
+ }
|
|
624
|
+
|
603
|
625
|
}
|