Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
Jun 24, 2008

Create a "Flea" Filter Using the RGBImageFilter Class

This tip demonstrates how to build a "flea" filter based on the RGBImageFilter class. The filtered picture will look like the image displayed on old TVs.

import java.awt.image.*;
import java.util.*;
import java.awt.*;

public class FleaFilter extends RGBImageFilter
{

   ColorModel cm=ColorModel.getRGBdefault();

   public FleaFilter()
   {
      canFilterIndexColorModel=true;
   }

   public int filterRGB(int x, int y, int rgb)
   {	      
      Random Rred=new Random();
      Random Rgreen=new Random();
      Random Rblue=new Random();
      Color backup=new Color(Rred.nextInt(255),
         Rgreen.nextInt(255),Rblue.nextInt(255));      
      return rgb|backup.getRGB();
   }
}
Leonard Anghel
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap