Trivial to change the color of pixels in a IconImage?

  • Follow


Does anyone know whether its a trivial matter to change the color of 
some pixels of an IconImage? I know I can work with it through a 
BufferedImage but how then do I go about changing the color. I suppose 
it is not as simple as changing an entry of some palette.

Regards,
Casper
0
Reply Casper 4/11/2006 1:42:05 PM

Casper B. wrote:
> Does anyone know whether its a trivial matter to change the color of 
> some pixels of an IconImage?

It depends on your definition of trivial.

> I know I can work with it through a 
> BufferedImage but how then do I go about changing the color. I suppose 
> it is not as simple as changing an entry of some palette.

Just a rough untested sketch, if you want to do it the old, slow way:


   import java.awt.image.*;

   class MyFilter extends RGBImageFilter {
	public int filterRGB(int x, int y, int rgb) {
		// do some change to rgb
		return rgb;
	}
   }


   ImageIcon ii = ...;
   FilteredImageSource fis = new FilteredImageSource(
	ii.getImage().getImageSource(),
	new MyFilter());

   Image changedImage = Toolkit.getDefaultToolkit().createImage(fis);

   ii.setImage(changeImage);

   //
   // inform the users of the ImageIcon that they probably need to
   // repaint themself
   //



/Thomas
-- 
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
0
Reply Thomas 4/11/2006 2:23:34 PM


1 Replies
239 Views

(page loaded in 0.028 seconds)

Similiar Articles:











7/24/2012 4:44:49 AM


Reply: