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

14 comments:

Leandro Maríngolo said...

I´m same problem

Anonymous said...

flatten your abs -
forex trading machine -
forex trading made ez -
get your exgirlfriend back -
google snatch -
governmentregistry -
government registry -
grow taller 4 idiots -
guy gets girl -
hcg recipes -
homemadeenergy -
home made energy -
how to break 80 -
hyper vre -
instant domain cash -
i software tv -
jamo rama acoustic -
linden method -
lose the back pain -
magni work -
maternityacupressure -
maternity acupressure -
musclegainingsecrets -
muscle gaining secrets -
negative calorie diet -
one minute cure -
one week marketing -
only 4 gamers -
paid surveys online -
panic away -
pc on point -
pc tv 4 me -
perfect optimizer -
phone number scan -

Anonymous said...

flatten your abs -
forex trading machine -
forex trading made ez -
get your exgirlfriend back -
google snatch -
governmentregistry -
government registry -
grow taller 4 idiots -
guy gets girl -
hcg recipes -
homemadeenergy -
home made energy -
how to break 80 -
hyper vre -
instant domain cash -
i software tv -
jamo rama acoustic -
linden method -
lose the back pain -
magni work -
maternityacupressure -
maternity acupressure -
musclegainingsecrets -
muscle gaining secrets -
negative calorie diet -
one minute cure -
one week marketing -
only 4 gamers -
paid surveys online -
panic away -
pc on point -
pc tv 4 me -
perfect optimizer -
phone number scan -

Anonymous said...

pick the gender of your bady -
power 4 home -
profit lance -
public records pro -
quantum mind power -
quit smoking today -
recipe secrets -
reg clean -
regi cleanse -
registry easy -
registry winner -
reg sweep -
reverse mobile -
reverse phone detective -
revolutioniz -
richard markenzie direct -
sale hoo -
simple php -
smtp 2 go -
spyware nuker -
surveys 4 checks -
tax liens made easy -
the bad breath report -
thedietsolutionprogram -
the diet solution program -
the handcrafters companion -
the retired millionaire -
the super mind evolution system -
truth about abs -
truth about diets -
turbulence training -
ultimate content creator -
video piggy -

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...

driver robot -
earth4energy -
earth 4 energy -
easy tech videos -
eatstopeat -
eat stop eat -
error killer -
error smart -
evidence eraser -
evidence smart -
fatburningfurnace -
fat burning furnace -
fatloss4idiots -
fat loss 4 idiots -
fitnessmodelprogram -
fitness model program -
fit yummy yummy -
flattenyourabs -
flatten your abs -
flat to fab -
forex derivative -
gas 4 free -
get better grades -
golf swing guru -
governmentregistry -
government registry -
heartburn no more -
homemadeenergy -
home made energy -
hyper vre -
i software tv -
legit online jobs -
linden method -
london forex rush -

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...

spyware nuker -
the bad breath report -
thedietsolutionprogram -
the diet solution program -
the stop snoring exercise program -
the super mind evolution system -
trading stock indices -
truth about abs -
turbulencetraining -
turbulence training -
twitter annihilation -
twitter rockstar -
twitter traffic machine -
ultimate content creator -
ultimate font download -
ultimate wow guide -
video piggy -
vincedelmontefitness -
vince del monte fitness -
warp speed fat loss -
web investigator -
win clear -
win spy -
yeast infection no more -

Anonymous said...

3d covers -
500 scrapbooking sketches -
acid alkaline diet -
acne free in 3 days -
advanced pc tweaker -
apple patch diet -
art of approaching -
auction inspector -
av advance -
build a nice store -
burnthefat -
burn the fat -
carb rotation diet -
catch spouse cheating -
chikara reiki do -
combat the fat -
conversationalhypnosis -
conversational hypnosis -
copy that game -
cure gout now -
dl guard -
dog training online -
driver checker -
driver robot -
drop shipping wholesalers -
earth4energy -
earth 4 energy -
easy backup wizard -
eatstopeat -

Anonymous said...

eat stop eat -
error fix -
error killer -
error smart -
evidence eraser -
evidence nuker -
ex girlfriend guru -
fatburningfurnace -
fat burning furnace -
fatloss4idiots -
fat loss 4 idiots -
final uninstaller -
fitnessmodelprogram -
fitness model program -
fit yummy yummy -
flattenyourabs -
flatten your abs -
flat to fab -
forex grid bot -
get google ads free -
get paid to draw -
get this off my chest now -
governmentregistry -
government registry -
heartburn no more -
homemadeenergy -
home made energy -
honest riches -
learn photoshop now -
linden method -
malware removal bot -
marketing on the fringe -
maternityacupressure -
maternity acupressure -

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 -

Anonymous said...

spyware nuker -
spyware remover -
starting a day care center -
the bad breath report -
the cb code -
thedietsolutionprogram -
the diet solution program -
the super mind evolution system -
traffic travis -
truth about abs -
turbulencetraining -
turbulence training -
twitter affiliate cash -
twitter decoded -
video piggy -
video web wizard -
vincedelmontefitness -
vince del monte fitness -
warp speed fat loss -
wedding speech 4u -
windo fix -
your bill killer -
you will get paid -
zygor guides -
20 day persuasion -
advanced pc tweaker -
adware bot -
affiliate naire -
apple patch diet -
article submitter -
art of approaching -
burnthefat -
burn the fat -
carb rotation diet -

Anonymous said...

酒店經紀 酒店打工 酒店工作 酒店上班 酒店兼差 酒店兼職 打工兼差 打工兼職 台北酒店 酒店應徵 禮服酒店 酒店 經紀 打工 兼差

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.