位图只不过是一个int[] pixels = new int[width * height]
;将位图缩放到另一个位图中,最好采用“手动”方式?
我使用了这种方式:
BufferedImage img = new BufferedImage(WIDTH,HEIGHT,RGB);
int[] pixels = ((DataBufferInt) img.getRaster().getDataBuffer()).getData();
“就在这里呈现的像素[],例如加载使用BufferedImage img = ImageIO.read(URL)
的图像;
Graphics g;
g.drawImage(img, 0,0, getWidth(), getHeight(), null);
现在在“做渲染在这里像素”很多东西都可能发生,着色纹理(它们是灰阶),但我还需要重新调节。虽然我不知道“最好的方式”做到这一点。
所有'位图'只是一个整数数组。
缩放可以在步骤来完成对0.1或0.01或3 我个人认为是这样的:
for(int yy = 0; yy < tex.height; yy++){
for(int xx = 0; xx < tex.width; xx++){
int px = tex.getPixel(yy * tex.width + xx);
this.putPixel((y*this.width)+((int)((yy*scale) * tex.width)) + (x) + ((int)(xx*scale)));
}
}
但我不知道这是否会是“正确”的方式。或者如果有其他/更好的方法。
如果需要更多信息,请不要问。 –
参见'AffineTransformOp',显示[here](http://stackoverflow.com/questions/4216123/how-to-scale-a-bufferedimage/4216635#4216635)。 – trashgod
是的,我看到了一个,但我不打算保留对BufferedImage对象的引用。 –