Search:

Type: Posts; User: sjdganc

Page 1 of 2 1 2

Search: Search took 0.23 seconds.

  1. Re: Convert color image to grayscale and then to sepia

    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...
  2. Re: Convert color image to grayscale and then to sepia

    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 <...
  3. Re: Convert color image to grayscale and then to sepia

    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...
  4. Re: Convert color image to grayscale and then to sepia

    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...
  5. Re: Convert color image to grayscale and then to sepia

    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...
  6. Re: Convert color image to grayscale and then to sepia

    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...
  7. Re: Convert color image to grayscale and then to sepia

    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...
  8. Re: Convert color image to grayscale and then to sepia

    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...
  9. Re: Convert color image to grayscale and then to sepia

    Hmmm. I'm not sure how to do that. I'll keep researching.
  10. Re: Convert color image to grayscale and then to sepia

    I thought the second if statement and elseif statements is the code for sepia.
  11. Re: Convert color image to grayscale and then to 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?
  12. Convert color image to grayscale and then to sepia

    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 =...
  13. Replies
    29
    Views
    326

    Re: Random Shape Generator

    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....
  14. Replies
    29
    Views
    326

    Re: Random Shape Generator

    So you're able to see the shapes generate? The code compiles for me as well but I only get an orange window.
  15. Replies
    29
    Views
    326

    Re: Random Shape Generator

    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...
  16. Replies
    29
    Views
    326

    Re: Random Shape Generator

    I thought


    public Draw() {
    }

    is the no-arg constructor. But I see I don't have it doing anything, so I added:


    public Draw() {
  17. Replies
    29
    Views
    326

    Re: Random Shape Generator

    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...
  18. Replies
    29
    Views
    326

    Re: Random Shape Generator

    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...
  19. Replies
    29
    Views
    326

    Re: Random Shape Generator

    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;...
  20. Replies
    29
    Views
    326

    Re: Random Shape Generator

    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...
  21. Replies
    29
    Views
    326

    Re: Random Shape Generator

    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:...
  22. Replies
    29
    Views
    326

    Re: Random Shape Generator

    I'm not sure what you mean by constructor. In the draw program do I change it to this


    public draw() {
    }
  23. Replies
    29
    Views
    326

    Re: Random Shape Generator

    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...
  24. Replies
    29
    Views
    326

    Re: Random Shape Generator

    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;

    ...
  25. Replies
    29
    Views
    326

    Re: Random Shape Generator

    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:...
Results 1 to 25 of 29
Page 1 of 2 1 2