I am developing an Android App that can do Gamma correction of an image stored in phone. My activity can get the image location, but i cant use the BufferedImage
class and ImageIO
class in my Application.
I get the following error in Eclipse IDE with ADT plugin..
ImageIO cannot be Resolved
BufferedImage cannot be Resolved
I cannot process the image . I have an idea of including the java libraries but i don't know how to do this in Android
Here is the Function i need to make it work .
private static BufferedImage gammaCorrection(BufferedImage original, double gamma) {
int alpha, red, green, blue;
int newPixel;
double gamma_new = 1 / gamma;
int[] gamma_LUT = gamma_LUT(gamma_new);
BufferedImage gamma_cor = new BufferedImage(original.getWidth(), original.getHeight(), original.getType());
for(int i=0; i<original.getWidth(); i++) {
for(int j=0; j<original.getHeight(); j++) {
// Get pixels by R, G, B
alpha = new Color(original.getRGB(i, j)).getAlpha();
red = new Color(original.getRGB(i, j)).getRed();
green = new Color(original.getRGB(i, j)).getGreen();
blue = new Color(original.getRGB(i, j)).getBlue();
red = gamma_LUT[red];
green = gamma_LUT[green];
blue = gamma_LUT[blue];
// Return back to original format
newPixel = colorToRGB(alpha, red, green, blue);
// Write pixels into image
gamma_cor.setRGB(i, j, newPixel);
}
}
return gamma_cor;
}
Android is not standard java, it lacks certain classes. AWT is just not there
I think a few Java libraries aren't in Android like the awt
String selectedImagePath;
ImageView img;
img = (ImageView)findViewById(R.id.ImageView1);
Bitmap yourSelectedImage = BitmapFactory.decodeFile(selectedImagePath);
img.setImageBitmap(yourSelectedImage);
if multiple image than you can make
ArrayList<Bitmap> aList = new ArrayList<Bitmap> ();
aList.add(yourbitmap);
than set in imageviews like above using for loop. because android not provide BufferedImage class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With