Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.my_bitmap); int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels, 0, width, 0, 0, width, height); // Do something with the pixel data
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.my_bitmap); int x = 100; int y = 100; int width = 200; int height = 200; int[] pixels = new int[width * height]; bitmap.getPixels(pixels, 0, width, x, y, width, height); // Do something with the pixel dataThis method is part of the android.graphics package.