I must read some image and then I have to change brightness and contrast of this image
I create main class and constructor where are panels, sliders and other stuff, I added changeListener to slider to take current value. My imagePanel is new Object of that class:
public class Obrazek extends JPanel{
public static BufferedImage img = null;
public Obrazek() {
super();
try {
img = ImageIO.read(new File("D:\\ja.jpg"));
} catch (IOException e) {}
}
@Override
public void paint(Graphics g) {
g.drawImage(img, 0, 0, null);
}
}
This is my load button
private void przyciskWczytaj(java.awt.event.ActionEvent evt) {
int odpowiedz = jFileChooser1.showOpenDialog(this);
if (odpowiedz == jFileChooser1.APPROVE_OPTION) {
File file = jFileChooser1.getSelectedFile();
try {
BufferedImage im = ImageIO.read(new File(file.getAbsolutePath()));
Obrazek.img = im;
} catch (IOException ex) {
System.out.println("Error");
}
}
}
And now I want to create class where I will change that brightness. I have to use but I don't know how to use that thing:
BufferedImage(256, 256, Bufferedmage.TYPE_INT_RGB)
and to get each pixel of image I need to do something like:
int rgb []=((DataBufferInt)img.getRaster().getDataBuffer()).getData();
And here I is next problem: How can I change the value of each r,g,b and show that new image on my panel