Posted by cocopopsicle
on January 13, 2009 at 2:15 PM PST
I am having a little trouble with my code at the minuite, I have tried quite alot of things and can not see why I am failing.
Ok what I'm doing is getting a image loading it from my C drive into a Image and then casting that image into a BufferedImage - note this is proberbly totaly the wrong way to go about this, but it's my first time playing with such things.
Ok so now I have my BufferedImage, it has width and heigh, I now use two for loops one inside the other to scan through each pixel.
For each pixel I am splitting it up into it's four parts like so
int alpha = (pixel >> 24) & 0xff;
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = (pixel ) & 0xff;
I set the blue pixel to 255 and leave the rest as they are and then reload the pixel into a into like so
pixel = (24 >> alpha) | (red << 16) | (green << 8) | blue;
When I then BufferedImage.setpixel(x, y, pixel) and save the resulting Buffered Image with should now have all blue components set to 255
but when I reload the image and scan through again this is not the case, I am thinking now that my int 'pixel' is in the wrong format and setPixel is not working correctly, but I can not fathom this for the life of me.
Any help will be appreciated, Thank you all, Chris