From 3417cf014a65765e02696c1d121ce58b2b4a8aed Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期二, 08 四月 2025 15:55:36 +0800 Subject: [PATCH] 修改pom.xml --- src/main/java/com/se/simu/utils/TiffToRGBUtil.java | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/se/simu/utils/TiffToRGBUtil.java b/src/main/java/com/se/simu/utils/TiffToRGBUtil.java index f6047e1..224ffb1 100644 --- a/src/main/java/com/se/simu/utils/TiffToRGBUtil.java +++ b/src/main/java/com/se/simu/utils/TiffToRGBUtil.java @@ -1,8 +1,8 @@ package com.se.simu.utils; import org.apache.commons.imaging.*; -import org.gdal.gdal.Band; import org.gdal.gdal.Dataset; +import org.gdal.gdal.Band; import org.gdal.gdal.gdal; import org.gdal.gdalconst.gdalconstConstants; @@ -14,7 +14,7 @@ public class TiffToRGBUtil { public static void main(String[] args) throws Exception{ - tifToPng("D:\\鍩庡競鍐呮稘\\sem\\DEM.tif","D:\\鍩庡競鍐呮稘\\sem\\DEM.png"); + tifToPng("D:\\鍩庡競鍐呮稘\\sem\\tongzhou_1m_tif\\tongzhou_raster_4548_1m_clip_river_fill.tif","D:\\鍩庡競鍐呮稘\\sem\\tongzhou_1m_tif\\tongzhou_raster_4548_1m_clip_river_fill.png"); } public static void tifToPng(String tifPath, String pngPath) throws Exception { // 娉ㄥ唽鎵�鏈夌殑 GDAL 椹卞姩 @@ -44,14 +44,13 @@ // 鍋囪楂樺害淇℃伅瀛樺偍鍦ㄥ儚绱犲�间腑 double pixelHeight = pixelValue * geoTransform[5]; //height = -10000 + ((R * 256 * 256 + G * 256 + B) * 0.1) - int value = (int) (pixelHeight + 10000) * 10; + int value = (int) ((pixelHeight + 10000) * 10); //value=(R * 256 * 256 + G * 256 + B); int r = value / (256 * 256); value = value % (256 * 256); int g = value / 256; int b = value % 256; Color color = new Color(r, g, b); - System.out.printf("Pixel (%d, %d): R=%d, G=%d, B=%d%n", x, y, r, g, b); int newRgb = color.getRGB(); // 灏嗗鐞嗗悗鐨勫儚绱犻鑹插�艰缃埌鏂扮殑 PNG 鍥惧儚涓� pngImage.setRGB(x, y, newRgb); -- Gitblit v1.9.3