I am able to use the method to revert the image back to its original state after applying filters that are built into my program ONCE, after that whenever I press the JButton linked to the restore method it does nothing. Here is what I believe to be all the relevant code:
private OFImage originalImage;
private OFImage currentImage;
private void openFile()
{
int returnVal = fileChooser.showOpenDialog(frame);
if(returnVal != JFileChooser.APPROVE_OPTION) {
return; // cancelled
}
File selectedFile = fileChooser.getSelectedFile();
currentImage = ImageFileManager.loadImage(selectedFile);
originalImage = ImageFileManager.loadImage(selectedFile);
if(currentImage == null) { // image file was not a valid image
JOptionPane.showMessageDialog(frame,
"The file was not in a recognized image file format.",
"Image Load Error",
JOptionPane.ERROR_MESSAGE);
return;
}
imagePanel.setImage(currentImage);
setButtonsEnabled(true);
showFilename(selectedFile.getPath());
showStatus("File loaded.");
updateCropToolbar(currentImage.getWidth(), currentImage.getHeight());
frame.pack();
}
private void restoreOriginal() {
OFImage restore = originalImage;
currentImage = restore;
imagePanel.setImage(currentImage);
updateCropToolbar(currentImage.getWidth(), currentImage.getHeight());
showStatus("File restored.");
frame.pack();
}
Apologies, this is my first question so if formatting is poor or I am blatantly missing crucial information, let me know. I just cannot for the life of me work out why originalImage is not being set after it has already set once.