• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Pixel Information of a Image using Link List

If some one could provide me with a code which extracts the pixel information of an image of any type (Information refers to the RGB Color and the width & Height of the image).  The information of the image should be stored in a Link List.

Regards
0
ZUBAIR
Asked:
ZUBAIR
1 Solution
 
zzynxSoftware engineerCommented:
0
 
Mayank SAssociate Director - Product EngineeringCommented:
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
TimYatesCommented:
>> The information of the image should be stored in a Link List.

Each pixel should be a node in a linked list?

I'm guessing this is a homework assignement, as that makes little or no sense otherwise ;-)
0
 
ZUBAIRAuthor Commented:
Thanks for your comment Tim,

I am learning java and it is obvious that a beginner needs a push or a help from there friends.

Anyhow what i was trying to do was that i need to store information of each and every pixel in a Link list where every pixels properties are saved individually, values of red, green, blue and the axis on which the pixel is lying (X-1, Y-1).

If you need further clarification - please do comment
0
 
TimYatesCommented:
Why don't you just use an array of int?

    int w = img.getWidth() ;
    int h = img.getHeight() ;
    int[] pixels = new int[ w * h ] ;

then, you can get the current X, Y position by modding and dividing like so:

    // loop  through every pixel
    for( int i = 0 ; i < pixels.length ; i++ )
    {
        int x = i % w ;
        int y = i / w ;
    }

and you can get the red, green and blue pixel colours by shifting and bitwise ANDing:

  public final static int getRed(int color) {
    return (color & 0x00FF0000 ) >>> 16 ;
  }

  public final static int getGreen(int color) {
    return (color & 0x0000FF00 ) >>> 8;
  }

  public final static int getBlue(int color) {
    return ( color & 0x000000FF ) ;
  }
0
 
TimYatesCommented:
Storing it in a linked list would lead to using a lot of memory very quickly...  
0
 
ZUBAIRAuthor Commented:
Thanks Tim,

The reason i am doing so is to learn about linklist. If you could guide me - i would be grateful
0
 
TimYatesCommented:
http://www.idevelopment.info/data/Programming/data_structures/java/LinkedList/LinkedList.shtml

is an example of writing your own linked list in java :-)

http://java.sun.com/j2se/1.4.2/docs/api/java/util/LinkedList.html is a java class which does it all for you (which I guess you don't want) :-)

Tim
0
 
TimYatesCommented:
what specific difficulty do you have with your code?

I can't just write a Linked list for you...but I may be able to point out bugs in your existing code...

Tim
0
 
ZUBAIRAuthor Commented:
Thanks a lot Tim :)

I have understood the basic concept of link list - i am a bit confused that how to store 5 different informations in a single node. (Five Different Information are ; RGB Color + X & Y axis of the pixel)

Zubair
0
 
TimYatesCommented:
public class Node
{
    Node next ; // the next node in the list
    int someValue ;
    String someString ;
    double whatever ;
    int anotherInt ;
}

etc..

it's a class...store whatever you want in it :-)

Tim
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now