Ver Fonte

The particle list further modifies the image

cxs há 2 meses atrás
pai
commit
5bcc9b9d99

+ 8 - 6
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage/ParticlesGridDevidePage.cs

@@ -1,5 +1,4 @@
-using DevExpress.XtraPrinting.Native;
-using NPOI.SS.UserModel;
+using NPOI.SS.UserModel;
 using NPOI.SS.UserModel.Charts;
 using NPOI.SS.Util;
 using NPOI.XSSF.UserModel;
@@ -488,8 +487,8 @@ namespace OTSIncAReportGrids
                         DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
                         iconColumn.Name = en.Current.Key;
                         iconColumn.HeaderText = en.Current.Value;
-                        iconColumn.ImageLayout = DataGridViewImageCellLayout.Stretch;
-                        iconColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
+                        //iconColumn.ImageLayout = DataGridViewImageCellLayout.Zoom;
+                        //iconColumn.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
                         dgV_ParticlesDevidePage.Columns.Add(iconColumn);
                     }
                     else if (en.Current.Key == "Element")
@@ -574,7 +573,10 @@ namespace OTSIncAReportGrids
                                 int height = result.GetImageHeight();
                                 string vs = "," + subParticleString.Replace(':', '-') + ",";
                                 DataTable dataTable = Particledata.GetParticleAllForBig(vs);//组成拼接颗粒的子颗粒
-                                bmap = fldImgAccess.GetBitmapForMergedParticle(subParticleString, pix, height, width, dataTable);
+                                var bmap1 = fldImgAccess.GetBitmapForMergedParticle(subParticleString, pix, height, width, dataTable);
+                                int cellWidth = dgV_ParticlesDevidePage.Columns[k].Width - 20;
+                                int cellHeight = dgV_ParticlesDevidePage.Rows[add_rowindex].Height - 20;
+                                bmap = fldImgAccess.ScaleImageProportional(bmap1, cellWidth, cellHeight);
                                 if (bmap != null)
                                 {
                                     string[] str = subParticleString.Split(',');
@@ -2577,7 +2579,7 @@ namespace OTSIncAReportGrids
                     }
                     Bitmap bmap = fldImgAccess.GetBitmapForParticleAll(subParticleString, dataTable, pix, height, width);
                     Bitmap bmap1 = fldImgAccess.GetBitmapForParticleAllWithBlackAndWhite(subParticleString, dataTable, segsData, pix, height, width);
-                    control_XRayTable1.SetBitmapOfPictureBox(bmap1, bmap);
+                    control_XRayTable1.SetBitmapOfPictureBox(bmap,bmap1 );
                     Invalidate();
                     ToolStripMenuItem_SimilarityReclassification.Enabled = true;
                 }

+ 16 - 0
OTSIncAReportApp/3-ServiceCenter/DataOperation/ImageAccess/FieldImage.cs

@@ -3,6 +3,7 @@ using System;
 using System.Collections.Generic;
 using System.Data;
 using System.Drawing;
+using System.Drawing.Drawing2D;
 using System.Drawing.Imaging;
 using System.IO;
 
@@ -392,5 +393,20 @@ namespace OTSIncAReportApp._3_ServiceCenter.DataOperation.DataAccess
             Bitmap bmap = CapturePic(dpImage, rectangle);
             return bmap;
         }
+
+        public Bitmap ScaleImageProportional(Image sourceImage, int newWidth, int newHeight)
+        {
+            Bitmap result = new Bitmap(newWidth, newHeight);
+            using (Graphics g = Graphics.FromImage(result))
+            {
+                g.CompositingQuality = CompositingQuality.HighQuality;
+                g.SmoothingMode = SmoothingMode.HighQuality;
+                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
+                g.DrawImage(sourceImage, 0, 0, newWidth, newHeight);
+            }
+            return result;
+        }
+
+
     }
 }