From fccc60d8897642ef5c39176b8c872b63fe819ae2 Mon Sep 17 00:00:00 2001 From: xcd <834800634@qq.com> Date: 星期五, 20 十一月 2020 10:44:57 +0800 Subject: [PATCH] gocator添加int4类型数据,暂时注释 --- src/Bro.Device.Gocator/GocatorDriver.cs | 54 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/Bro.Device.Gocator/GocatorDriver.cs b/src/Bro.Device.Gocator/GocatorDriver.cs index ae21a3f..0d22a6f 100644 --- a/src/Bro.Device.Gocator/GocatorDriver.cs +++ b/src/Bro.Device.Gocator/GocatorDriver.cs @@ -66,6 +66,8 @@ } HandleGoData(dataSet); + + dataSet.Dispose(); } private void HandleGoData(GoDataSet dataSet, GoImageSet imgSet = null) @@ -88,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 => @@ -106,13 +111,32 @@ 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() { @@ -181,6 +205,8 @@ // } // break; } + + dataObj.Dispose(); } } @@ -238,6 +264,9 @@ } HandleGoData(dataSet, imgSet); + + dataSet.Dispose(); + if (imgSet.HImage == null) { LogAsync(DateTime.Now, $"{Name}鏈兘鑾峰彇HImage鍥惧儚", ""); @@ -412,6 +441,8 @@ _snapHandle.Set(); } } + + dataSet.Dispose(); } #region 閲嶅啓鍥剧墖淇濆瓨鎿嶄綔 @@ -422,7 +453,7 @@ OnImageUpdated?.Invoke(this, showImage, imgSetId); }); - GoImageSet set = _imageSetList.FirstOrDefault(u => u.Id == imgSetId) as GoImageSet; + GoImageSet set = _imageSetList[imgSetId] as GoImageSet; if (set == null) return; @@ -463,7 +494,7 @@ { await Task.Run(() => { - GoImageSet set = _imageSetList.FirstOrDefault(u => u.Id == imgSetId) as GoImageSet; + GoImageSet set = _imageSetList[imgSetId] as GoImageSet; if (set == null) return; @@ -493,19 +524,22 @@ } }); } + + public override void ClearImageSet(IImageSet set) + { + if (set.IsOriginSaved && set.IsFitSaved && set.IsAddtionalSaved) + { + (set as GoImageSet).HImage_2?.Dispose(); + (set as GoImageSet).HImage_2 = null; + } + + base.ClearImageSet(set); + } #endregion } public class GoImageSet : ImageSet { public HImage HImage_2 { get; set; } - - public override void Dispose() - { - base.Dispose(); - - HImage_2?.Dispose(); - HImage_2 = null; - } } } -- Gitblit v1.8.0