Android: 如何将一个位图数组转换为整数数组?

3

我正在对一个整型数组中的一些图像进行裁剪...

int[] imagenes_originales = new int[] {
    R.drawable.image1,
    R.drawable.image2,
    R.drawable.image3,
    R.drawable.image4
}

int[] new_images;

for (a = 0; a <= 3; a++) {
    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), imagenes_originales[a]);

    int x = bitmap.getWidth(), y = bitmap.getHeight();
    int escalax = getWindowManager().getDefaultDisplay().getWidth();

    Bitmap recorte = Bitmap.createBitmap(bitmap, 0, y / 2, escalax, 100);
}

我该如何将变量new_images[]中的位图图像进行转换?


你能详细解释一下吗?我不太明白你想要什么,到底是什么目的? - Trung NT Nguyen
最终,您希望new_images保存什么内容? - Balkrishna Rawool
1个回答

5
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), imagenes_originales[a]);
int x = bitmap.getWidth();
int y = bitmap.getHeight();
int[] intArray = new int[x * y];
bitmap.getPixels(intArray, 0, x, 0, 0, x, y);

你的位图转换为整型数组现在保存在intArray中。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接