1 /* 2 * Copyright (C) 2006 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 17 package android.graphics; 18 19 public class PixelFormat 20 { 21 /* these constants need to match those in hardware/hardware.h */ 22 23 public static final int UNKNOWN = 0; 24 25 /** System chooses a format that supports translucency (many alpha bits) */ 26 public static final int TRANSLUCENT = -3; 27 28 /** 29 * System chooses a format that supports transparency 30 * (at least 1 alpha bit) 31 */ 32 public static final int TRANSPARENT = -2; 33 34 /** System chooses an opaque format (no alpha bits required) */ 35 public static final int OPAQUE = -1; 36 37 public static final int RGBA_8888 = 1; 38 public static final int RGBX_8888 = 2; 39 public static final int RGB_888 = 3; 40 public static final int RGB_565 = 4; 41 42 @Deprecated 43 public static final int RGBA_5551 = 6; 44 @Deprecated 45 public static final int RGBA_4444 = 7; 46 public static final int A_8 = 8; 47 public static final int L_8 = 9; 48 @Deprecated 49 public static final int LA_88 = 0xA; 50 @Deprecated 51 public static final int RGB_332 = 0xB; 52 53 54 /** 55 * @deprecated use {@link android.graphics.ImageFormat#NV16 56 * ImageFormat.NV16} instead. 57 */ 58 @Deprecated 59 public static final int YCbCr_422_SP= 0x10; 60 61 /** 62 * @deprecated use {@link android.graphics.ImageFormat#NV21 63 * ImageFormat.NV21} instead. 64 */ 65 @Deprecated 66 public static final int YCbCr_420_SP= 0x11; 67 68 /** 69 * @deprecated use {@link android.graphics.ImageFormat#YUY2 70 * ImageFormat.YUY2} instead. 71 */ 72 @Deprecated 73 public static final int YCbCr_422_I = 0x14; 74 75 /** 76 * @deprecated use {@link android.graphics.ImageFormat#JPEG 77 * ImageFormat.JPEG} instead. 78 */ 79 @Deprecated 80 public static final int JPEG = 0x100; 81 82 /* 83 * We use a class initializer to allow the native code to cache some 84 * field offsets. 85 */ 86 native private static void nativeClassInit(); 87 static { nativeClassInit(); } 88 89 public static native void getPixelFormatInfo(int format, PixelFormat info); 90 public static boolean formatHasAlpha(int format) { 91 switch (format) { 92 case PixelFormat.A_8: 93 case PixelFormat.LA_88: 94 case PixelFormat.RGBA_4444: 95 case PixelFormat.RGBA_5551: 96 case PixelFormat.RGBA_8888: 97 case PixelFormat.TRANSLUCENT: 98 case PixelFormat.TRANSPARENT: 99 return true; 100 } 101 return false; 102 } 103 104 public int bytesPerPixel; 105 public int bitsPerPixel; 106 } 107