Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Need some help changing the colors of a picture

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Need some help changing the colors of a picture

    Hey, everyone. I am currently teaching myself Java and now I am trying to make a program that puts some kind of color filter over a picture. I'm really having trouble getting it to compile. I get the same errors constantly. Here is my code:

    import java.util.Scanner;
    import java.awt.image.Raster;
    import java.util.*;
     
    public class Landscape extends Picture
    {
      public void increaseGreen(Picture beach)
      {
       Pixel[] pixelArray = this.getPixels();
       Pixel pixel = null;
       int value = 0;
       int index = 0;
       while(index < pixelArray.length)
       {
         pixel = pixelArray[index];
         value = (int) (value * 1.3);
         pixel.setGreen(value);
         index = index + 1;
       }
       System.out.println(beach);
       beach.show();
      }
     
      public void increasePink(Picture beach)
      {
       Pixel[] pixelArray = this.getPixels();
       Pixel pixel = null;
       int value = 0;
       int index = 0;
       while(index < pixelArray.length)
       {
         pixel = pixelArray[index];
         value = (int) (value * 1.3);
         pixel.setGreen(value);
         pixel.setRed(value);
         index = index + 1;
       }
       System.out.println(beach);
       beach.show();
      }
      public void main(String[] args) 
      {
        String typevalue = "Filter";
        String pink = "Pink";
        String green = "Green";
        String fileName = FileChooser.pickAFile();
        System.out.println(fileName);
        Picture beach = new Picture(fileName);
        beach.show();
     
        //public boolean equals(Object anObject)
     
     
        Scanner keyboard = new Scanner(System.in);
          System.out.println("Please type either 'Green' or 'Pink' to decide which filter to apply.");
          while ((typevalue) != green || (typevalue != pink))
      {
        System.out.println("You have made an invalid selection. Please type either 'Green' or 'Pink' to decide which filter to apply.");
        typevalue = keyboard.nextLine();
      }
        if (typevalue == pink){
        System.out.println("Now displaying picture with pink filter...");
        increasePink(beach);
      }
      else if (typevalue == green){
        System.out.println("Now displaying picture with green filter...");
        increaseGreen(beach);
      }
      }
    }

    Any help would be greatly appreciated.
    Last edited by Methos; January 25th, 2012 at 04:40 PM.


  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Need some help changing the colors of a picture

    Well don't you think you should post the error messages here?
    Paste the entire errors message you're receiving along with the code segments the errors are pointing to.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

Similar Threads

  1. Replies: 5
    Last Post: January 9th, 2012, 02:36 PM
  2. Converting a picture made up of 0s and 1s into a colored picture??
    By Kranti1992 in forum Java Theory & Questions
    Replies: 10
    Last Post: November 21st, 2011, 06:25 PM
  3. How are the colors in Swing's UIManager used?
    By JerryH in forum AWT / Java Swing
    Replies: 0
    Last Post: January 27th, 2011, 10:50 PM
  4. Modify Colors in a Picture
    By theuniverse in forum Java Theory & Questions
    Replies: 0
    Last Post: October 17th, 2009, 04:49 PM
  5. Changing colors of large image in real time
    By chals in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: May 7th, 2009, 05:06 AM