• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
22        in ui/PixelFormat.h & pixelflinger/format.h */
23 
24     public static final int UNKNOWN     = 0;
25 
26     /** System chooses a format that supports translucency (many alpha bits) */
27     public static final int TRANSLUCENT = -3;
28 
29     /**
30      * System chooses a format that supports transparency
31      * (at least 1 alpha bit)
32      */
33     public static final int TRANSPARENT = -2;
34 
35     /** System chooses an opaque format (no alpha bits required) */
36     public static final int OPAQUE      = -1;
37 
38     public static final int RGBA_8888   = 1;
39     public static final int RGBX_8888   = 2;
40     public static final int RGB_888     = 3;
41     public static final int RGB_565     = 4;
42 
43     public static final int RGBA_5551   = 6;
44     public static final int RGBA_4444   = 7;
45     public static final int A_8         = 8;
46     public static final int L_8         = 9;
47     public static final int LA_88       = 0xA;
48     public static final int RGB_332     = 0xB;
49 
50     /**
51      * YCbCr formats, used for video. These are not necessarily supported
52      * by the hardware.
53      */
54     public static final int YCbCr_422_SP= 0x10;
55 
56     /** YCbCr format used for images, which uses the NV21 encoding format.
57      *  This is the default format for camera preview images, when not
58      *  otherwise set with
59      *  {@link android.hardware.Camera.Parameters#setPreviewFormat(int)}.
60      */
61     public static final int YCbCr_420_SP= 0x11;
62 
63     /** YCbCr format used for images, which uses YUYV (YUY2) encoding format.
64      *  This is an alternative format for camera preview images. Whether this
65      *  format is supported by the camera hardware can be determined by
66      *  {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.
67      */
68     public static final int YCbCr_422_I = 0x14;
69 
70     /**
71      * Encoded formats.  These are not necessarily supported by the hardware.
72      */
73     public static final int JPEG        = 0x100;
74 
75     /*
76      * We use a class initializer to allow the native code to cache some
77      * field offsets.
78      */
nativeClassInit()79     native private static void nativeClassInit();
nativeClassInit()80     static { nativeClassInit(); }
81 
getPixelFormatInfo(int format, PixelFormat info)82     public static native void getPixelFormatInfo(int format, PixelFormat info);
formatHasAlpha(int format)83     public static boolean formatHasAlpha(int format) {
84         switch (format) {
85             case PixelFormat.A_8:
86             case PixelFormat.LA_88:
87             case PixelFormat.RGBA_4444:
88             case PixelFormat.RGBA_5551:
89             case PixelFormat.RGBA_8888:
90             case PixelFormat.TRANSLUCENT:
91             case PixelFormat.TRANSPARENT:
92                 return true;
93         }
94         return false;
95     }
96 
97     public int  bytesPerPixel;
98     public int  bitsPerPixel;
99 }
100