예제 #1
0
        public bool SaveImageToFile(AqDisplay aqDisplay, Bitmap originBitmap, string strSavePath)
        {
            string sourcePath = strSavePath + @"Source\";
            string resultPath = strSavePath + @"Result\";

            if (!Directory.Exists(sourcePath))
            {
                Directory.CreateDirectory(sourcePath);
            }
            if (!Directory.Exists(resultPath))
            {
                Directory.CreateDirectory(resultPath);
            }

            int   count       = Directory.GetFiles(strSavePath).Length;        //1063.216
            Image originImage = Image.FromHbitmap(originBitmap.GetHbitmap());  //1221.3

            Bitmap bitmap = new Bitmap(originImage.Width, originImage.Height); //1299.576

            Graphics gTemplate = Graphics.FromImage(bitmap);

            gTemplate.DrawImage(originImage, 0, 0, new Rectangle(0, 0, originImage.Width, originImage.Height), System.Drawing.GraphicsUnit.Pixel);

            string timeNowToString = string.Format("{0}{1}{2}{3}{4}{5}{6}", DateTime.Now.Year, DateTime.Now.Month,
                                                   DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond);

            string picSourceName     = string.Format("{0}{1}_{2}_.jpg", sourcePath, count.ToString(), timeNowToString);
            string picResultFullName = string.Format("{0}{1}_{2}_.jpg", resultPath, count.ToString(), timeNowToString);

            bitmap.Save(picSourceName, System.Drawing.Imaging.ImageFormat.Jpeg);
            aqDisplay.CreateContentBitmap().Save(picResultFullName); // 1304.456

            gTemplate.Dispose();
            bitmap.Dispose();      //1225.496
            originImage.Dispose(); //1146.756
            return(true);
        }
예제 #2
0
        private void ShowGetResultsData(double[] xPointList, double[] yPointList, long[] countPointList, AqColorConstants color, AqDisplay aqDisplayShow)
        {
            Stopwatch st = new Stopwatch();

            st.Start();
            int iPointList = 0;

//             double[] centerX = new double[countPointList.Length];
//             double[] centerY = new double[countPointList.Length];
//             double PlusX = 0;
//             double PlusY = 0;

            for (int countList = 0, countSegement = 0; iPointList < xPointList.Length; iPointList++, countSegement++)
            {
//                 PlusX += xPointList[iPointList];
//                 PlusY += yPointList[iPointList];
                AqLineSegment lineSegment = new AqLineSegment();
                if ((countSegement + 1) == countPointList[countList])
                {
                    lineSegment.StartX = xPointList[iPointList];
                    lineSegment.StartY = yPointList[iPointList];

//                     //保存中心点
//                     centerX[countList] = PlusX / countPointList[countList];
//                     centerY[countList] = PlusY / countPointList[countList];
//                     PlusX = 0;
//                     PlusY = 0;

                    if (countList == 0)
                    {
                        lineSegment.EndX = xPointList[0];
                        lineSegment.EndY = yPointList[0];

                        if ((Math.Abs(xPointList[0] - xPointList[iPointList]) < 0.0001) &&
                            (Math.Abs(yPointList[0] - yPointList[iPointList]) < 0.0001))
                        {
                            lineSegment.EndX = xPointList[0];
                            lineSegment.EndY = yPointList[0];
                            countList++;
                            countSegement = -1;
                        }
                        else
                        {
                            countList++;
                            countSegement = -1;
                            continue;   //不连接
                        }
                    }
                    else
                    {
                        if ((Math.Abs(xPointList[countPointList[countList - 1]] - xPointList[iPointList]) < 0.0001) &&
                            (Math.Abs(yPointList[countPointList[countList - 1]] - yPointList[iPointList]) < 0.0001))
                        {
                            lineSegment.EndX = xPointList[countPointList[countList - 1]];
                            lineSegment.EndY = yPointList[countPointList[countList - 1]];
                            countList++;
                            countSegement = -1;
                        }
                        else
                        {
                            countList++;
                            countSegement = -1;
                            continue;
                        }
                    }
                }
                else
                {
                    lineSegment.StartX = xPointList[iPointList];
                    lineSegment.StartY = yPointList[iPointList];
                    lineSegment.EndX   = xPointList[iPointList + 1];
                    lineSegment.EndY   = yPointList[iPointList + 1];
                }
                lineSegment.Color = color;
                lineSegment.LineWidthInScreenPixels = 3;
                aqDisplayShow.InteractiveGraphics.Add(lineSegment, "AAA 11111", true);
            }
            st.Stop();
            aqDisplayShow.Update();
//             for(int i = 0; i<countPointList.Length; i++)
//             {
//                 listBox1.Items.Add(string.Format("{0}, {1}", centerX[i], centerY[i]));
//             }
            //MessageBox.Show(string.Format("{0},{1},{2} ",st.Elapsed, st.ElapsedMilliseconds, iPointList));//fortest
        }
예제 #3
0
 public void ShowGetResultsData(AqColorConstants color, AqDisplay aqDisplayShow)
 {
     ShowGetResultsData(m_Location.XldColsM, m_Location.XldRowsM, m_Location.XldPointCountsM, color, aqDisplayShow);
 }