张洋洋
2025-02-18 5c87778c13e3e33bb30edfcc344e5e69754bc9bf
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 驱动
@@ -51,7 +51,6 @@
                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);