0
我想重复边框像素n次。我设法为顶部边界的一部分做到了这一点,但我正在与其他部门斗争。有没有更简单的方法来做到这一点,因为它似乎过于复杂,我试图实现。BufferedImage重复的边框
public BlurredImage(int n) {
try {
castle = ImageIO.read(this.getClass().getResource("test.png"));
} catch (IOException e) {
System.out.println("cannot read image");
}
int w = (2*n)+castle.getWidth();
int h = (2*n)+castle.getHeight();
int origW =castle.getWidth();
int origH = castle.getHeight();
System.out.println(w);
System.out.println(h);
BufferedImage enlargedImage = new BufferedImage(w, h, castle.getType());
//Map existing image
for (int y=0; y < origH; y++){
for (int x=0; x < origW; x++){
enlargedImage.setRGB(x+n, y+n, castle.getRGB(x, y));
}
}
//Top border
for (int y=0; y < n; y++){
for (int x=0; x < origW; x++){
enlargedImage.setRGB(x+n, y, castle.getRGB(x, 0));
}
}
//Bottom border
for (int y=0; y > y+n; y++){
for (int x=0; x < origW; x++){
enlargedImage.setRGB(x+n, y, castle.getRGB(x, 0));
}
}
}
你是不是放大图像,顺便说一句正确的位置 - 只是将其移动'n'个像素...你能澄清你想达到的目标吗? “复制边框像素”是什么意思?一个我们可以真正运行的适当的[SCCEE](http://sscce.org),而不是部分代码会让我们更容易帮助。 – DNA 2012-03-01 19:11:17