我正在剪切一些int array的图片......
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[]
变量中转换位图图像?
答案 0 :(得分:4)
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);
您的位图到int数组现在位于intArray
/