jarandaf
jarandaf

Reputation: 4427

PNG to Bitmap file conversion

I'm developing a RESTful API with Spring where some users can upload some images they draw in a mobile device. The mobile application sends the image in .png format and I would need to generate a bitmap from it for further processing in Delphi. I've been playing around using ImageIO class but it does not seem to do the trick when specifying .bmp format and writing to a new file. Are out there some libraries that do these kind of image conversions? It should be a solved problem nowadays but I am not familiar with image processing.

Thanks

Upvotes: 1

Views: 9380

Answers (1)

Ezzored
Ezzored

Reputation: 925

This should work:

//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);

Upvotes: 1

Related Questions