< prev index next >

src/java.desktop/share/classes/java/awt/image/RGBImageFilter.java

Print this page


   1 /*
   2  * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  48  *              // filtered directly.
  49  *              canFilterIndexColorModel = true;
  50  *          }
  51  *
  52  *          public int filterRGB(int x, int y, int rgb) {
  53  *              return ((rgb & 0xff00ff00)
  54  *                      | ((rgb & 0xff0000) >> 16)
  55  *                      | ((rgb & 0xff) << 16));
  56  *          }
  57  *      }
  58  *
  59  * }</pre>
  60  *
  61  * @see FilteredImageSource
  62  * @see ImageFilter
  63  * @see ColorModel#getRGBdefault
  64  *
  65  * @author      Jim Graham
  66  */
  67 public abstract class RGBImageFilter extends ImageFilter {





  68 
  69     /**
  70      * The {@code ColorModel} to be replaced by
  71      * {@code newmodel} when the user calls
  72      * {@link #substituteColorModel(ColorModel, ColorModel) substituteColorModel}.
  73      */
  74     protected ColorModel origmodel;
  75 
  76     /**
  77      * The {@code ColorModel} with which to
  78      * replace {@code origmodel} when the user calls
  79      * {@code substituteColorModel}.
  80      */
  81     protected ColorModel newmodel;
  82 
  83     /**
  84      * This boolean indicates whether or not it is acceptable to apply
  85      * the color filtering of the filterRGB method to the color table
  86      * entries of an IndexColorModel object in lieu of pixel by pixel
  87      * filtering.  Subclasses should set this variable to true in their


   1 /*
   2  * Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  48  *              // filtered directly.
  49  *              canFilterIndexColorModel = true;
  50  *          }
  51  *
  52  *          public int filterRGB(int x, int y, int rgb) {
  53  *              return ((rgb & 0xff00ff00)
  54  *                      | ((rgb & 0xff0000) >> 16)
  55  *                      | ((rgb & 0xff) << 16));
  56  *          }
  57  *      }
  58  *
  59  * }</pre>
  60  *
  61  * @see FilteredImageSource
  62  * @see ImageFilter
  63  * @see ColorModel#getRGBdefault
  64  *
  65  * @author      Jim Graham
  66  */
  67 public abstract class RGBImageFilter extends ImageFilter {
  68 
  69     /**
  70      * Constructor for subclasses to call.
  71      */
  72     protected RGBImageFilter() {}
  73 
  74     /**
  75      * The {@code ColorModel} to be replaced by
  76      * {@code newmodel} when the user calls
  77      * {@link #substituteColorModel(ColorModel, ColorModel) substituteColorModel}.
  78      */
  79     protected ColorModel origmodel;
  80 
  81     /**
  82      * The {@code ColorModel} with which to
  83      * replace {@code origmodel} when the user calls
  84      * {@code substituteColorModel}.
  85      */
  86     protected ColorModel newmodel;
  87 
  88     /**
  89      * This boolean indicates whether or not it is acceptable to apply
  90      * the color filtering of the filterRGB method to the color table
  91      * entries of an IndexColorModel object in lieu of pixel by pixel
  92      * filtering.  Subclasses should set this variable to true in their


< prev index next >