我正在做一个应用程序在Java中,我想这样做: 我有一个BufferedImage
加载一个大图像,我想分配一部分到另一个BufferedImage
。将BufferedImage的一部分分配给另一个BufferedImage
比方说
BufferedImage2 = BufferedImage1.GetWindow(From x1 y1 to x2 y2);
BufferedImage2
将是更大BufferedImage1
只是一小部分。
我正在做一个应用程序在Java中,我想这样做: 我有一个BufferedImage
加载一个大图像,我想分配一部分到另一个BufferedImage
。将BufferedImage的一部分分配给另一个BufferedImage
比方说
BufferedImage2 = BufferedImage1.GetWindow(From x1 y1 to x2 y2);
BufferedImage2
将是更大BufferedImage1
只是一小部分。
你可以尝试BufferedImage.getSubimage()
int width = x2 - x1;
int height = y2 - y1;
BufferedImage bufferedImage2 = bufferedImage1.getSubimage(x1, y1, width, height);
是的,这是它。谢谢您的帮助 – user3417479
例如在图像缓冲器绘制:
BufferedImage img2 = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = img2.createGraphics();
g.drawImage(bufferedImage1, x, y, width, height, null);
g.dispose();
有几种drawImage
方法,请参阅的javadoc。你可能想要这个drawImage。
什么是BufferedImage的? GetWindow()返回什么? – martynas
http://stackoverflow.com/questions/6317732/how-to-get-small-images-from-big-bufferedimage-really-fast – dnault
你正在寻找的方法是'BufferedImage.getSubimage()'http: //stackoverflow.com/questions/22133993/what-exactly-does-getsubimage-of-bufferedimage-do – haraldK