From 2cca43048718536c991d6095fa22c0d87e5e24d5 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期五, 19 七月 2024 20:22:54 +0800
Subject: [PATCH] 1

---
 SimuTools/Tools/Handle.cs |   30 +++++++++++-------------------
 1 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/SimuTools/Tools/Handle.cs b/SimuTools/Tools/Handle.cs
index 6ff3f22..24b36b6 100644
--- a/SimuTools/Tools/Handle.cs
+++ b/SimuTools/Tools/Handle.cs
@@ -5,7 +5,6 @@
 using System;
 using System.Collections.Generic;
 using System.Configuration;
-using System.Data;
 using System.Diagnostics;
 using System.Drawing;
 using System.IO;
@@ -41,7 +40,7 @@
             CopeFlow(flowPath, outPath, layer);
             CopeLayerJson(outPath, layer);
 
-            //if (Directory.Exists(temp)) Directory.Delete(temp, true);
+            if (Directory.Exists(temp)) Directory.Delete(temp, true);
         }
 
         /// <summary>
@@ -91,14 +90,6 @@
 
             foreach (int[] sizes in layer.terrain.size)
             {
-                //string filePath = Path.Combine(outPath, sizes[0] + "_" + sizes[1] + ".png");
-                //// 濉厖鍐呭瓨鍥惧儚
-                //byte[] buffer = new byte[sizes[0] * sizes[1] * 3];
-                //for (int i = 0; i < buffer.Length; i++)
-                //{
-                //    buffer[i] = (byte)(i % 256);
-                //}
-
                 string tif = Path.Combine(tempPath, DateTime.Now.Ticks.ToString() + ".tif");
                 Resample(ds.GetDescription(), tif, sizes[0], sizes[1]);
                 if (!File.Exists(tif))
@@ -178,28 +169,30 @@
                 band.ReadRaster(0, 0, width, height, buffer, width, height, 0, 0);
 
                 Bitmap image = new Bitmap(width, height);
-                //Graphics graphic = Graphics.FromImage(image);
-                //graphic.Clear(Color.Transparent); // 濉厖閫忔槑鑹�
+                Graphics graphic = Graphics.FromImage(image);
+                graphic.Clear(Color.Transparent); // 濉厖閫忔槑鑹�
 
-                double perHeight = (layer.extension.maxHeight - layer.extension.minHeight) * 100 / 65536;
+                //double perHeight = (layer.extension.maxHeight - layer.extension.minHeight) * 100 / 65536;
+                //int val = Convert.ToInt32(buffer[x * y]* 100); //Convert.ToInt32((buffer[x * y] - layer.extension.minHeight) * 100);
+                //int val = Convert.ToInt32((buffer[x * y] - layer.extension.minHeight) * 100 / perHeight);
 
                 for (int x = 0; x < width; x++)
                 {
                     for (int y = 0; y < height; y++)
                     {
-                        if (float.IsNaN(buffer[x * y]) || buffer[x * y] == -9999)
+                        int offset = x + y * height;
+                        if (float.IsNaN(buffer[offset]) || buffer[offset] == -9999)
                         {
-                            image.SetPixel(x, y, Color.Transparent);
+                            //image.SetPixel(x, y, Color.Transparent);
                             continue;
                         }
 
-                        //int val = Convert.ToInt32(buffer[x * y]* 100); //Convert.ToInt32((buffer[x * y] - layer.extension.minHeight) * 100);
-                        int val = Convert.ToInt32((buffer[x * y] - layer.extension.minHeight) * 100 / perHeight);
+                        int val = Convert.ToInt32(buffer[offset] * 100);
                         int r = val / 65536;
                         int g = (val - r * 65536) / 256;
                         int b = val % 256;
 
-                        Color color = Color.FromArgb(0, r, g, b);
+                        Color color = Color.FromArgb(127, r, g, b);
                         image.SetPixel(x, y, color);
                     }
                 }
@@ -238,7 +231,6 @@
                     if (null != ds) ds.Dispose();
                 }
             }*/
-
             Parallel.For(0, files.Count, i =>
             {
                 Dataset ds = null;

--
Gitblit v1.9.3