diff options
author | Mathias Agopian <mathias@google.com> | 2010-02-17 17:53:09 -0800 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2010-02-18 15:32:47 -0800 |
commit | a696f5d667227365da732481770767dcb330dd23 (patch) | |
tree | 0a89f08df3f88daea3f29948c8d5cdd7675a3fff /core/jni | |
parent | be8af08cf4cf9384b3fa13c853c40d761211ceed (diff) | |
download | frameworks_base-a696f5d667227365da732481770767dcb330dd23.zip frameworks_base-a696f5d667227365da732481770767dcb330dd23.tar.gz frameworks_base-a696f5d667227365da732481770767dcb330dd23.tar.bz2 |
Add ImageFormat.java and move the Camera/YUV constants from PixelFormat to it.
PixelFormat's corresponding constansts are now deprecated.
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/android/graphics/YuvToJpegEncoder.cpp | 4 | ||||
-rw-r--r-- | core/jni/android_graphics_PixelFormat.cpp | 26 |
2 files changed, 27 insertions, 3 deletions
diff --git a/core/jni/android/graphics/YuvToJpegEncoder.cpp b/core/jni/android/graphics/YuvToJpegEncoder.cpp index e6a1872..819cce8 100644 --- a/core/jni/android/graphics/YuvToJpegEncoder.cpp +++ b/core/jni/android/graphics/YuvToJpegEncoder.cpp @@ -7,9 +7,9 @@ #include <jni.h> YuvToJpegEncoder* YuvToJpegEncoder::create(int format, int* strides) { - // Only PIXEL_FORMAT_YCbCr_420_SP and PIXEl_FOMAT_YCbCr_422_I are supported + // Only ImageFormat.NV21 and ImageFormat.YUY2 are supported // for now. - if (format == HAL_PIXEL_FORMAT_YCbCr_420_SP) { + if (format == HAL_PIXEL_FORMAT_YCrCb_420_SP) { return new Yuv420SpToJpegEncoder(strides); } else if (format == HAL_PIXEL_FORMAT_YCbCr_422_I) { return new Yuv422IToJpegEncoder(strides); diff --git a/core/jni/android_graphics_PixelFormat.cpp b/core/jni/android_graphics_PixelFormat.cpp index 0643622..5b8363c 100644 --- a/core/jni/android_graphics_PixelFormat.cpp +++ b/core/jni/android_graphics_PixelFormat.cpp @@ -48,11 +48,35 @@ static void android_graphics_getPixelFormatInfo( JNIEnv* env, jobject clazz, jint format, jobject pixelFormatObject) { PixelFormatInfo info; - status_t err = getPixelFormatInfo(format, &info); + status_t err; + + // we need this for backward compatibility with PixelFormat's + // deprecated constants + switch (format) { + case HAL_PIXEL_FORMAT_YCbCr_422_SP: + // defined as the bytes per pixel of the Y plane + info.bytesPerPixel = 1; + info.bitsPerPixel = 16; + goto done; + case HAL_PIXEL_FORMAT_YCrCb_420_SP: + // defined as the bytes per pixel of the Y plane + info.bytesPerPixel = 1; + info.bitsPerPixel = 12; + goto done; + case HAL_PIXEL_FORMAT_YCbCr_422_I: + // defined as the bytes per pixel of the Y plane + info.bytesPerPixel = 1; + info.bitsPerPixel = 16; + goto done; + } + + err = getPixelFormatInfo(format, &info); if (err < 0) { doThrow(env, "java/lang/IllegalArgumentException"); return; } + +done: env->SetIntField(pixelFormatObject, offsets.bytesPerPixel, info.bytesPerPixel); env->SetIntField(pixelFormatObject, offsets.bitsPerPixel, info.bitsPerPixel); } |