This week's book giveaways are in the Cloud and AI/ML forums. We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line! See this thread and this one for details.
Hi all, I am having issues with calling one of my methods, specifically displayImage(). I am supposed to use this program to convert an image from a file to grey scale, high contrast, or negative based on user input. User input is also prompted to ask the user which image they would like to convert. This is the code thus far:
I am not sure if you need that information to solve this question, because again, my main problem is the method not being called, and not knowing how to initialize ImageInfo image in the main method of the program. Thank you in advance for any insight on this.
Why do you have so many static methods in the first post? Why have you overridden equals() without overriding hashCode()?
How do you know the method isn't called? Have you put any debugging code in it? Why does that method have a drawing panel local variable?
How are you implementing keyboard input? Is there any chance of your calling nextLine() after nextInt() or similar?
Why have you got an infinite loop in lines 61ff. Why are you closing a Scanner reading from System.in?
Why are you catching unchecked exceptions? Are you suffering any exceptions at all?
There are all sorts of other minor problems, but what actually happens when you try to run your code?
I tried to run your program, but I get a lot of errors, so that did not work.
First of all: have a look a line 103. That should not cause the displayImage() not being called, but it is incorrect anyway.
Can't you put a 'System.out.println("I'm in displayImage") at the start of that method? Then it is clear right away whether that method is called or not. If not, add that statement at some more places, to see where your program gets, and where potentially an error occurs.
Java has some classes that will do image maniputation for you, without you having to perform much pixel juggling. See the interface BufferedImageOp and its implementing classes. There is also some tutorial from Oracle: