![]() |
The Java Developers Almanac 1.4Order this book from Amazon. |
e665. Filtering the RGB Values in an ImageThis example demonstrates how to create a filter that can modify any of the RGB pixel values in an image. // This filter removes all but the red values in an image
class GetRedFilter extends RGBImageFilter {
public GetRedFilter() {
// When this is set to true, the filter will work with images
// whose pixels are indices into a color table (
Here's some code that uses the filter:
// Get image Image image = new ImageIcon("image.gif").getImage(); // Create the filter ImageFilter filter = new GetRedFilter(); FilteredImageSource filteredSrc = new FilteredImageSource(image.getSource(), filter); // Create the filtered image image = Toolkit.getDefaultToolkit().createImage(filteredSrc);
e661. Determining If an Image Has Transparent Pixels e662. Getting the Color Model of an Image e663. Getting the Transparent Pixel and Number of Colors Used in a GIF Image e664. Getting a Sub-Image of an Image
© 2002 Addison-Wesley. |