| | |
| | | |
| | | public class TiffToRGBUtil { |
| | | public static void main(String[] args) throws Exception{ |
| | | tifToPng("D:\\城市内涝\\sem\\DEM100.tif","D:\\城市内涝\\sem\\DEM100.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 驱动 |
| | |
| | | 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); |