What i want to do is to read some image in android and convert each pixel in my image to RGB values , and here is the code that i have found :
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button test=(Button)findViewById(R.id.button1);
test.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
BufferedImage bi=ImageIO.read(new File("C:\\images\\Sunset.jpg"));
int[] pixel;
for (int y = 0; y < bi.getHeight(); y++) {
for (int x = 0; x < bi.getWidth(); x++) {
pixel = bi.getRaster().getPixel(x, y, new int[3]);
System.out.println(pixel[0] + " - " + pixel[1] + " - " + pixel[2] + " - " + (bi.getWidth() * y + x));
}
}
}
});
}
}
But i have problems in importing some packages like this :
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
And i don't know how to download them or which is the best way to resolve this problem.. Any help??