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
17package android.graphics;
18
19public 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    public static final int RGBA_5551   = 6;
43    public static final int RGBA_4444   = 7;
44    public static final int A_8         = 8;
45    public static final int L_8         = 9;
46    public static final int LA_88       = 0xA;
47    public static final int RGB_332     = 0xB;
48
49
50    /**
51     * @deprecated use {@link android.graphics.ImageFormat#NV16
52     * ImageFormat.NV16} instead.
53     */
54    @Deprecated
55    public static final int YCbCr_422_SP= 0x10;
56
57    /**
58     * @deprecated use {@link android.graphics.ImageFormat#NV21
59     * ImageFormat.NV21} instead.
60     */
61    @Deprecated
62    public static final int YCbCr_420_SP= 0x11;
63
64    /**
65     * @deprecated use {@link android.graphics.ImageFormat#YUY2
66     * ImageFormat.YUY2} instead.
67     */
68    @Deprecated
69    public static final int YCbCr_422_I = 0x14;
70
71    /**
72     * @deprecated use {@link android.graphics.ImageFormat#JPEG
73     * ImageFormat.JPEG} instead.
74     */
75    @Deprecated
76    public static final int JPEG        = 0x100;
77
78    /*
79     * We use a class initializer to allow the native code to cache some
80     * field offsets.
81     */
82    native private static void nativeClassInit();
83    static { nativeClassInit(); }
84
85    public static native void getPixelFormatInfo(int format, PixelFormat info);
86    public static boolean formatHasAlpha(int format) {
87        switch (format) {
88            case PixelFormat.A_8:
89            case PixelFormat.LA_88:
90            case PixelFormat.RGBA_4444:
91            case PixelFormat.RGBA_5551:
92            case PixelFormat.RGBA_8888:
93            case PixelFormat.TRANSLUCENT:
94            case PixelFormat.TRANSPARENT:
95                return true;
96        }
97        return false;
98    }
99
100    public int  bytesPerPixel;
101    public int  bitsPerPixel;
102}
103