witam, napisałem taką funkcję:
public static BufferedImage liniowo(BufferedImage img){
int MIN = -255;
int MAX = 255;
int INIT = 0;
final JDialog dialog = new JDialog();
dialog.setTitle("Rozjaśnij liniowo");
dialog.setModal(true);
dialog.setLayout(new BorderLayout());
final JLabel label = new JLabel("0", SwingConstants.CENTER);
final JSlider slider = new JSlider(JSlider.HORIZONTAL, MIN, MAX, INIT);
slider.setMajorTickSpacing(255);
slider.setPaintTicks(true);
slider.setPaintLabels(true);
slider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent evt) {
JSlider slider = (JSlider)evt.getSource();
if (!slider.getValueIsAdjusting()) {
val = slider.getValue();
label.setText("" + val + "");
}
}
});
JButton ok = new JButton("OK");
ok.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent k){
value = slider.getValue();
dialog.setVisible(false);
}
});
JButton cancel = new JButton("Anuluj");
cancel.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent k){
dialog.setVisible(false);
}
});
dialog.add(label, BorderLayout.PAGE_START);
dialog.add(slider, BorderLayout.CENTER);
JPanel dolny = new JPanel();
dolny.setLayout(new GridLayout(1, 2));
dolny.add(cancel);
dolny.add(ok);
dialog.add(dolny, BorderLayout.PAGE_END);
dialog.pack();
dialog.setVisible(true);
float offset = (float) value;
float i = 1f;
RescaleOp op = new RescaleOp(i, offset, null);
img = op.filter(img, null);
return img;
}
której zadaniem jest dodawanie stałej wartości (rozjaśnienie/ściemnienie) do przekazanego doń argumentu, niestety jednak funkcja powoduje błąd:
An unexpected error has been detected by Java Runtime Environment:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d0ad65d, pid=3488, tid=3984
przyczyną błędu jest przedostatnia linia funkcji (przynajmniej po jej skomentowaniu program nie wyrzuca błędu)
img = op.filter(img, null);
generowany błąd zamieszczę na serwerze, może to coś pomoże, ja nie wiele z niego rozumiem ;/ log