1. Load file into Bitmap
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeFile(photoPath, options);
// selected_photo.setImageBitmap(bitmap); // if you need
2. Access each pixel array
int dstWidth = width of the flag rectangle;
int dstHeight = height of the flag rectangle;
int pixelArray[] = new int[dstWidth * dstHeight];
int startX = start X position of your flag;
int endX = end X position of your flag;
int startY = start Y position of your flag;
int endX = end Y position of your flag;
bitmap.getPixels(pixelArray, 0, startX, startX, startY, dstWidth, dstHeight);
3. Create a small Bitmap with array
Bitmap flag = Bitmap.createBitmap(dstWidth, dstHeight, Bitmap.Config.ARGB_8888);
bitmap.copyPixelsFromBuffer(pixelArray);