From e2025f1ced5ea621808eb053fb3d745ba26c0559 Mon Sep 17 00:00:00 2001 From: zqm Date: Thu, 6 Nov 2025 09:28:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0TemperatureData.cs=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Toprie/Toprie/TemperatureData.cs | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/Windows/CS/Framework4.0/Toprie/Toprie/TemperatureData.cs b/Windows/CS/Framework4.0/Toprie/Toprie/TemperatureData.cs index 2185c7b..5fa135f 100644 --- a/Windows/CS/Framework4.0/Toprie/Toprie/TemperatureData.cs +++ b/Windows/CS/Framework4.0/Toprie/Toprie/TemperatureData.cs @@ -127,7 +127,9 @@ namespace JoyD.Windows.CS.Toprie { throw new ArgumentException("数据长度不足,无法解析"); } - + + String key = $"{Width}_{Height}"; + bool hasMap = _temperatureMap.TryGetValue(key, out ConcurrentDictionary> map); // 计算温度数据长度和像素总数 int dataLength = rawData.Length - HEADER_SIZE; int pixelCount = dataLength / 2; // 每个像素2字节 @@ -161,11 +163,13 @@ namespace JoyD.Windows.CS.Toprie // 应用温度补偿值 float compensatedTemperature = rawTemperature + compensationValue; - // 原始温度存入TemperatureMatrix(未温补) - TemperatureMatrix[row, col] = rawTemperature; - - // 温补后的温度存入RealTemperatureMatrix(映射到512×384矩阵) - MapToRealTemperatureMatrix(row, col, compensatedTemperature); + // 原始温度存入TemperatureMatrix + TemperatureMatrix[row, col] = compensatedTemperature; + if (hasMap) + { + // 温补后的温度存入RealTemperatureMatrix(映射到512×384矩阵) + MapToRealTemperatureMatrix($"{col}_{row}", map, compensatedTemperature); + } } } } @@ -174,25 +178,17 @@ namespace JoyD.Windows.CS.Toprie /// /// 将原始温度数据映射到512×384的实际温度矩阵 /// - /// 源数据行索引 - /// 源数据列索引 + /// 映射键 + /// 映射表 /// 温度值 - private void MapToRealTemperatureMatrix(int sourceRow, int sourceCol, float temperature) + private void MapToRealTemperatureMatrix(String key, ConcurrentDictionary> map, float temperature) { - // 计算映射比例(从原始分辨率映射到512×384) - float rowRatio = 384.0f / Height; - float colRatio = 512.0f / Width; - - // 计算目标位置 - int targetRow = (int)(sourceRow * rowRatio); - int targetCol = (int)(sourceCol * colRatio); - - // 确保目标位置在有效范围内 - targetRow = Math.Min(383, Math.Max(0, targetRow)); - targetCol = Math.Min(511, Math.Max(0, targetCol)); - - // 设置实际温度值 - RealTemperatureMatrix[targetRow, targetCol] = temperature; + if (!map.TryGetValue(key, out List xy)) return; + for (int idx = 0; idx < xy.Count; idx += 2) + { + // 设置实际温度值 + RealTemperatureMatrix[xy[idx], xy[idx+1]] = temperature; + } } ///