Re: Invert image colours
- From: Thomas Fritsch <i.dont.like.spam@xxxxxxxxxxx>
- Date: Tue, 12 Sep 2006 10:03:19 GMT
k0m0r schrieb:
Hmm maybe I was asking a wrong question.int rgb = image.getRGB(x,y);
I have a BufferedImage and I need to convert the colour of every pixel
to the opposite value,
for example if the rgb is (0,100,255), I need to convert it to
(255,155,0).
I was trying with a manual, but don't know a few things:
I've got two loops:
0 < x < image.getWidth()
0 < y < image.getHeight()
Inside, I can get the RGB value of every pixel:
int rgb = image.getRGB(x,y);
Now, how can I convert this value to the way I want?
I know the RGB contains also alpha value - and I want this to stay
untouched.
Rest of the values should be set to (255-value) and then set back into
int rgb.
How can I do that?
rgb = rgb ^ 0x00FFFFFF; // ^ is the bit-wise exclusive-or
image.setRGB(x, y, rgb);
--
Thomas
.
- Prev by Date: Re: availableProcessors() : wrong amont of CPU?
- Next by Date: Eclipse sharing a group of classes between projects
- Previous by thread: University Research: Survey about searching for open source code on the Internet
- Next by thread: Eclipse sharing a group of classes between projects
- Index(es):
Relevant Pages
|
|