In my project, users upload a picture. Sometimes it is less than expected.
I would like to create a default white (blank) image and place the user's image (small) in the center of the white image. In other words, I want to cover all sides of a small image with white pixels.
How can I do this using java?
I am not good at java image processing. But I use BuferedImageto expand the downloaded image.
BufferedImage newImage = new BufferedImage(50, 50, BufferedImage.TYPE_INT_RGB);
newImage.getGraphics().drawImage(srcImage, 0, 0, srcImage.getWidth(), srcImage.getHeight(), null);
The code above fills in black if the width and height of the original image is less than 50. The original image is displayed on the left, and the remaining area is filled in black.
Is it possible to move the original image to the center and fill the remaining pixels with white.
Any suggestions would be greatly appreciated.
thank
user405398
source
share