Tag: rgba

Java旋转图像变成背景黑色的一部分

当我尝试旋转图像时,看起来背景的一部分变黑(我的图像是透明的) 背景白色 背景的一部分变黑 这是旋转图像的代码: public BufferedImage rotate(int height, int width, BufferedImage originalImg, int angle) { BufferedImage rotateImage = null; try { rotateImage = new BufferedImage(height, width, BufferedImage.TYPE_INT_RGB); AffineTransform a90 = AffineTransform.getRotateInstance(Math.toRadians(angle), height / 2, width / 2); AffineTransformOp op90 = new AffineTransformOp(a90, AffineTransformOp.TYPE_BILINEAR); op90.filter(originalImg, rotateImage); } catch (Exception e) { System.err.println(e); } return rotateImage; }

Java:从缓冲图像中获取RGBA作为整数数组

给定一个图像文件,比如PNG格式,如何获得一个int [r,g,b,a]数组,表示位于第i行第j列的像素? 到目前为止,我从这里开始: private static int[][][] getPixels(BufferedImage image) { final byte[] pixels = ((DataBufferByte) image.getRaster().getDataBuffer()).getData(); final int width = image.getWidth(); final int height = image.getHeight(); int[][][] result = new int[height][width][4]; // SOLUTION GOES HERE…. } 提前致谢!

如何设置颜色的R,G,B和Alpha分量?

有3个整数值构成RGB值,我也有颜色的Alpha分量值。 如何设置这4个值以获得所需的颜色