2 * Copyright (C) 2010 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.graphics;
19 public class ImageFormat {
21 * these constants are chosen to be binary compatible with their previous
22 * location in PixelFormat.java
25 public static final int UNKNOWN = 0;
28 * RGB format used for pictures encoded as RGB_565 see
29 * {@link android.hardware.Camera.Parameters#setPictureFormat(int)}.
31 public static final int RGB_565 = 4;
34 * Planar 4:2:0 YCrCb format. This format assumes an horizontal stride of 16
35 * pixels for all planes and an implicit vertical stride of the image
36 * height's next multiple of two.
37 * y_size = stride * ALIGN(height, 2)
38 * c_size = ALIGN(stride/2, 16) * height
39 * size = y_size + c_size * 2
41 * cb_offset = y_size + c_size
43 * Whether this format is supported by the camera hardware can be determined
45 * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.
47 public static final int YV12 = 0x32315659;
50 * YCbCr format, used for video. Whether this format is supported by the
51 * camera hardware can be determined by
52 * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.
54 public static final int NV16 = 0x10;
57 * YCrCb format used for images, which uses the NV21 encoding format. This
58 * is the default format for camera preview images, when not otherwise set
59 * with {@link android.hardware.Camera.Parameters#setPreviewFormat(int)}.
61 public static final int NV21 = 0x11;
64 * YCbCr format used for images, which uses YUYV (YUY2) encoding format.
65 * This is an alternative format for camera preview images. Whether this
66 * format is supported by the camera hardware can be determined by
67 * {@link android.hardware.Camera.Parameters#getSupportedPreviewFormats()}.
69 public static final int YUY2 = 0x14;
72 * Encoded formats. These are not necessarily supported by the hardware.
74 public static final int JPEG = 0x100;
77 * Use this function to retrieve the number of bits per pixel of an
81 * @return the number of bits per pixel of the given format or -1 if the
82 * format doesn't exist or is not supported.
84 public static int getBitsPerPixel(int format) {