0

Hi, I am new to java programming, but i have this problem:

I open an image, i put ir in array 2 dimensional, teh idea is like this


array[count][0]=x;
array[count][1]=y
array[count][2]=red;
array[count][3]=green;
array[count][4]=blue;
array[count][5]=alpha;


I do so becaude i need to work with colors, but later on i want to save all changes in image. Can you please help me?! Some links with more info could be nice.

Thank you

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by stultuske
0

Hi, I am new to java programming, but i have this problem:

I open an image, i put ir in array 2 dimensional, teh idea is like this


array[count][0]=x;
array[count][1]=y
array[count][2]=red;
array[count][3]=green;
array[count][4]=blue;
array[count][5]=alpha;


I do so becaude i need to work with colors, but later on i want to save all changes in image. Can you please help me?! Some links with more info could be nice.

Thank you

hmmm ... don't have the time to look into it right now, but you're just showing a one-dimensional array.

a two-dimensional one would look like:

String[][] ColorAndDebt = new String[2][2];
ColorAndDebt[0] = {"RED","285"};
ColorAndDebt[1] = {"BLUE","180"};
0

i think you expect this

Object[][] data = new Object[][] {
                           { 
        	            new ImageIcon("atr.gif"),
                           new ImageIcon("atr.gif")
                             }
                                                  }
0

hmmm ... don't have the time to look into it right now, but you're just showing a one-dimensional array.

a two-dimensional one would look like:

String[][] ColorAndDebt = new String[2][2];
ColorAndDebt[0] = {"RED","285"};
ColorAndDebt[1] = {"BLUE","180"};

Uhm, no, array[index1][index2] = x is also a two dimensional array, just accessing an individual element rather than an entire array element from the "outer" array.

Anyway, OP. Use BufferedImage to create an image, then use getGraphics to get a Graphics2D object, then use setRGB once for each element.

Edit: But, in any case, unless you simply want to save it in that format to be "human readable", then you should simply be using ImageIO to save it as a regular image (format of your choice, i.e. gif, jpeg, png, etc) and you can use the varying Image methods to retreive the color and coordinate data directly from the image.

Edited by masijade: n/a

0

Uhm, no, array[index1][index2] = x is also a two dimensional array, just accessing an individual element rather than an entire array element from the "outer" array.

you're right there, but I ment that, since couter was never altered, however still a 2 dimensional array, seemed a lot to be like a 1 dimensional, not a very efficiënt way to use a 2 dimensional one

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.