1/* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.graphics; 18 19public class ColorMatrixColorFilter extends ColorFilter { 20 /** 21 * Create a colorfilter that transforms colors through a 4x5 color matrix. 22 * 23 * @param matrix 4x5 matrix used to transform colors. It is copied into 24 * the filter, so changes made to the matrix after the filter 25 * is constructed will not be reflected in the filter. 26 */ 27 public ColorMatrixColorFilter(ColorMatrix matrix) { 28 native_instance = nativeColorMatrixFilter(matrix.getArray()); 29 } 30 31 /** 32 * Create a colorfilter that transforms colors through a 4x5 color matrix. 33 * 34 * @param array array of floats used to transform colors, treated as a 4x5 35 * matrix. The first 20 entries of the array are copied into 36 * the filter. See ColorMatrix. 37 */ 38 public ColorMatrixColorFilter(float[] array) { 39 if (array.length < 20) { 40 throw new ArrayIndexOutOfBoundsException(); 41 } 42 native_instance = nativeColorMatrixFilter(array); 43 } 44 45 private static native int nativeColorMatrixFilter(float[] array); 46} 47