I am working on creating an online image editing tool.Looking for some refernce how can I add an image with white space on right side.For example see this image
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- How to get the background from multiple images by
- StackExchange API - Deserialize Date in JSON Respo
Presumably, you want to create a new image from an existing image, where the new image has white space on the left and right?
Suppose the unpadded image was a BufferedImage and is called 'image'. Suppose the amount of whitespace you want on each side is 'w'. What you want to do is create a new BufferedImage wider than the original, then paint the entire thing white, and finally draw the smaller image on top of it:
Create a new
BufferedImage
object of the right size; useGraphics.fillRect()
to paint it white; draw the image into the top-left corner withdrawImage()
; then save your new image.If anyone comes upon a similar problem, I would definitively recommend imgScalr. You can add padding with literally one line
imageSource= Scalr.pad(imageSource,pad,Color.White);
.