领胜LDS 键盘AOI检测项目
xcd
2020-11-20 fccc60d8897642ef5c39176b8c872b63fe819ae2
src/Bro.Device.Gocator/GocatorDriver.cs
@@ -90,9 +90,12 @@
                            long bufferSize = width * height;
                            IntPtr bufferPointer = surfaceMsg.Data;
                            float zoomFactor = (float)((double)surfaceMsg.YResolution / (double)surfaceMsg.XResolution);
                            int zoomHeight = (int)(zoomFactor * height);
                            IntPtr zoomPtr = Marshal.AllocHGlobal(zoomHeight * (int)width * 2);
                            //IntPtr zoomPtr = Marshal.AllocHGlobal(zoomHeight * (int)width * 4);
                            //没有插值,默认0
                            //Parallel.For(0, height, h =>
@@ -108,14 +111,33 @@
                                CopyMemory((IntPtr)((long)zoomPtr + width * 2 * h), (IntPtr)((long)bufferPointer + width * 2 * originHeightIndex), width * 2);
                            });
                            ////使用上一行原有数据
                            //Parallel.For(0, zoomHeight, h =>
                            //{
                            //    int originHeightIndex = (int)Math.Floor((double)height * h / (double)zoomHeight);
                            //    byte[] rowBuffer = new byte[width * 4];
                            //    Parallel.For(0, width, w =>
                            //    {
                            //        rowBuffer[w * 4 + 2] = Marshal.ReadByte(bufferPointer, (int)(width * 2 * originHeightIndex + w * 2));
                            //        rowBuffer[w * 4 + 3] = Marshal.ReadByte(bufferPointer, (int)(width * 2 * originHeightIndex + w * 2 + 1));
                            //    });
                            //    Marshal.Copy(rowBuffer, 0, (IntPtr)((long)zoomPtr + width * 2 * h), rowBuffer.Length);
                            //});
                            if (imgSet != null)
                            {
                                imgSet.HImage = new HImage();
                                imgSet.HImage.GenImage1("uint2", (int)width, zoomHeight, zoomPtr);
                                //imgSet.HImage.GenImage1("int4", (int)width, zoomHeight, zoomPtr);
                                imgSet.HImage_2 = new HImage();
                                imgSet.HImage_2.GenImage1("uint2", (int)width, zoomHeight, zoomPtr);
                                //imgSet.HImage_2.GenImage1("int4", (int)width, zoomHeight, zoomPtr);
                                LaserScanParam para = new LaserScanParam()
                                {
                                    Resolution_X = surfaceMsg.XResolution,