Java Code Examples for android.graphics.ImageFormat#UNKNOWN
The following examples show how to use
android.graphics.ImageFormat#UNKNOWN .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LegacyCameraDevice.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public static boolean isPreviewConsumer(Surface output) { int usageFlags = detectSurfaceUsageFlags(output); int disallowedFlags = GRALLOC_USAGE_HW_VIDEO_ENCODER | GRALLOC_USAGE_RENDERSCRIPT | GRALLOC_USAGE_SW_READ_OFTEN; int allowedFlags = GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_HW_RENDER; boolean previewConsumer = ((usageFlags & disallowedFlags) == 0 && (usageFlags & allowedFlags) != 0); int surfaceFormat = ImageFormat.UNKNOWN; try { surfaceFormat = detectSurfaceType(output); } catch(BufferQueueAbandonedException e) { throw new IllegalArgumentException("Surface was abandoned", e); } return previewConsumer; }
Example 2
Source File: LegacyCameraDevice.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public static boolean isVideoEncoderConsumer(Surface output) { int usageFlags = detectSurfaceUsageFlags(output); int disallowedFlags = GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_COMPOSER | GRALLOC_USAGE_RENDERSCRIPT | GRALLOC_USAGE_SW_READ_OFTEN; int allowedFlags = GRALLOC_USAGE_HW_VIDEO_ENCODER; boolean videoEncoderConsumer = ((usageFlags & disallowedFlags) == 0 && (usageFlags & allowedFlags) != 0); int surfaceFormat = ImageFormat.UNKNOWN; try { surfaceFormat = detectSurfaceType(output); } catch(BufferQueueAbandonedException e) { throw new IllegalArgumentException("Surface was abandoned", e); } return videoEncoderConsumer; }
Example 3
Source File: Camera.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
private int pixelFormatForCameraFormat(String format) { if (format == null) return ImageFormat.UNKNOWN; if (format.equals(PIXEL_FORMAT_YUV422SP)) return ImageFormat.NV16; if (format.equals(PIXEL_FORMAT_YUV420SP)) return ImageFormat.NV21; if (format.equals(PIXEL_FORMAT_YUV422I)) return ImageFormat.YUY2; if (format.equals(PIXEL_FORMAT_YUV420P)) return ImageFormat.YV12; if (format.equals(PIXEL_FORMAT_RGB565)) return ImageFormat.RGB_565; if (format.equals(PIXEL_FORMAT_JPEG)) return ImageFormat.JPEG; return ImageFormat.UNKNOWN; }
Example 4
Source File: VideoCapture.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@CalledByNative public int getColorspace() { switch (mImageFormat){ case ImageFormat.YV12: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_YV12; case ImageFormat.NV21: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_NV21; case ImageFormat.YUY2: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_YUY2; case ImageFormat.NV16: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_NV16; case ImageFormat.JPEG: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_JPEG; case ImageFormat.RGB_565: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_RGB_565; case ImageFormat.UNKNOWN: default: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_UNKNOWN; } }
Example 5
Source File: VideoCapture.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@CalledByNative public int getColorspace() { switch (mImageFormat){ case ImageFormat.YV12: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_YV12; case ImageFormat.NV21: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_NV21; case ImageFormat.YUY2: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_YUY2; case ImageFormat.NV16: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_NV16; case ImageFormat.JPEG: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_JPEG; case ImageFormat.RGB_565: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_RGB_565; case ImageFormat.UNKNOWN: default: return AndroidImageFormatList.ANDROID_IMAGEFORMAT_UNKNOWN; } }
Example 6
Source File: Camera.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Gets the supported preview formats. {@link android.graphics.ImageFormat#NV21} * is always supported. {@link android.graphics.ImageFormat#YV12} * is always supported since API level 12. * * @return a list of supported preview formats. This method will always * return a list with at least one element. * @see android.graphics.ImageFormat * @see #setPreviewFormat */ public List<Integer> getSupportedPreviewFormats() { String str = get(KEY_PREVIEW_FORMAT + SUPPORTED_VALUES_SUFFIX); ArrayList<Integer> formats = new ArrayList<Integer>(); for (String s : split(str)) { int f = pixelFormatForCameraFormat(s); if (f == ImageFormat.UNKNOWN) continue; formats.add(f); } return formats; }
Example 7
Source File: Camera.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Gets the supported picture formats. * * @return supported picture formats. This method will always return a * list with at least one element. * @see android.graphics.ImageFormat */ public List<Integer> getSupportedPictureFormats() { String str = get(KEY_PICTURE_FORMAT + SUPPORTED_VALUES_SUFFIX); ArrayList<Integer> formats = new ArrayList<Integer>(); for (String s : split(str)) { int f = pixelFormatForCameraFormat(s); if (f == ImageFormat.UNKNOWN) continue; formats.add(f); } return formats; }
Example 8
Source File: AndroidImageReaderProxy.java From Camera2 with Apache License 2.0 | 5 votes |
private static String imageFormatToString(int imageFormat) { switch (imageFormat) { case ImageFormat.JPEG: return "JPEG"; case ImageFormat.NV16: return "NV16"; case ImageFormat.NV21: return "NV21"; case ImageFormat.RAW10: return "RAW10"; case ImageFormat.RAW_SENSOR: return "RAW_SENSOR"; case ImageFormat.RGB_565: return "RGB_565"; case ImageFormat.UNKNOWN: return "UNKNOWN"; case ImageFormat.YUV_420_888: return "YUV_420_888"; case ImageFormat.YUY2: return "YUY2"; case ImageFormat.YV12: return "YV12"; } return Integer.toString(imageFormat); }
Example 9
Source File: CameraUtils.java From libcommon with Apache License 2.0 | 5 votes |
/** * 対応する映像フォーマットをlogCatへ出力する * @param params */ public static void dumpSupportedPictureFormats(@NonNull final Camera.Parameters params) { final List<Integer> formats = params.getSupportedPictureFormats(); for (final int format: formats) { switch (format) { case ImageFormat.DEPTH16: Log.i(TAG, "supported: DEPTH16"); break; case ImageFormat.DEPTH_POINT_CLOUD: Log.i(TAG, "supported: DEPTH_POINT_CLOUD"); break; case ImageFormat.FLEX_RGBA_8888: Log.i(TAG, "supported: FLEX_RGBA_8888"); break; case ImageFormat.FLEX_RGB_888: Log.i(TAG, "supported: FLEX_RGB_888"); break; case ImageFormat.JPEG: Log.i(TAG, "supported: JPEG"); break; case ImageFormat.NV16: Log.i(TAG, "supported: NV16"); break; case ImageFormat.NV21: Log.i(TAG, "supported: NV21"); break; case ImageFormat.PRIVATE: Log.i(TAG, "supported: PRIVATE"); break; case ImageFormat.RAW10: Log.i(TAG, "supported: RAW10"); break; case ImageFormat.RAW12: Log.i(TAG, "supported: RAW12"); break; case ImageFormat.RAW_PRIVATE: Log.i(TAG, "supported: RAW_PRIVATE"); break; case ImageFormat.RAW_SENSOR: Log.i(TAG, "supported: RAW_SENSOR"); break; case ImageFormat.RGB_565: Log.i(TAG, "supported: RGB_565"); break; case ImageFormat.UNKNOWN: Log.i(TAG, "supported: UNKNOWN"); break; case ImageFormat.YUV_420_888: Log.i(TAG, "supported: YUV_420_888"); break; case ImageFormat.YUV_422_888: Log.i(TAG, "supported: YUV_422_888"); break; case ImageFormat.YUV_444_888: Log.i(TAG, "supported: YUV_444_888"); break; case ImageFormat.YUY2: Log.i(TAG, "supported: YUY2"); break; case ImageFormat.YV12: Log.i(TAG, "supported: YV12"); break; default: Log.i(TAG, String.format("supported: unknown, %08x", format)); break; } } }
Example 10
Source File: VideoCapture.java From 365browser with Apache License 2.0 | 5 votes |
@CalledByNative public final int getColorspace() { switch (mCaptureFormat.mPixelFormat) { case ImageFormat.YV12: return AndroidImageFormat.YV12; case ImageFormat.YUV_420_888: return AndroidImageFormat.YUV_420_888; case ImageFormat.NV21: return AndroidImageFormat.NV21; case ImageFormat.UNKNOWN: default: return AndroidImageFormat.UNKNOWN; } }
Example 11
Source File: MainActivity.java From FastBarcodeScanner with Apache License 2.0 | 4 votes |
private String formatFormat(int imageFormat) { switch (imageFormat) { case ImageFormat.UNKNOWN: return "UNKNOWN"; case ImageFormat.NV21: return "NV21"; case ImageFormat.NV16: return "NV16"; case ImageFormat.YV12: return "YV12"; case ImageFormat.YUY2: return "YUY2"; case ImageFormat.YUV_420_888: return "YUV_420_888"; case ImageFormat.YUV_422_888: return "YUV_422_888"; case ImageFormat.YUV_444_888: return "YUV_444_888"; case ImageFormat.FLEX_RGB_888: return "FLEX_RGB_888"; case ImageFormat.FLEX_RGBA_8888: return "FLEX_RGBA_8888"; case ImageFormat.JPEG: return "JPEG"; case ImageFormat.RGB_565: return "RGB_565"; case ImageFormat.RAW_SENSOR: return "RAW_SENSOR"; case ImageFormat.RAW10: return "RAW10"; case ImageFormat.RAW12: return "RAW12"; case ImageFormat.DEPTH16: return "DEPTH16"; case ImageFormat.DEPTH_POINT_CLOUD: return "DEPTH_POINT_CLOUD"; //case ImageFormat.Y8: //case ImageFormat.Y16: } return "" + imageFormat; }
Example 12
Source File: StillSequenceCamera.java From FastBarcodeScanner with Apache License 2.0 | 4 votes |
private static double getFormatCost(int format) { switch (format) { case ImageFormat.UNKNOWN: return 1.0; case ImageFormat.NV21: return 0.8; case ImageFormat.NV16: // This format has never been seen in the wild, but is compatible as we only care // about the Y channel, so allow it. return 0.8; case ImageFormat.YV12: case ImageFormat.YUY2: case ImageFormat.YUV_420_888: return 0.5; // pure guesswork - but it IS faster than JPEG case ImageFormat.YUV_422_888: // only varies from yuv_420_888 in chroma-subsampling, which I'm guessing // doesn't affect the luminance much // (see https://en.wikipedia.org/wiki/Chroma_subsampling) return 0.5; case ImageFormat.YUV_444_888: // only varies from yuv_420_888 in chroma-subsampling, which I'm guessing // doesn't affect the luminance much // (see https://en.wikipedia.org/wiki/Chroma_subsampling) return 0.5; case ImageFormat.FLEX_RGB_888: case ImageFormat.FLEX_RGBA_8888: case ImageFormat.RGB_565: return 0.8; // pure guesswork case ImageFormat.JPEG: return 1.0; // duh...? case ImageFormat.RAW_SENSOR: case ImageFormat.RAW10: case ImageFormat.RAW12: return 0.4; // pure guesswork - but any RAW format must be optimal (wrt capture speed)? case ImageFormat.DEPTH16: case ImageFormat.DEPTH_POINT_CLOUD: return 1.5; // sound terribly complicated - but I'm just guessing.... //ImageFormat.Y8: //ImageFormat.Y16: } return 1.0; }
Example 13
Source File: JpegUtils.java From FastBarcodeScanner with Apache License 2.0 | 4 votes |
public static byte[] ToJpeg(byte[] imageData, int imageFormat, int width, int height) { if (imageData == null) return null; switch (imageFormat) { case ImageFormat.NV21: case ImageFormat.YUY2: YuvImage img = new YuvImage(imageData, imageFormat, width, height, null); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int quality = 20; //set quality img.compressToJpeg(new Rect(0, 0, width, height), quality, baos);//this line decreases the image quality return baos.toByteArray(); case ImageFormat.YUV_420_888: return JpegFromYuv420888(imageData, imageFormat, width, height); case ImageFormat.UNKNOWN: return null; case ImageFormat.NV16: // Source: http://www.programcreek.com/java-api-examples/index.php?source_dir=Roid-Library-master/src/com/rincliu/library/common/persistence/zxing/camera/CameraManager.java // This format has never been seen in the wild, but is compatible as we only care // about the Y channel, so allow it. case ImageFormat.YV12: // source: https://github.com/evopark/tiqr-android/blob/master/src/main/java/de/evopark/tiqr/android/processing/ZxingQrScanner.java case ImageFormat.YUV_422_888: // only varies from yuv_420_888 in chroma-subsampling, which I'm guessing // doesn't affect the luminance much // (see https://en.wikipedia.org/wiki/Chroma_subsampling) case ImageFormat.YUV_444_888: // only varies from yuv_420_888 in chroma-subsampling, which I'm guessing // doesn't affect the luminance much // (see https://en.wikipedia.org/wiki/Chroma_subsampling) return null;//new PlanarYUVLuminanceSource(data, width, height, 0, 0, width, height, false); case ImageFormat.FLEX_RGB_888: case ImageFormat.FLEX_RGBA_8888: return null;//new RGBLuminanceSource(width, height, uncompress(data, width, height));// PlanarYUVLuminanceSource(bytes, width, height, 0, 0, width, height, false); case ImageFormat.JPEG: // Tried and tested myself return null;//new RGBLuminanceSource(width, height, uncompress(data, width, height));// PlanarYUVLuminanceSource(bytes, width, height, 0, 0, width, height, false); case ImageFormat.RGB_565: return null;//new RGB565(width, height, uncompress(data, width, height));// PlanarYUVLuminanceSource(bytes, width, height, 0, 0, width, height, false); case ImageFormat.RAW_SENSOR: case ImageFormat.RAW10: case ImageFormat.RAW12: case ImageFormat.DEPTH16: case ImageFormat.DEPTH_POINT_CLOUD: //ImageFormat.Y8: //ImageFormat.Y16: return null; default: throw new IllegalArgumentException("No support for image format " + imageFormat); } }
Example 14
Source File: JellyBeanCamera.java From LiveMultimedia with Apache License 2.0 | 4 votes |
/****************************************************************************************** * The preview window can supprt different image formats depending on the camera make * Almost all support NV21 and JPEG * @param parameters preview window parms ****************************************************************************************/ @SuppressWarnings("deprecation") private synchronized void queryPreviewSettings(Camera.Parameters parameters) { List<int[]> supportedFps = parameters.getSupportedPreviewFpsRange(); for (int[] item : supportedFps) { Log.d(TAG, "Mix preview frame rate supported: " + item[ Camera.Parameters.PREVIEW_FPS_MIN_INDEX]/ 1000 ); Log.d(TAG, "Max preview frame rate supported: " + item[ Camera.Parameters.PREVIEW_FPS_MAX_INDEX]/ 1000 ); } List<Integer> formats = parameters.getSupportedPreviewFormats(); for (Integer format : formats) { if (format == null) { Log.e(TAG, "This camera supports illegal format in preview"); break; } switch ( format.intValue() ) { case ImageFormat.JPEG: Log.d(TAG, "This camera supports JPEG format in preview"); break; case ImageFormat.NV16: Log.d(TAG, "This camera supports NV16 format in preview"); break; case ImageFormat.NV21: Log.d(TAG, "This camera supports NV21 format in preview"); mNV21ColorFormatSupported = true; break; case ImageFormat.RGB_565: Log.d(TAG, "This camera supports RGB_5645 format in preview"); break; case ImageFormat.YUV_420_888: Log.d(TAG, "This camera supports YUV_420_888 format in preview"); break; case ImageFormat.YUY2: Log.d(TAG, "This camera supports YUY2 format in preview"); break; case ImageFormat.YV12: Log.d(TAG, "This camera supports YV12 format in preview"); mYV12ColorFormatSupported = true; break; case ImageFormat.UNKNOWN: Log.e(TAG, "This camera supports UNKNOWN format in preview"); break; default: Log.e(TAG, "This camera supports illegal format in preview"); break; } } }