| | |
| | | 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); |
| | | |
| | | //没有插值,默认0 |
| | | //Parallel.For(0, height, h => |
| | | // { |
| | | // CopyMemory((IntPtr)((long)zoomPtr + width * 2 * Math.Floor(h * zoomFactor)), (IntPtr)((long)bufferPointer + width * 2 * h), width * 2); |
| | | // }); |
| | | |
| | | //使用上一行原有数据 |
| | | Parallel.For(0, zoomHeight, h => |
| | | { |
| | | int originHeightIndex = (int)Math.Floor((double)height * h / (double)zoomHeight); |
| | | |
| | | CopyMemory((IntPtr)((long)zoomPtr + width * 2 * h), (IntPtr)((long)bufferPointer + width * 2 * originHeightIndex), width * 2); |
| | | }); |
| | | |
| | | if (imgSet != null) |
| | | { |
| | | imgSet.HImage = new HImage(); |
| | | imgSet.HImage.GenImage1("uint2", (int)width, (int)height, bufferPointer); |
| | | imgSet.HImage.GenImage1("uint2", (int)width, zoomHeight, zoomPtr); |
| | | //imgSet.HImage = imgSet.HImage.ZoomImageSize((int)width, zoomHeight, "constant"); |
| | | |
| | | |
| | | imgSet.HImage_2 = new HImage(); |
| | | imgSet.HImage_2.GenImage1("uint2", (int)width, (int)height, bufferPointer); |
| | | imgSet.HImage_2.GenImage1("uint2", (int)width, zoomHeight, zoomPtr); |
| | | |
| | | //imgSet.HImage_2 = imgSet.HImage_2.ZoomImageSize((int)width, zoomHeight, "constant"); |
| | | } |
| | | |
| | | Generate16GrayImageByPointer((int)width, (int)height, bufferPointer, imgSet?.Id); |
| | | Generate16GrayImageByPointer((int)width, zoomHeight, zoomPtr, imgSet?.Id).ContinueWith(t => |
| | | { |
| | | Marshal.FreeHGlobal(zoomPtr); |
| | | }); |
| | | |
| | | //int zoomHeight = (int)(((double)surfaceMsg.YResolution / (double)surfaceMsg.XResolution) * (double)surfaceMsg.Length); |
| | | |
| | | //if (imgSet != null) |
| | | //{ |
| | | // imgSet.HImage = new HImage(); |
| | | // imgSet.HImage.GenImage1("uint2", (int)width, (int)height, bufferPointer); |
| | | // imgSet.HImage = imgSet.HImage.ZoomImageSize((int)width, zoomHeight, "constant"); |
| | | |
| | | |
| | | // imgSet.HImage_2 = new HImage(); |
| | | // imgSet.HImage_2.GenImage1("uint2", (int)width, (int)height, bufferPointer); |
| | | |
| | | // imgSet.HImage_2 = imgSet.HImage_2.ZoomImageSize((int)width, zoomHeight, "constant"); |
| | | //} |
| | | |
| | | //Generate16GrayImageByPointer((int)width, (int)height, bufferPointer, imgSet?.Id); |
| | | } |
| | | break; |
| | | //case GoDataMessageType.SurfaceIntensity: |
| | | // { |
| | | // GoSurfaceIntensityMsg surfaceMsg = (GoSurfaceIntensityMsg)dataObj; |
| | | // long width = surfaceMsg.Width; |
| | | // long height = surfaceMsg.Length; |
| | | // long bufferSize = width * height; |
| | | // IntPtr bufferPointer = surfaceMsg.Data; |
| | | |
| | | // //int zoomHeight = (surfaceMsg.YResolution * (int)surfaceMsg.Length * 10) / surfaceMsg.XResolution; |
| | | |
| | | // int zoomHeight = (int)(((double)surfaceMsg.YResolution / (double)surfaceMsg.XResolution) * (double)surfaceMsg.Length); |
| | | |
| | | // if (imgSet != null) |
| | | // { |
| | | // imgSet.HImage = new HImage(); |
| | | // imgSet.HImage.GenImage1("uint2", (int)width, (int)height, bufferPointer); |
| | | // imgSet.HImage = imgSet.HImage.ZoomImageSize((int)width, zoomHeight, "constant"); |
| | | |
| | | |
| | | // imgSet.HImage_2 = new HImage(); |
| | | // imgSet.HImage_2.GenImage1("uint2", (int)width, (int)height, bufferPointer); |
| | | |
| | | // imgSet.HImage_2 = imgSet.HImage_2.ZoomImageSize((int)width, zoomHeight, "constant"); |
| | | // } |
| | | |
| | | // Generate16GrayImageByPointer((int)width, (int)height, bufferPointer, imgSet?.Id); |
| | | // } |
| | | // break; |
| | | } |
| | | } |
| | | } |
| | |
| | | public override async void SaveOriginImage(Bitmap map, Bitmap showImage, string imgSetId) |
| | | { |
| | | Task.Run(() => |
| | | { |
| | | OnImageUpdated?.Invoke(this, showImage, imgSetId); |
| | | }); |
| | | { |
| | | OnImageUpdated?.Invoke(this, showImage, imgSetId); |
| | | }); |
| | | |
| | | GoImageSet set = _imageSetList.FirstOrDefault(u => u.Id == imgSetId) as GoImageSet; |
| | | |