【发布时间】:2017-03-29 07:41:47
【问题描述】:
首先感谢您的宝贵时间。我有一个 jar 库,它将作为库包含在我的 Android 应用程序中。
除其他外,此 jar 能够从 jpg 图像中获取 RGB 值。这在我的 java 应用程序中运行良好,但是当我在我的 Android 应用程序中运行它时它不起作用,因为类 ImageIO.read(File file) (Bufferedimage) 没有在 Android 中实现。
我读过一些关于使用 Bitmap 类的内容,但我没有找到任何关于它的内容。
你能帮我看看你在下面找到的这个方法吗?
public static int[][][] getImageRgb(BufferedImage image) {
int width = image.getWidth();
int height = image.getHeight();
int[][][] rgb = new int[height][width][3];
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
int pixel = image.getRGB(j, i);
rgb[i][j] = getPixelRgb(pixel); }
}
return rgb;
}
getPixelRgb 是一个函数的目标是:
public static int[] getPixelRgb(int pixel) {
// int alpha = (pixel >> 24) & 0xff;
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel) & 0xff;
return new int[]{red, green, blue};
}
我真的不知道如何为 Android 转换这些方法。
我期待收到您的来信。 非常感谢。
【问题讨论】:
-
什么?真的吗 ? this 呢?
-
感谢您的回复,但我真的不知道如何实现它
标签: java android bufferedimage javax.imageio mobile-development