|
@@ -434,23 +434,23 @@ namespace Common.system
|
434
|
434
|
|
435
|
435
|
MemoryStream memoryStream = new MemoryStream();
|
436
|
436
|
encoder.Save(memoryStream);
|
437
|
|
- Bitmap bit = new Bitmap(memoryStream,true);
|
|
437
|
+ Bitmap bit = new Bitmap(memoryStream, true);
|
438
|
438
|
if (ImgWidth - 2 < bit.Width)
|
|
439
|
+ {
|
|
440
|
+ try
|
439
|
441
|
{
|
440
|
|
- try
|
441
|
|
- {
|
442
|
|
- Graphics g = Graphics.FromImage(Img);
|
|
442
|
+ Graphics g = Graphics.FromImage(Img);
|
443
|
443
|
g.DrawImage(bit, new Rectangle(0, 0, ImgWidth, ImgHeight), new Rectangle(0, 0, bit.Width, bit.Height), GraphicsUnit.Pixel);
|
444
|
|
- g.Dispose();
|
445
|
|
- }
|
446
|
|
- catch
|
447
|
|
- {
|
448
|
|
- Img = bit;
|
449
|
|
- }
|
|
444
|
+ g.Dispose();
|
450
|
445
|
}
|
451
|
|
- else
|
|
446
|
+ catch
|
452
|
447
|
{
|
453
|
448
|
Img = bit;
|
|
449
|
+ }
|
|
450
|
+ }
|
|
451
|
+ else
|
|
452
|
+ {
|
|
453
|
+ Img = bit;
|
454
|
454
|
}
|
455
|
455
|
Img.Save(filePathName);
|
456
|
456
|
memoryStream.Dispose();
|
|
@@ -638,71 +638,71 @@ namespace Common.system
|
638
|
638
|
BitmapEncoder encoder = new PngBitmapEncoder();
|
639
|
639
|
encoder.Frames.Add(BitmapFrame.Create(bmp));
|
640
|
640
|
string filePathName = saveModel.filePathName;
|
641
|
|
- if (ImgWidth > 0)
|
642
|
|
- {
|
643
|
|
- Bitmap Img = new Bitmap(ImgWidth, ImgHeight);
|
644
|
|
- try
|
|
641
|
+ if (ImgWidth > 0)
|
645
|
642
|
{
|
646
|
|
- MemoryStream memoryStream = new MemoryStream();
|
647
|
|
- encoder.Save(memoryStream);
|
648
|
|
- new Thread(new ThreadStart(new Action(() =>
|
|
643
|
+ Bitmap Img = new Bitmap(ImgWidth, ImgHeight);
|
|
644
|
+ try
|
649
|
645
|
{
|
|
646
|
+ MemoryStream memoryStream = new MemoryStream();
|
|
647
|
+ encoder.Save(memoryStream);
|
|
648
|
+ new Thread(new ThreadStart(new Action(() =>
|
|
649
|
+ {
|
650
|
650
|
//System.Drawing.Image img = System.Drawing.Image.FromStream(memoryStream);
|
651
|
651
|
Bitmap bit = new Bitmap(memoryStream);
|
652
|
|
- if (ImgWidth - 2 < bit.Width)
|
653
|
|
- {
|
654
|
|
- try
|
|
652
|
+ if (ImgWidth - 2 < bit.Width)
|
655
|
653
|
{
|
656
|
|
- Graphics g = Graphics.FromImage(Img);
|
|
654
|
+ try
|
|
655
|
+ {
|
|
656
|
+ Graphics g = Graphics.FromImage(Img);
|
657
|
657
|
//g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
658
|
658
|
g.DrawImage(bit, new Rectangle(0, 0, ImgWidth, ImgHeight), new Rectangle(0, 0, bit.Width, bit.Height), GraphicsUnit.Pixel);
|
659
|
|
- g.Dispose();
|
|
659
|
+ g.Dispose();
|
|
660
|
+ }
|
|
661
|
+ catch
|
|
662
|
+ {
|
|
663
|
+ Img = bit;
|
|
664
|
+ }
|
660
|
665
|
}
|
661
|
|
- catch
|
|
666
|
+ else
|
662
|
667
|
{
|
663
|
668
|
Img = bit;
|
664
|
669
|
}
|
665
|
|
- }
|
666
|
|
- else
|
667
|
|
- {
|
668
|
|
- Img = bit;
|
669
|
|
- }
|
670
|
|
- Img.Save(filePathName);
|
|
670
|
+ Img.Save(filePathName);
|
671
|
671
|
//Bitmap bitmap = CutImageWhitePart(Img);
|
672
|
672
|
//FileToolsCommon.DeleteFile(filePathName);
|
673
|
673
|
//bitmap.Save(filePathName);
|
674
|
674
|
//bitmap.Dispose();
|
675
|
675
|
memoryStream.Dispose();
|
676
|
|
- Img.Dispose();
|
677
|
|
- bit.Dispose();
|
678
|
|
- }))).Start();
|
|
676
|
+ Img.Dispose();
|
|
677
|
+ bit.Dispose();
|
|
678
|
+ }))).Start();
|
|
679
|
+ }
|
|
680
|
+ catch (Exception ex)
|
|
681
|
+ {
|
|
682
|
+
|
|
683
|
+ }
|
679
|
684
|
}
|
680
|
|
- catch (Exception ex)
|
|
685
|
+ else
|
681
|
686
|
{
|
|
687
|
+ //SaveImageModel sim = new SaveImageModel();
|
|
688
|
+ //sim.encoder = new PngBitmapEncoder();
|
|
689
|
+ //sim.encoder = new PngBitmapEncoder();
|
|
690
|
+ //BitmapFrame test= encoder.Frames[0];
|
|
691
|
+ //sim.encoder.Frames.Add(BitmapFrame.Create(test));
|
|
692
|
+ ////sim.encoder.Frames[0].CopyTo(encoder.Frames[0]);
|
|
693
|
+ ////sim.encoder.CopyTo(encoder);
|
|
694
|
+ ////encoder.CopyTo(sim.encoder);
|
|
695
|
+ //sim.FilePath = filePathName;
|
|
696
|
+ ////sim.bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
|
|
697
|
+ ////bmp.CopyTo(sim.bmp);
|
|
698
|
+ //Thread t1 = new Thread(SaveImage);
|
|
699
|
+ //t1.Start(sim);
|
682
|
700
|
|
|
701
|
+ System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
|
|
702
|
+ encoder.Save(fs);
|
|
703
|
+ fs.Close();
|
683
|
704
|
}
|
684
|
705
|
}
|
685
|
|
- else
|
686
|
|
- {
|
687
|
|
- //SaveImageModel sim = new SaveImageModel();
|
688
|
|
- //sim.encoder = new PngBitmapEncoder();
|
689
|
|
- //sim.encoder = new PngBitmapEncoder();
|
690
|
|
- //BitmapFrame test= encoder.Frames[0];
|
691
|
|
- //sim.encoder.Frames.Add(BitmapFrame.Create(test));
|
692
|
|
- ////sim.encoder.Frames[0].CopyTo(encoder.Frames[0]);
|
693
|
|
- ////sim.encoder.CopyTo(encoder);
|
694
|
|
- ////encoder.CopyTo(sim.encoder);
|
695
|
|
- //sim.FilePath = filePathName;
|
696
|
|
- ////sim.bmp = new RenderTargetBitmap(width, height, PrimaryScreen.DpiX, PrimaryScreen.DpiY, PixelFormats.Pbgra32);
|
697
|
|
- ////bmp.CopyTo(sim.bmp);
|
698
|
|
- //Thread t1 = new Thread(SaveImage);
|
699
|
|
- //t1.Start(sim);
|
700
|
|
-
|
701
|
|
- System.IO.FileStream fs = new System.IO.FileStream(filePathName, System.IO.FileMode.Create);
|
702
|
|
- encoder.Save(fs);
|
703
|
|
- fs.Close();
|
704
|
|
- }
|
705
|
|
- }
|
706
|
706
|
catch (Exception ex)
|
707
|
707
|
{
|
708
|
708
|
|