如何在Java中裁剪图像? [英] How do I crop an image in Java?
本文介绍了如何在Java中裁剪图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用鼠标手动裁剪图像。
假设图像有一些文字,我想从图像中选择一些文字,然后
为此我想要使用鼠标裁剪该区域。
I want to crop an image manually using the mouse.
Suppose the image has some text, and I want to select some text from an image, then
for that purpose I want to crop that area by using the mouse.
推荐答案
我发现裁剪缓冲图像最有用的解决方案是使用getSubImage(x,y,w,h);
The solution I found most useful for cropping a buffered image uses the getSubImage(x,y,w,h);
我的裁剪程序最终看起来像这样:
My cropping routine ended up looking like this:
private BufferedImage cropImage(BufferedImage src, Rectangle rect) {
BufferedImage dest = src.getSubimage(0, 0, rect.width, rect.height);
return dest;
}
这篇关于如何在Java中裁剪图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文