张洋洋
2025-02-25 1af1a0d208cd223be9bc574eebf1c21b45b3b117
src/main/java/com/se/simu/utils/TiffToRGBUtil.java
@@ -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);