jdk/src/share/classes/sun/awt/image/ImagingLib.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.awt.image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.geom.AffineTransform;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.image.AffineTransformOp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.image.BufferedImage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.image.BufferedImageOp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.image.ByteLookupTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.image.ConvolveOp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.image.Kernel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.image.LookupOp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.image.LookupTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.image.RasterOp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.image.Raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.image.WritableRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * This class provides a hook to access platform-specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * imaging code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * If the implementing class cannot handle the op, tile format or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * image format, the method will return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * If there is an error when processing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * data, the implementing class may either return null
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * (in which case our java code will be executed) or may throw
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * an exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
public class ImagingLib {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    static boolean useLib = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    static boolean verbose = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private static final int NUM_NATIVE_OPS = 3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private static final int LOOKUP_OP   = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private static final int AFFINE_OP   = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private static final int CONVOLVE_OP = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private static Class[] nativeOpClass = new Class[NUM_NATIVE_OPS];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Returned value indicates whether the library initailization was
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * succeded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * There could be number of reasons to failure:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * - failed to load library.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * - failed to get all required entry points.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private static native boolean init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    static public native int transformBI(BufferedImage src, BufferedImage dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                                         double[] matrix, int interpType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    static public native int transformRaster(Raster src, Raster dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                                             double[] matrix,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                                             int interpType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    static public native int convolveBI(BufferedImage src, BufferedImage dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                                        Kernel kernel, int edgeHint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    static public native int convolveRaster(Raster src, Raster dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                                            Kernel kernel, int edgeHint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    static public native int lookupByteBI(BufferedImage src, BufferedImage dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                                        byte[][] table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    static public native int lookupByteRaster(Raster src, Raster dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                                              byte[][] table);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        PrivilegedAction<Boolean> doMlibInitialization =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            new PrivilegedAction<Boolean>() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                public Boolean run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                    String arch = System.getProperty("os.arch");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                    if (arch == null || !arch.startsWith("sparc")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                            System.loadLibrary("mlib_image");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                        } catch (UnsatisfiedLinkError e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                            return Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                    boolean success =  init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                    return Boolean.valueOf(success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        useLib = AccessController.doPrivileged(doMlibInitialization);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        // Cache the class references of the operations we know about
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        // at the time this class is initially loaded.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            nativeOpClass[LOOKUP_OP] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                Class.forName("java.awt.image.LookupOp");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        } catch (ClassNotFoundException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            System.err.println("Could not find class: "+e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            nativeOpClass[AFFINE_OP] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                Class.forName("java.awt.image.AffineTransformOp");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        } catch (ClassNotFoundException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            System.err.println("Could not find class: "+e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            nativeOpClass[CONVOLVE_OP] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                Class.forName("java.awt.image.ConvolveOp");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        } catch (ClassNotFoundException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            System.err.println("Could not find class: "+e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    private static int getNativeOpIndex(Class opClass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        // Search for this class in cached list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        // classes supplying native acceleration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        int opIndex = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        for (int i=0; i<NUM_NATIVE_OPS; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            if (opClass == nativeOpClass[i]) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                opIndex = i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        return opIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public static WritableRaster filter(RasterOp op, Raster src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                                        WritableRaster dst) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        if (useLib == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        // Create the destination tile
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        if (dst == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            dst = op.createCompatibleDestRaster(src);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        WritableRaster retRaster = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        switch (getNativeOpIndex(op.getClass())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
          case LOOKUP_OP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            // REMIND: Fix this!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            LookupTable table = ((LookupOp)op).getTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            if (table.getOffset() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                // Right now the native code doesn't support offsets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            if (table instanceof ByteLookupTable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                ByteLookupTable bt = (ByteLookupTable) table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                if (lookupByteRaster(src, dst, bt.getTable()) > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                    retRaster = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
          case AFFINE_OP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            AffineTransformOp bOp = (AffineTransformOp) op;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            double[] matrix = new double[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            bOp.getTransform().getMatrix(matrix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            if (transformRaster(src, dst, matrix,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                                bOp.getInterpolationType()) > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                retRaster =  dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
          case CONVOLVE_OP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            ConvolveOp cOp = (ConvolveOp) op;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            if (convolveRaster(src, dst,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                               cOp.getKernel(), cOp.getEdgeCondition()) > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                retRaster = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        if (retRaster != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            SunWritableRaster.markDirty(retRaster);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        return retRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    public static BufferedImage filter(BufferedImageOp op, BufferedImage src,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                                       BufferedImage dst)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        if (verbose) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            System.out.println("in filter and op is "+op
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                               + "bufimage is "+src+" and "+dst);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        if (useLib == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        // Create the destination image
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        if (dst == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            dst = op.createCompatibleDestImage(src, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        BufferedImage retBI = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        switch (getNativeOpIndex(op.getClass())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
          case LOOKUP_OP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            // REMIND: Fix this!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            LookupTable table = ((LookupOp)op).getTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            if (table.getOffset() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                // Right now the native code doesn't support offsets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            if (table instanceof ByteLookupTable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                ByteLookupTable bt = (ByteLookupTable) table;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                if (lookupByteBI(src, dst, bt.getTable()) > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                    retBI = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
          case AFFINE_OP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            AffineTransformOp bOp = (AffineTransformOp) op;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            double[] matrix = new double[6];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
            AffineTransform xform = bOp.getTransform();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            bOp.getTransform().getMatrix(matrix);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            if (transformBI(src, dst, matrix,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                            bOp.getInterpolationType())>0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                retBI = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
          case CONVOLVE_OP:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            ConvolveOp cOp = (ConvolveOp) op;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            if (convolveBI(src, dst, cOp.getKernel(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                           cOp.getEdgeCondition()) > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                retBI = dst;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
          default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        if (retBI != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            SunWritableRaster.markDirty(retBI);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        return retBI;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
}