示例#1
0
        private void btncenter_Click(object sender, EventArgs e)
        {
            if (captureImagesNow.Count <= 0 || userControlMutiDicomImages.SelectedIndex >= captureImagesNow.Count)
            {
                return;
            }
            if (CalibrationType == "CENTER")
            {
                this.Cursor     = Cursors.Default;
                CalibrationType = "NONE";
            }
            else
            {
                this.Cursor     = Cursors.Cross;
                CalibrationType = "CENTER";
            }
            ImageObject img = captureImagesNow[userControlMutiDicomImages.SelectedIndex];

            RefreshImage(img);
        }
示例#2
0
        void cImage_LutMouseUp(int ChangedType, object ChangedObject, Color[] LUT)
        {
            if (captureImagesNow.Count <= 0 || userControlMutiDicomImages.SelectedIndex >= captureImagesNow.Count)
            {
                return;
            }

            ImageObject img = captureImagesNow[userControlMutiDicomImages.SelectedIndex];

            if (ChangedType == 0)
            {
                img.level  = ((Point)ChangedObject).X;
                img.window = ((Point)ChangedObject).Y;
            }
            else if (ChangedType == 1)
            {
                img.converse = (bool)ChangedObject;
            }
            else if (ChangedType == 2)
            {
                img.colorModeName = (string)ChangedObject;
            }
            userControlMutiDicomImages.DrawImagesInPane(GetSmallBitmapList(captureImagesNow), false);
        }
示例#3
0
        private void pictureBox1_MouseWheel(object sender, MouseEventArgs e)
        {
            if (captureImagesNow.Count <= 0 || userControlMutiDicomImages.SelectedIndex >= captureImagesNow.Count)
            {
                return;
            }
            float scale = myMatrix.Elements[0];
            bool  toBig = (e.Delta > 0);

            if ((toBig && scale >= ScaleMax) || (!toBig && scale <= ScaleMin))
            {
                return; //超过缩放限制后不再继续
            }
            float k         = toBig ? 1.1f : 0.9f;
            float tempScale = scale * k;

            if (tempScale > ScaleMax)
            {
                tempScale = ScaleMax;
            }
            else if (tempScale < ScaleMin)
            {
                tempScale = ScaleMin;
            }
            //float defaultScale = Math.Min(imgPictureBox.Width / (float)ctWidth, imgPictureBox.Height / (float)ctHeight);
            PointF pCenter  = new PointF((float)e.X, (float)e.Y);
            Matrix mxInvert = (Matrix)myMatrix.Clone();

            mxInvert.Invert();
            PointF[] pts = new PointF[1] {
                pCenter
            };
            mxInvert.TransformPoints(pts);
            pCenter = pts[0];
            if (pCenter.IsEmpty)
            {
                return;
            }
            pts = new PointF[1] {
                pCenter
            };
            myMatrix.TransformPoints(pts);
            PointF pt1 = pts[0];

            myMatrix.Scale(k, k);
            pts[0] = pCenter;
            myMatrix.TransformPoints(pts);
            PointF pt2 = pts[0];
            float  dx  = pt1.X - pt2.X;
            float  dy  = pt1.Y - pt2.Y;

            myMatrix.Translate(dx, dy, MatrixOrder.Append);

            ImageObject img     = captureImagesNow[userControlMutiDicomImages.SelectedIndex];
            Bitmap      bmpTemp = ImageAfterZoom(img.LUT[0], srcBitmap);

            if (CalibrationType == "CENTER")
            {
                Graphics g     = Graphics.FromImage(bmpTemp);
                Brush    brush = new SolidBrush(Color.Red);
                Pen      pen   = new Pen(Color.Red, 1);
                g.DrawLine(pen, new Point(0, e.Location.Y), new Point(bmpTemp.Width, e.Location.Y));
                g.DrawLine(pen, new Point(e.Location.X, 0), new Point(e.Location.X, bmpTemp.Height));
                g.Dispose();
            }
            pictureBox1.Image = bmpTemp;
            pictureBox1.Refresh();
        }
