I'm stumped. Am I on the right track with the below code? Or do I need to redefine red, green, and blue?
if(red < 63) {
red = (int)(red * 1.1);
blue = (int)(blue...
Type: Posts; User: sjdganc
I'm stumped. Am I on the right track with the below code? Or do I need to redefine red, green, and blue?
if(red < 63) {
red = (int)(red * 1.1);
blue = (int)(blue...
I put the {} around the for statements but the outcome did not change. Still only getting the color image.
for(int y = 0; y < image.getHeight(); y++) {
for(int x = 0; x <...
I found the error, it was the curly brace, ugh. So the program is compiling without errors but not doing what I want it to do. Now only the color image displays. The grayscale image is not showing...
Yes I'm sure but now I'm having trouble recreating it. I keep getting an illegal start of statement at line 56 which is the curly brace right above the comment //Causes program to wait to draw the...
Just saw your update. I put the for loop in just to see the pixel values. So I'll try putting it after the if () statements and get the values.
--- Update ---
So here is the whole code. I put...
Ok. That makes sense. What is printing out as the pixel values follows the if statements, so maybe what I am missing is the code after the if() statements to get or set what the pixels should be. Is...
I put in a for statement to run through all of the pixels. The red pixel is below 63 and when I run it through the second if statement they are below 192.
if(red < 63) {
red = (int)(red...
I put in a println() statement and the values are all the same:
Pixel R: 62 G: 62 B: 62
which is the grayscale. So according to this the R value is less than 63 as in the below if statement. The...
Hmmm. I'm not sure how to do that. I'll keep researching.
I thought the second if statement and elseif statements is the code for sepia.
Thank you that cleared the errors. So now the image appears in color and then in grayscale but the sepia effect is not working. What am I missing?
I have the program working where the image is converted to grayscale but I get the following error when trying to convert from grayscale to sepia.
java:36 error: '. class' expected
red =...
I cannot see why the paintComponent is not being executed. The switch...case is inside this method. Not sure what the default case should be? I have the three different shapes that need to be drawn....
So you're able to see the shapes generate? The code compiles for me as well but I only get an orange window.
I moved setVisible() to after everything as you suggested but still get the same errors as most recently stated above. I also see your points about the for loop so I commented those out for now and...
I thought
public Draw() {
}
is the no-arg constructor. But I see I don't have it doing anything, so I added:
public Draw() {
When I comment these three lines out I get the orange box but still no shapes. In other examples I have seen where the for loop should be in the main method. Is this part of my problem or am I...
I put that back in in the Draw class and it compiles with no errors. But still get the same above errors:
import javax.swing.*;
import java.awt.*;
import java.util.Random;
public class...
Ok, I see that. Thank you. So the Draw program new code compiles without error but I get a new error in the ShapeGen program.
import javax.swing.*;
import java.awt.*;
import java.util.Random;...
I'm trying to get this but I'm not quite understanding. So I changed the name of the draw program to Draw and left the constructor as public draw. I get this error on the Draw program
import...
I tried it and see from the tutorial you provided that it is a no-arg constructor, so I'm not telling it what I want to do, right? But in the ShapeGen program I get this error:
ShapeGen.java:32:...
I'm not sure what you mean by constructor. In the draw program do I change it to this
public draw() {
}
This code is supposed to run the shapes in the draw program. I added a draw object to the ShapeGen code but get the below errors:
ShapeGen.java:29: error: constructor draw in class draw cannot be...
Do I need that in the draw program? I changed it to the below code. I get just a yellow window to display, but no shapes.
import javax.swing.*;
import java.awt.*;
import java.util.Random;
...
No, I had it outside of the brackets. Thank you for pointing that out. When I fixed that I realized the third error expecting the } so I fixed that. Now I am getting this error:
ShapeGen.java:13:...