0
我想旋转图像没有标准方法,使颜色数组和操作它,但是当我调用,旋转我得到黑点(看图片)我试图旋转没有lib,但它使黑色点在图片
这里是我的代码,colScaled是我试图转换成数组图片:
public void arrays() {
colScaled = zoom2();
int j = 0;
int i = 0;
angel = Integer.parseInt(this.mn.jTextField1.getText());
float degree = (float) Math.toRadians(angel);
float cos = (float) Math.cos(degree);
float sin = (float) Math.sin(degree);
int W = Math.round(colScaled[0].length * Math.abs(sin) + colScaled.length * Math.abs(cos));
int H = Math.round(colScaled[0].length * Math.abs(cos) + colScaled.length * Math.abs(sin));
int x;
int y;
int xn = (int) W/2;
int yn = (int) H/2;
int hw = (int) colScaled.length/2;
int hh = (int) colScaled[0].length/2;
BufferedImage image = new BufferedImage(W + 1, H + 1, im.getType());
for (i = 0; i < colScaled.length; i++) {
for (j = 0; j < colScaled[0].length; j++) {
x = Math.round((i - hw) * cos - (j - hh) * sin + xn);
y = Math.round((i - hw) * sin + (j - hh) * cos + yn);
image.setRGB(x, y, colScaled[i][j]);
}
}
ImageIcon ico = new ImageIcon(image);
this.mn.jLabel1.setIcon(ico);
}
[Java像素数组旋转]的可能重复(http://stackoverflow.com/questions/29739809/java-rotation-of-pixel-array) – Spektre
“黑色点”在哪里?在图像中还是在图像周围? – gpasch
在图像中,周围不是问题 –