示例#4
0
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                switch (CalibrationType)
                {
                case "LENGTH":
                {
                    if (captureImagesNow.Count <= 0 || userControlMutiDicomImages.SelectedIndex >= captureImagesNow.Count)
                    {
                        return;
                    }

                    ImageObject img      = captureImagesNow[userControlMutiDicomImages.SelectedIndex];
                    Point       p        = e.Location;
                    Matrix      mxInvert = (Matrix)myMatrix.Clone();
                    mxInvert.Invert();
                    Point[] ps = new Point[] { p };
                    mxInvert.TransformPoints(ps);
                    endP = new Point(ps[0].X, ps[0].Y);
                    UserControlCalibrationLength ctrl = new UserControlCalibrationLength();
                    if (ShowBaseForm.ShowControlDialog(ctrl) == DialogResult.OK)
                    {
                        float len         = ctrl.length;
                        float pixelLen    = (float)Math.Sqrt((float)((startP.X - endP.X) * (startP.X - endP.X) + (startP.Y - endP.Y) * (startP.Y - endP.Y)));
                        float SAD         = float.Parse(textBoxSAD.Text.Trim());
                        float panelSize   = float.Parse(textBoxPhysicsWidth.Text.Trim());
                        float setupHeight = (float)((SAD * (panelSize / img.imageWidth) * pixelLen) / len);
                        setupHeight = float.Parse(setupHeight.ToString("0.0"));
                        if (cls_MessageBox.Show("Will you apply setup height " + setupHeight + "(mm)?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            textBoxSetupHeight.Text = setupHeight.ToString();
                            CapturePub.saveCaptrueValue("SetupHeight", setupHeight.ToString());
                        }
                    }
                }
                break;

                case "CENTER":
                {
                    if (captureImagesNow.Count <= 0 || userControlMutiDicomImages.SelectedIndex >= captureImagesNow.Count)
                    {
                        return;
                    }
                    ImageObject img      = captureImagesNow[userControlMutiDicomImages.SelectedIndex];
                    Point       p        = e.Location;
                    Matrix      mxInvert = (Matrix)myMatrix.Clone();
                    mxInvert.Invert();
                    Point[] ps = new Point[] { p };
                    mxInvert.TransformPoints(ps);
                    Point originalPoint = new Point(ps[0].X, ps[0].Y);
                    Point imageCenter   = new Point(512, 512);
                    float offsetX       = (originalPoint.X - imageCenter.X) * (float.Parse(textBoxPhysicsWidth.Text.Trim()) / img.imageWidth);   // panel上的偏移距离
                    float offsetY       = (originalPoint.Y - imageCenter.Y) * (float.Parse(textBoxPhysicsWidth.Text.Trim()) / img.imageWidth);
                    offsetX = float.Parse(offsetX.ToString("0.0"));
                    offsetY = float.Parse(offsetY.ToString("0.0"));
                    if (cls_MessageBox.Show("Will you apply center offset value X:" + offsetX + ",Y:" + offsetY + "(mm)?", "Confirm", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        textBoxImageCenterX.Text = offsetX.ToString();
                        CapturePub.saveCaptrueValue("ImageCenterX", offsetX.ToString());
                        textBoxImageCenterY.Text = offsetY.ToString();
                        CapturePub.saveCaptrueValue("ImageCenterY", offsetY.ToString());
                    }
                }
                break;

                case "NONE":
                    break;
                }
            }
            else if (e.Button == MouseButtons.Right)
            {
                if (CalibrationType == "LENGTH")
                {
                    this.Cursor = DistanceCursor;
                }
                else if (CalibrationType == "CENTER")
                {
                    this.Cursor = Cursors.Cross;
                }
                else
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
示例#5
0
        private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (userControlMutiDicomImages.Num <= 0 || userControlMutiDicomImages.SelectedIndex < 0)
            {
                return;
            }
            Point  p        = e.Location;
            Matrix mxInvert = (Matrix)myMatrix.Clone();

            mxInvert.Invert();
            Point[] ps = new Point[] { p };
            mxInvert.TransformPoints(ps);
            labelAxis.Text = "X=" + ps[0].X + ",Y=" + ps[0].Y;
            int index = userControlMutiDicomImages.SelectedIndex;

            ushort[,] data = captureImagesNow[index].ImageData;
            if (ps[0].X < 0 || ps[0].Y < 0 || ps[0].X >= data.GetLength(1) || ps[0].Y >= data.GetLength(0))
            {
                labelAxis.Text       = "";
                labelImageValue.Text = "";
                return;
            }
            ushort v = data[ps[0].Y, ps[0].X];

            //labelImageValue.Text = v.ToString();
            labelImageValue.Text = " Value:" + v.ToString();

            if (e.Button == MouseButtons.Left && startP != Point.Empty && CalibrationType == "LENGTH")
            {
                ImageObject img     = captureImagesNow[userControlMutiDicomImages.SelectedIndex];
                Bitmap      bmpTemp = ImageAfterZoom(img.LUT[0], srcBitmap);

                Graphics g     = Graphics.FromImage(bmpTemp);
                Brush    brush = new SolidBrush(Color.Red);
                Pen      pen   = new Pen(Color.Red, 1);
                Point[]  Pt    = new Point[] { new Point(startP.X, startP.Y) };
                myMatrix.TransformPoints(Pt);
                g.DrawLine(pen, Pt[0], e.Location);
                pictureBox1.Image = bmpTemp;
                g.Dispose();
                pictureBox1.Refresh();
            }
            else if (e.Button == MouseButtons.Right)
            {
                ImageObject img = captureImagesNow[userControlMutiDicomImages.SelectedIndex];
                float       dx  = e.X - movePoint.X;
                float       dy  = e.Y - movePoint.Y;
                if (dx == 0 && dy == 0)
                {
                    return;
                }
                myMatrix.Translate(dx, dy, MatrixOrder.Append);
                movePoint = e.Location;
                RefreshImage(img);
            }
            else if (CalibrationType == "CENTER")
            {
                ImageObject img     = captureImagesNow[userControlMutiDicomImages.SelectedIndex];
                Bitmap      bmpTemp = ImageAfterZoom(img.LUT[0], srcBitmap);

                Graphics g     = Graphics.FromImage(bmpTemp);
                Brush    brush = new SolidBrush(Color.Red);
                Pen      pen   = new Pen(Color.Red, 1);
                g.DrawLine(pen, new Point(0, e.Location.Y), new Point(bmpTemp.Width, e.Location.Y));
                g.DrawLine(pen, new Point(e.Location.X, 0), new Point(e.Location.X, bmpTemp.Height));
                pictureBox1.Image = bmpTemp;
                g.Dispose();
                pictureBox1.Refresh();
            }
        }
示例#6
0
        private void cbAngle_SelectedIndexChanged(object sender, EventArgs e)
        {
            string xmlValue = CapturePub.readCaptrueValue("SetupAngle");
            int    idx1     = cbAngle.Items.IndexOf(xmlValue);

            if (idx1 < 0)
            {
                idx1 = 0;
            }
            int SetupAngle = (cbAngle.SelectedIndex - idx1) * 90;

            ImgCapture.SetupAngle = int.Parse(cbAngle.Text.Trim());
            CapturePub.saveCaptrueValue("SetupAngle", cbAngle.Text);

            if (captureImagesNow == null || captureImagesNow.Count <= 0)
            {
                return;
            }
            if (SetupAngle % 90 != 0 || SetupAngle % 360 == 0)
            {
                return;
            }

            while (SetupAngle < 0)
            {
                SetupAngle += 360;
            }

            for (int n = 0; n < captureImagesNow.Count; n++)
            {
                int          idx        = SetupAngle / 90;
                int          r          = captureImagesNow[n].ImageData.GetLength(0);
                int          c          = captureImagesNow[n].ImageData.GetLength(1);
                List <int[]> COUNTANGLE = new List <int[]> {
                    new int[5] {
                        1, -1, 1, c - 1, 0
                    },
                    new int[5] {
                        0, -1, -1, r - 1, c - 1
                    },
                    new int[5] {
                        1, 1, -1, 0, r - 1
                    },
                    new int[5] {
                        0, 1, -1, 0, c - 1
                    },
                    new int[5] {
                        0, -1, 1, r - 1, 0
                    }
                };                                      //[exchange,scaleX,scaleY,offX,offY]
                int[] ca = COUNTANGLE[idx - 1];
                ushort[,] temp = new ushort[r, c];
                if (ca[0] == 1)
                {
                    for (int i = 0; i < r; i++)
                    {
                        for (int j = 0; j < c; j++)
                        {
                            temp[i, j] = captureImagesNow[n].ImageData[j * ca[1] + ca[3], i *ca[2] + ca[4]];
                        }
                    }
                    captureImagesNow[n].ImageData = (ushort[, ])temp.Clone();
                }
                else
                {
                    for (int i = 0; i < r; i++)
                    {
                        for (int j = 0; j < c; j++)
                        {
                            temp[i, j] = captureImagesNow[n].ImageData[i * ca[1] + ca[3], j *ca[2] + ca[4]];
                        }
                    }
                    captureImagesNow[n].ImageData = (ushort[, ])temp.Clone();
                }
            }
            if (userControlMutiDicomImages.Num <= 0)
            {
                return;
            }
            else
            {
                int index = userControlMutiDicomImages.SelectedIndex;
                if (index >= userControlMutiDicomImages.Num || index < 0)
                {
                    index = 0;
                }
                userControlMutiDicomImages.DrawImagesInPane(GetSmallBitmapList(captureImagesNow), index);
                ImageObject img = captureImagesNow[index];
                srcBitmap = img.BMP;
                RefreshImage(img);
            }
        }
        private void ReadFile(string file)
        {
            //TiffReader tiff = new TiffReader();
            //IOD_RI RI = new IOD_RI();
            HisObject His = new HisObject();
            //IOD_RD RD = new IOD_RD();
            ImageObject img = new ImageObject();

            //if (tiff.ReadFile(file))
            //{
            //    imageRows = (uint)tiff.ImageHegiht;
            //    imageColumns = (uint)tiff.ImageWidth;
            //    RefreshScale();

            //    img.pixelSize = pixelSize;
            //    img.centerX = imageCenterX;
            //    img.centerY = imageCenterY;
            //    ushort[,] image = new ushort[tiff.ImageHegiht, tiff.ImageWidth];
            //    int sn = 0;
            //    for (int y = 0; y < tiff.ImageHegiht; y++)
            //    {
            //        for (int x = 0; x < tiff.ImageWidth; x++)
            //        {
            //            image[y, x] = tiff.Value[sn++];
            //        }
            //    }
            //    img.imageData = image;
            //    img.createTime = DateTime.Now;
            //    imgList.Add(img);
            //}
            //if (RI.OpenFromFile(file))
            //{
            //    img.pixelSize = RI.RIImage.ImagePlanePixelSpacing[0];
            //    img.centerX = -RI.RIImage.RTImagePosition[0] / RI.RIImage.ImagePlanePixelSpacing[0];
            //    img.centerY = RI.RIImage.RTImagePosition[1] / RI.RIImage.ImagePlanePixelSpacing[1];
            //    img.level = (int)RI.RIImage.WindowCenter;
            //    img.window = (int)RI.RIImage.WindowWidth;
            //    img.imageHeight = RI.ImagePixel.PixelData.GetLength(0);
            //    img.imageWidth = RI.ImagePixel.PixelData.GetLength(1);
            //    ushort[,] image = new ushort[img.imageHeight, img.imageWidth];
            //    short[,] dv = RI.ImagePixel.PixelData;
            //    for (int y = 0; y < img.imageHeight; y++)
            //    {
            //        for (int x = 0; x < img.imageWidth; x++)
            //        {
            //            image[y,x] = (ushort)dv[y,x];
            //        }
            //    }
            //    img.imageData = image;
            //    imgList.Add(img);
            //    GC.Collect();
            //}
            if (His.LoadDataFromFile(file))
            {
                if (His.dataList != null)
                {
                    for (int i = 0; i < His.dataList.Count; i++)
                    {
                        ImageObject imageObj = new ImageObject();

                        imageObj.ImageData = His.dataList[i];
                        imageRows          = (uint)imageObj.ImageData.GetLength(0);
                        imageColumns       = (uint)imageObj.ImageData.GetLength(1);
                        RefreshScale();
                        imageObj.pixelSize = pixelSize;
                        imageObj.centerX   = imageCenterX;
                        imageObj.centerY   = imageCenterY;
                        imgList.Enqueue(imageObj);
                    }
                    His.dataList = null;
                    GC.Collect();
                }
            }
            //else if (RD.OpenFromFile(file))//增加RD图像,2011.12.15,ml
            //{

            //    //img.level = 4590;
            //    //img.window = 10000;
            //    if (RD.RD.PixelData.Length > 0)
            //    {
            //        img.pixelSize = RD.RD.PixelSpacing;
            //        img.imageWidth = RD.RD.PixelData[0].GetLength(1);
            //        img.imageHeight = RD.RD.PixelData[0].GetLength(0);
            //        img.centerX = img.imageWidth / 2; //-RDF.fra.ImagePosition[0] / PixelSize;
            //        img.centerY = img.imageHeight / 2;//RDF.fra.ImagePosition[1] / PixelSize;
            //        img.SliceDepth = RD.RD.ImagePosition[1];

            //        ushort[,] image = new ushort[img.imageHeight, img.imageWidth];

            //        UInt32[,] rd = RD.RD.PixelData[0];
            //        for (int i = 0; i < img.imageHeight; i++)
            //        {
            //            for (int j = 0; j < img.imageWidth; j++)
            //            {
            //                image[i, j] = Convert.ToUInt16(rd[i, j] * RD.RD.DoseGridScaling * 1000F);
            //            }
            //        }
            //        img.imageData = image;
            //        imgList.Add(img);
            //        GC.Collect();
            //    }
            //}
            //else
            //{
            //    try
            //    {
            //        //Bitmap bm = new Bitmap(file);
            //        //LWList.Add(new Point(-1, -1));
            //        //imgList.Add(BitmapToUShort(bm));
            //        //pixelSize = phySize / imgList[0].GetLength(0);
            //        //imageCenterX = phyCenterX / pixelSize;
            //        //imageCenterY = phyCenterY / pixelSize;
            //    }
            //    catch (System.Exception ex)
            //    {
            //        ;
            //    }
            //}
        }
示例#8
0
        void drocEventCallback(int eventID, ref CareRayInterface.EventData eventData)
        {
            Console.WriteLine("Event ID:" + eventID);

            switch (eventID)
            {
            case (int)CareRayInterface.event_id.EVT_DISCONNECT:
            case (int)CareRayInterface.event_id.EVT_DETECTOR_ERROR:
            {
                int result = CareRayInterface.CR_stop_acq_frame();
                if ((int)KZ_ERROR_TYPE.CR_NO_ERR != result)
                {
                    Console.WriteLine("CR_stop_acq_frame error, reason: {0}\n", CareRayErrors.CrErrStrList(result));
                }
            }
            break;

            case (int)CareRayInterface.event_id.EVT_IMAGE_ARRIVE:
            case (int)CareRayInterface.event_id.EVT_VIDEO_FRAME_INDEX_CHANGED:
            {
                //外部中断Cancel();立即退出;
                if (!WorkStatus)
                {
                    Kernel32Interface.PostMessage(HostHandle, WIN_MSG.WM_CAPTURE_WORKSTATUS, 0, 0);
                    Kernel32Interface.PostMessage(HostHandle, WIN_MSG.WM_SHOW_PROGRESS, -2, 0);
                    WorkStatus = false;
                    return;
                }

                //用于判断采集是否结束
                acqImageNuber--;

                //改变采集到的帧数统计;
                acqBrightImageNumber++;
                //输出亮场帧数统计信息;
                Console.WriteLine("Image Number=" + acqBrightImageNumber);

                //Windows界面输出采集进度;
                int msgID = GenerateWinMessage("Capturing image number:" + acqBrightImageNumber);
                Kernel32Interface.PostMessage(HostHandle, WIN_MSG.WM_SHOW_PROGRESS, msgID, 0);


                #region Step(1):TCP/IP协议网络从Panel缓冲区取出图像;

                DateTime tm           = DateTime.Now; //log
                int      imageSize    = eventData.width * eventData.height * eventData.bits / 8;
                int      imageRows    = eventData.height;
                int      imageColumns = eventData.width;

                ushort *imageData = (ushort *)eventData.data;

                #region 验证是否丢帧

                IntPtr checkPtr = (IntPtr)imageData;
                int    imageID  = Marshal.ReadInt32(checkPtr, 0);
                if (imageID != ImageTrackID)
                {
                    Console.WriteLine("!!!!!!!!!!!!!!!!!!!!!lost frame ID=" + imageID);
                }

                ImageTrackID = imageID;
                ImageTrackID++;

                #endregion



                Console.WriteLine("Step(1):(TCP/IP)Transfer image time=" + (DateTime.Now - tm));        //log
                #endregion

                #region Step(2)封装数据到对象ImageObject

                tm = DateTime.Now;

                RefreshScale();

                ImageObject imageObjectBase = new ImageObject();

                ushort[,] imagedata = BufferToArray(imageData, RawFileHeadSize, imageRows, imageColumns);

                imageObjectBase.pixelSize  = this.pixelSize;
                imageObjectBase.centerX    = this.imageCenterX;
                imageObjectBase.centerY    = this.imageCenterY;
                imageObjectBase.ImageData  = imagedata;
                imageObjectBase.createTime = DateTime.Now;

                Console.WriteLine("Encapsulate image data to ImageROI time=" + (DateTime.Now - tm));        //log
                #endregion



                #region Step(3):将采集到的数据ImageROI对象压入到堆栈中供异步处理

                //压入堆栈;
                imgList.Enqueue(imageObjectBase);
                //发送消息到采集界面;保存数据库;
                Kernel32Interface.PostMessage(HostHandle, WIN_MSG.WM_CAPTURE_DATA, (int)captureImageMode, acqBrightImageNumber);
                #endregion

                //判断采集是否结束
                if (acqImageNuber == 0)
                {
                    Cancel();
                    return;
                }
            }
            break;

            default:
                Console.WriteLine("Rad image transmission complete default");
                break;
            }
        }
示例#9
0
        private void timerGenerateImage_Elapsed(object sender, ElapsedEventArgs e)
        {
            seqenceNum++;
            if (captureImageMode == CapturePKI.PanelCaptureMode.Sequence)
            {
                Kernel32Interface.SendMessage(HostHandle, WIN_MSG.WM_SHOW_PROGRESS, -1, 1);
                Bitmap   bm = new Bitmap(imageColumns, imageRows);
                Graphics g  = Graphics.FromImage(bm);
                g.FillRectangle(new SolidBrush(Color.Black), 0, 0, bm.Width, bm.Height);
                Font font = new Font(FontFamily.GenericSansSerif, 800, FontStyle.Bold);
                g.DrawString(seqenceNum.ToString(), font, new SolidBrush(Color.White), new PointF(0, 0));

                ImageObject image = new ImageObject();
                image.pixelSize   = pixelSize;
                image.imageData   = BitmapToUShort(bm);
                image.imageWidth  = image.imageData.GetLength(1);
                image.imageHeight = image.imageData.GetLength(0);
                image.centerX     = imageCenterX;
                image.centerY     = imageCenterY;
                image.createTime  = DateTime.Now;
                imgList.Add(image);
                if (seqenceNum == FrameCount)
                {
                    Kernel32Interface.SendMessage(HostHandle, WIN_MSG.WM_CAPTURE_DATA, (int)captureImageMode, 0);
                    timerGenerateImage.Stop();
                    WorkStatus = false;
                    Kernel32Interface.SendMessage(HostHandle, WIN_MSG.WM_SHOW_PROGRESS, -2, 0);
                    Kernel32Interface.SendMessage(HostHandle, WIN_MSG.WM_CAPTURE_WORKSTATUS, 0, 0);
                }
            }
            else if (captureImageMode == CapturePKI.PanelCaptureMode.Continuous)
            {
                Bitmap   bm = new Bitmap(imageColumns, imageRows);
                Graphics g  = Graphics.FromImage(bm);
                g.FillRectangle(new SolidBrush(Color.Black), 0, 0, bm.Width, bm.Height);
                Font font = new Font(FontFamily.GenericSansSerif, 800, FontStyle.Bold);
                g.DrawString(seqenceNum.ToString(), font, new SolidBrush(Color.White), new PointF(0, 0));

                ImageObject image = new ImageObject();
                image.pixelSize   = pixelSize;
                image.imageData   = BitmapToUShort(bm);
                image.imageWidth  = image.imageData.GetLength(1);
                image.imageHeight = image.imageData.GetLength(0);
                image.centerX     = imageCenterX;
                image.centerY     = imageCenterY;
                image.createTime  = DateTime.Now;
                imgList.Add(image);
                Kernel32Interface.SendMessage(HostHandle, WIN_MSG.WM_CAPTURE_DATA, (int)captureImageMode, 0);
            }
            //else if (captureImageMode == CapturePKI.PanelCaptureMode.Average)
            //{
            //    //PKL_Interface.Acquisition_DefineDestBuffers(hAcqDesc, pAcqBufferAverage, (uint)FrameCount, imageRows, imageColumns);
            //    //PKL_Interface.Acquisition_Acquire_Image(hAcqDesc, (uint)FrameCount, 0, (uint)SeqBufferMode.HIS_SEQ_AVERAGE, pOffsetBuffer, null, null);
            //    //Kernel32Interface.SendMessage(HostHandle, WIN_MSG.WM_SHOW_PROGRESS, msgID, FrameCount);
            //}
            else if (captureImageMode == CapturePKI.PanelCaptureMode.DoubleExposure)
            {
                //beamON_Num++;
                //PKL_Interface.Acquisition_DefineDestBuffers(hAcqDesc, pAcqBuffer, (uint)FrameCount, imageRows, imageColumns);
                //PKL_Interface.Acquisition_Acquire_Image(hAcqDesc, (uint)FrameCount, 0, (uint)SeqBufferMode.HIS_SEQ_ONE_BUFFER, null, null, null);
                //Kernel32Interface.SendMessage(HostHandle, WIN_MSG.WM_SHOW_PROGRESS, msgID, 0);
            }
        }
示例#10
0
        public void RotateImage(ImageObject image)
        {
            if (image == null)
            {
                return;
            }
            if (SetupAngle % 90 != 0 || SetupAngle % 360 == 0)
            {
                return;
            }

            while (SetupAngle < 0)
            {
                SetupAngle += 360;
            }
            int          idx        = SetupAngle / 90;
            int          r          = image.ImageData.GetLength(0);
            int          c          = image.ImageData.GetLength(1);
            List <int[]> COUNTANGLE = new List <int[]> {
                new int[5] {
                    1, -1, 1, c - 1, 0
                },
                new int[5] {
                    0, -1, -1, r - 1, c - 1
                },
                new int[5] {
                    1, 1, -1, 0, r - 1
                },
                new int[5] {
                    0, 1, -1, 0, c - 1
                },
                new int[5] {
                    0, -1, 1, r - 1, 0
                }
            };                                          //[exchange,scaleX,scaleY,offX,offY]

            int[] ca = COUNTANGLE[idx - 1];
            ushort[,] temp = new ushort[r, c];
            if (ca[0] == 1)
            {
                for (int i = 0; i < r; i++)
                {
                    for (int j = 0; j < c; j++)
                    {
                        temp[i, j] = image.ImageData[j * ca[1] + ca[3], i *ca[2] + ca[4]];
                    }
                }
                image.ImageData = temp;
            }
            else
            {
                for (int i = 0; i < r; i++)
                {
                    for (int j = 0; j < c; j++)
                    {
                        temp[i, j] = image.ImageData[i * ca[1] + ca[3], j *ca[2] + ca[4]];
                    }
                }
                image.ImageData = temp;
            }
        }