简体   繁体   中英

Getting a part of the Image

I have a sprite image

http://spriters-resource.com/pc_computer/maplestory/sheet/21909

I would like to first load the whole image as a BufferedImage, and I found that quite simple.

BufferedImage image_ = ImageIO.read(file_);

now that I have this buffered image I would like to be able to slice and dice it. I want to try to write a function that returns pieces of this Buffered image

public BufferedImage getImage(int x, int y, int width, int height)

But I have absolutely no idea how one would go about cutting the BufferedImage into pieces. What would be the best way to go about it, or what other ideas would you suggest?

Any help would be appreciated, this is driving me nuts.

Your first port of call should the JavaDocs ...

Take a look at BufferedImage#getSubImage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM