【发布时间】:2023-03-22 22:37:01
【问题描述】:
如果我用我的三星 Galaxy s2 制作图片,图片为 3264 x 2448 像素。 我想对其使用颜色范围检查,但它不起作用。
但是,如果我将图片缩小,例如 2500 x 2500(像素更少),那么它确实有效。但我想使用 Galaxy s2 (3264 x 2448) 的图片大小。 我认为这是一个内存问题? 我已经不知道极限是什么了。 但他们是“绕过”这个问题的另一种方式吗?
这是一段代码,我现在怎么做:
bmp = BitmapFactory.decodeResource(getResources(),
R.drawable.four_colors);
int width = bmp.getWidth();
int height = bmp.getHeight();
int[] pixels = new int[width * height];
bmp.getPixels(pixels, 0, width, 0, 0, width, height);
for (int y = 0; y < height; y++){
for (int x = 0; x < width; x++){
int index = y * width + x;
int R = (pixels[index] >> 16) & 0xff; //bitwise shifting
int G = (pixels[index] >> 8) & 0xff;
int B = pixels[index] & 0xff;
total++;
if ((G > R)&&(G > B)){
counter++;
}
}
}
它崩溃是因为图片太大,较小的图片可以工作。 那么他们有什么东西可以“绕过”这个问题吗?而不是使用较小的图像:)
我尝试了其他一些事情,但没有成功,我尝试解释我尝试了什么。
我尝试将图像“剪切”成两半,然后单独扫描(没有用)。
我尝试只扫描它的一半 (1632 x 1224) 然后将图像旋转 (180 度) 并再次扫描,但这也没有用。
- 打我:)
【问题讨论】:
-
嘿,我明天要试试答案。我会让你听到它的结果
标签: android memory colors bitmap