I have been trying out some basic image processing using java (after a long gap).
Any operation I do on the original image and save it as a new image -> the o/p image always appears DULL (may be an issue with opacity or transparency).
I am pasting the function which I am using to do this job below :
//Returns a blurred java buffered image
public static BufferedImage blurImage(BufferedImage image)
{
int w = image.getWidth();
int h = image.getHeight();
int alpha = 0;
int red, green, blue, newPix;
int pix[] = null;
BufferedImage newImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
for(int i=0,j=0; i<w; i++)
{
for(j=0; j<h; j++)
{
pix = getSurroundingPixels(image, i>0?i-1:0, i<w-1?i+1:w-1, j>0?j-1:0, j<h-1?j+1:h-1);
red = green = blue = 0;
for(int k=0; k<pix.length; k++)
{
red += (pix[k]>>16) & 0xFF;
green += (pix[k]>>8) & 0xFF;
blue += (pix[k]) & 0xFF;
}
alpha = (image.getRGB(i,j)>>24) & 0xFF;
red /= pix.length;
green /= pix.length;
blue /= pix.length;
newPix = ((alpha<<24) | (red<<16) | (green<<8) | blue);
newImage.setRGB(i,j, newPix);
}
}
return newImage;
}
I would appreciate someone helping me on this issue.