• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pixels and RGB of a .png file

 
Mano Wilk
Greenhorn
Posts: 4
Debian VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone,

i started learning java last night. i had a previous little knowledge with c++, somewhere in the past.

i am doing an exercise where i load a black picture, change its RGB values and then i could see the hidden image. i have read much about filechooser and so...and finally i made it to get a little window asking me to choose a file.
now my ideas are too "loose" yet, and i am confused and dont know what to do.
I have seen many examples that do what i want.
It seems the right way is to count every pixel of the .png file? and using something similar to getRed, getBlue, getGreen for every i (means width) and j (height)?
so the idea is, e.g i have a 4x4 image, i.e 16 pixels (?) then i would use the getRed getBlue getGreen stuff to grab the RGB of each pixel? That means 16 data values?
so i would edit these 16 values, like *0,5 if i want to decrease the RGB level and so?
i cant understand how my code would ordenate all the pixels again at the end...
isnt there a way to get a data like "this is the RGB value of the image" instead of "those are the RGB values of every pixel"?
sorry if this is a too abstract question, but i dont know how to express my problem, as i said, i am rather confused.
and i apologize i dont have a code to post, but this part of the code i dont have yet. All the other parts are: creating object for the picture, loading a picture, showing a picture [here i should add the code to edit the RGB values] and then save this new picture somewhere. and i dont think they would help in this part...
 
Rajdeep Biswas
Ranch Hand
Posts: 216
1
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch. Can you give some pseudocode or dumb text how you have done so far and what are the results?
 
Mano Wilk
Greenhorn
Posts: 4
Debian VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajdeep Biswas wrote:Welcome to the Ranch. Thats all for now!


hello!

kind regards
 
Mano Wilk
Greenhorn
Posts: 4
Debian VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajdeep Biswas wrote:Welcome to the Ranch. Can you give some pseudocode or dumb text how you have done so far and what are the results?


yes, i will try



so, i believe where "here are the things done" i should tell the program to the following:



thank you
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what the "Picture" class does, but I would use the javax.imageio.ImageIO class to read and write the image; it provides you with a BufferedImage object that you can use to get and set individual pixel values.

Note that the R, G, B and alpha values of a particular pixel are encoded in a single int value, so you need to do some bitwise arithmetic to extract (and later reassemble) them from the int.
 
Mano Wilk
Greenhorn
Posts: 4
Debian VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:I'm not sure what the "Picture" class does, but I would use the javax.imageio.ImageIO class to read and write the image; it provides you with a BufferedImage object that you can use to get and set individual pixel values.


thank you for the reply!
these are the methods of Pictures:


other class i think i should use is Pixels:


I am thinking in creating a pixel[i] and while i is smaller than my pixel numbers:



Note that the R, G, B and alpha values of a particular pixel are encoded in a single int value, so you need to do some bitwise arithmetic to extract (and later reassemble) them from the int.

I see. That means my "value" could not be used as i wrote and i should interpret it using arithmetic?

thanks for your time and
kind regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic