Coloured Image
1 posts in topic
Flat View  Flat View

Posted By:   Anja_Kratzer
Posted On:   Sunday, April 21, 2002 08:28 AM

I have an image and i want to display it, but without a special colour, for example without blue

Re: Coloured Image

Posted By:   Tanveer_Rameez  
Posted On:   Tuesday, May 28, 2002 01:52 AM

first grab the pixels of that image into a int array using PixelGrabber class. then using a for loop scan all pixels and replace the blue color with the desired color. then obtain image from that int array:

//asuming you already have loaded the image
pixels=new int[width*height];
PixelGrabber pg=new PixelGrabber(image,0,0,width,height,pixels,0,width);
catch(InterruptedException ie){}
Color color=null;
for(int i=0;i{
color=new Color(pixels[i]);
if(color.getBlue(0==255 &7 color.getRed()==0 && color.getGreen()==0) //Note: only pure blue will be replaced

//now convert the pixels array to image
MemoryImageSource imageSource = new MemoryImageSource(width,height,pixels,0,width);
Image image=Toolkit.getDefaultToolkit().createImage(imageSource);
About | Sitemap | Contact