Results 1 to 4 of 4
  1. #1
    kaninchen is offline Member
    Join Date
    Jan 2013
    Location
    Deutschland
    Posts
    2
    Rep Power
    0

    Default pixels and RGB of a .png file

    hello everyone!

    i started to learn java on my own, last night. i have had a little experience with c++ in the past.
    i am doing an exercise where i should create a dialog to load a dark .png file, and then change its RGB values, so i could see the hidden image beyond the darkness.
    i managed to make it load the file and show it (as a test), but i am really confused (specially towards definitions of classes and stuff) when it comes to getting the RGB values and changing them.
    the following contains what i have done sofar:
    Java Code:
    public class ImagePuzzle {  
           
              
            public void solveBlackPuzzle() {  
             
            Picture input = new Picture(FileChooser.pickAFile());  
              
            Picture output = null;  
              
            if (input != null) {  
          
                input.show();         
                 /////////////////////////////////////////////////////   
                 //  HERE ARE THE THINGS DONE. i think.  
                //////////////////////////////////////////////////////  
                    output.show();  
                String directory = "/home/wilker/";    
                output.write(directory + "black-puzzle-solution.png");  
            }  
            }

    this "here are the things done" part, i am trying the following:

    Java Code:
        method to decrease red  
        get the pixels;  
        define an integer that will work as a counter  
        for (int= 0; i < my pixels number; i++)  
        {  
        p = pixels[i];  
        value = p.getRed(); (is getRed a method from color?)  
        p.setRed(something....value*0,2) (is setRed a method from color?)  
          
        now it should show the picture, with the red value changed...  
          
        }
    i have tried many things, watching videos, reading tutorials...but understand things better when i try it instead of reading about it...
    it either shows warnings that i am doing things in the wrong place...or it even compiles without major errors*, but it just open the input file dialog then shows it and thats it.


    Obs: major errors*, because it seems some objects needed are in other classes, so i keep adding classes to my source (for example Picture, FileChooser, etc...) and it seems to be an infinite chain...to finally returns me an error like some weird library cant file a file, like:
    Java Code:
    NetBeansProjects/ImagePuzzle/src/Imagepuzzle/JpegImagesToMovie.java:41: package javax.media.datasink does not exist
    and i dont even directly need this jpegimagestomovie thing...

    sorry if i dont sound clear, but my thoughts are all loose..
    thanks in advance and kind regards!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: pixels and RGB of a .png file

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    kaninchen is offline Member
    Join Date
    Jan 2013
    Location
    Deutschland
    Posts
    2
    Rep Power
    0

    Default Re: pixels and RGB of a .png file

    hi,

    yes, sorry. i am new to forums in general and had no aware that was a bad thing. just thought my chances would be higher if i had it in more places...
    could you please, as moderator, delete it where you find proper to?

    regards

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default Re: pixels and RGB of a .png file

    We don't delete threads just because the question has been cross posted. But we do keep other members informes so they can decide whether they still want to help.

    Some do, some don't.

    db

    PS: look into using HSL color. Search Google and you can find Java implementations for converting between RGB and HSL (or HSB/HSI)
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. help with some pixels
    By HelloWorld1234 in forum New To Java
    Replies: 13
    Last Post: 07-09-2012, 01:58 AM
  2. Pixels
    By shakeel in forum Java 2D
    Replies: 0
    Last Post: 03-01-2011, 12:32 PM
  3. Image to pixels
    By Deva in forum New To Java
    Replies: 6
    Last Post: 04-01-2010, 09:35 PM
  4. get image file from array of pixels
    By mester in forum Advanced Java
    Replies: 1
    Last Post: 12-28-2008, 11:38 AM
  5. Counting Pixels
    By shaungoater in forum Java 2D
    Replies: 5
    Last Post: 11-29-2007, 06:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •