< prev index next >

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

Print this page




2908      *
2909      * @param raster The {@code WritableRaster} from which to extract the
2910      * alpha  channel.
2911      *
2912      * @return A {@code WritableRaster} containing the image's alpha channel.
2913      *
2914      */
2915     public WritableRaster getAlphaRaster(WritableRaster raster) {
2916         if (hasAlpha() == false) {
2917             return null;
2918         }
2919 
2920         int x = raster.getMinX();
2921         int y = raster.getMinY();
2922         int[] band = new int[1];
2923         band[0] = raster.getNumBands() - 1;
2924         return raster.createWritableChild(x, y, raster.getWidth(),
2925                                           raster.getHeight(), x, y,
2926                                           band);
2927     }
2928 
2929     /**
2930      * Compares this color model with another for equality.
2931      *
2932      * @param obj The object to compare with this color model.
2933      * @return {@code true} if the color model objects are equal,
2934      * {@code false} if they are not.
2935      */
2936     public boolean equals(Object obj) {
2937         if (!super.equals(obj)) {
2938             return false;
2939         }
2940 
2941         if (obj.getClass() !=  getClass()) {
2942             return false;
2943         }
2944 
2945         return true;
2946     }
2947 
2948 }


2908      *
2909      * @param raster The {@code WritableRaster} from which to extract the
2910      * alpha  channel.
2911      *
2912      * @return A {@code WritableRaster} containing the image's alpha channel.
2913      *
2914      */
2915     public WritableRaster getAlphaRaster(WritableRaster raster) {
2916         if (hasAlpha() == false) {
2917             return null;
2918         }
2919 
2920         int x = raster.getMinX();
2921         int y = raster.getMinY();
2922         int[] band = new int[1];
2923         band[0] = raster.getNumBands() - 1;
2924         return raster.createWritableChild(x, y, raster.getWidth(),
2925                                           raster.getHeight(), x, y,
2926                                           band);
2927     }




















2928 }
< prev index next >