| | |
| | | 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 => |
| | |
| | | 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, |