Wednesday, June 27, 2007

I had this requirement to pick the pixel color from an image. I usually use a image editor program that I have to select the color. Iam aware that programs like photoshop would do this kind of thing quite easily. But it didn't make sense to start photoshop if it wasn't already running just for this small requirement. As usually the case with free programs, the image editor software started acting strange and would not tell me the color. So I began searching the net for ColorPicker programs. Most of the results were for html websites that allow you to select web safe colors. There was a flash based one which I couldn't use because I didn't have flash installed. Another was a COM based google gadget which I couldn't test because I didn't have google desktop installed. So I went to the usually reliable Java for a solution. Only in this case it didn't prove so reliable after all. I call it usually reliable because there's always some java code out there that does what you want. A small example would be when I had to capture a screenshot and the print screen function was not working. A java code I found on the net did just what I wanted. I was hoping for something similar to happen with the color picker as well. But no luck. To select a color from an image, you would have to be able to manipulate the image at the pixel level. Java 2D allowed you to do that. But life is never simple, is it? I was working with a jpg file and to obtain a BufferedImage from a jpg file, you need a jpeg decoder. The sample code said that this could be done using something like below:

InputStream in = ClipImage.class.getResourceAsStream(imgFile);
JPEGImageDecoder decoder = JPEGDecoder.createJPEGDecoder(in);
final BufferedImage bufferedImage = decoder.decodeAsBufferedImage();
in.close();

Only the jai-imageio project which contained JPEGImageDecoder did not have any JPEGDecoder in it. So it was back to search for JPEGDecoder and there were very few hits. The GNU classpath project had a JPEGDecoder and after getting all the files, it became evident that it wasn't quite the same as the decoder I wanted. The documentation was also scarce and by then I was able to get the color I wanted by running the image editor on my laptop.

Moral of the story: Don't go on a wild goose chase

5 comments:

Leandro MarĂ­ngolo said...

I´m same problem

Anonymous said...

vincedelmontefitness -
vince del monte fitness -
viral tweets -
warp speed fat loss -
webstigate -
win clear -
win spy -
worlds best compost -
xp repair pro -
yeast infection no more -
your approved -
500 love making tips -
acid alkaline diet -
advanced defrag -
amazing resume creator -
anti spyware -
art of approaching -
av advance -
banish tonsil stones -
bookmarking demon -
burnthefat -
burn the fat -
carb rotation diet -
catch spouse cheating -
cb affiliate blueprints -
combat the fat -
conversationalhypnosis -
conversational hypnosis -
cure angular cheilitis -
directory of ezines -
dirty talking guide -
dish tv for pc -
dog training online -
domain sales machine -

Anonymous said...

master word smith -
maternityacupressure -
maternity acupressure -
max pro system -
meet your sweet -
membership gold rush -
minute sites -
musclegainingsecrets -
muscle gaining secrets -
negative calorie diet -
one minute cure -
one week marketing -
pc on point -
pc tv 4 me -
perfect optimizer -
php link cloaker -
pick the gender of your baby -
profit lance -
public records pro -
quit smoking today -
recipe secrets -
reg clean -
regi cleanse -
registry easy -
registry winner -
reg sweep -
reverse mobile -
reverse phone detective -
richard mackenzie direct -
rocket piano -
rocket spanish -
satellite tv to pc -
smtp 2 go -
spam bully -

Anonymous said...

meet your sweet -
musclegainingsecrets -
muscle gaining secrets -
my online income system -
negative calorie diet -
no adware -
one minute cure -
one week marketing -
online pickup secrets -
partenon -
pc on point -
perfect optimizer -
perfect uninstaller -
pick the gender of your baby -
power cash secret -
profit lance -
publicrecordspro -
public records pro -
push button marketer -
quit smoking today -
registry easy -
registry easy download -
registry fix -
registry winner download -
reverse mobile -
reverse phone detective -
richard mackenzie direct -
rocket spanish -
rss power plus -
sem business blueprint -
silent sales machine -
spam bully -
sports betting champ -
spyware cease -

Penis Enlargement Pills said...

I recently came across your blog and have been reading along. I think I will leave my first comment.
I don’t know what to say except that I have enjoyed reading. Nice blog.
I will keep visiting this blog very often.
By the way,
Blogger how when you visit my blog,
My Blog have been created for the satisfaction of consumer of all.