gpt4 book ai didi

java - PNG 到位图文件转换

转载 作者:行者123 更新时间:2023-12-01 06:18:00 25 4
gpt4 key购买 nike

我正在使用 Spring 开发一个 RESTful API,一些用户可以上传他们在移动设备中绘制的一些图像。移动应用程序以 .png 格式发送图像,我需要从中生成一个位图,以便在 Delphi 中进一步处理。我一直在使用ImageIO类,但在指定 .bmp 格式并写入新文件时,它似乎不起作用。是否有一些库可以进行此类图像转换?如今这应该是一个已解决的问题,但我对图像处理不熟悉。

谢谢

最佳答案

这应该有效:

//Create file for the source
File input = new File("c:/temp/image.png");

//Read the file to a BufferedImage
BufferedImage image = ImageIO.read(input);

//Create a file for the output
File output = new File("c:/temp/image.bmp");

//Write the image to the destination as a BMP
ImageIO.write(image, "bmp", output);

关于java - PNG 到位图文件转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19378334/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com