首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

用Java如何从一个图片中提取出部分的图像

2012-06-03 
用Java怎么从一个图片中提取出部分的图像我不想用PhotoShop, 或 inkscape, 原因是前者没有, 后者不会用。如

用Java怎么从一个图片中提取出部分的图像
我不想用PhotoShop, 或 inkscape, 原因是前者没有, 后者不会用。

如下图,

怎么把这10个图像用java分离成单独的图像, 或怎么设定访问固定的区域, 求解?

[解决办法]
用Windows自带的画笔多好。。。

假设你原始图片是:Image source;

BufferedImage img = new BufferedImage(50, 50);
Graphics g = img.getGraphics();
g.drawImage(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);

img图片左上右下坐标位置:
dx1 - the x coordinate of the first corner of the destination rectangle.
dy1 - the y coordinate of the first corner of the destination rectangle.
dx2 - the x coordinate of the second corner of the destination rectangle.
dy2 - the y coordinate of the second corner of the destination rectangle.
source图片左上右下坐标位置:
sx1 - the x coordinate of the first corner of the source rectangle.
sy1 - the y coordinate of the first corner of the source rectangle.
sx2 - the x coordinate of the second corner of the source rectangle.
sy2 - the y coordinate of the second corner of the source rectangle.
[解决办法]
用Windows自带的画笔

热点排行