@Test public void canTransformImageToByteArray() throws ImageUtil.CodecFailedException { byte[] byteArray = ImageUtil.imageToJpegByteArray(mImage); assertThat(byteArray).isEqualTo(mDataByteArray); }
public static byte[] imageToJpegByteArray(ImageProxy image) throws CodecFailedException { byte[] data = null; if (image.getFormat() == ImageFormat.JPEG) { data = jpegImageToJpegByteArray(image); } else if (image.getFormat() == ImageFormat.YUV_420_888) { data = yuvImageToJpegByteArray(image); } else { Log.w(TAG, "Unrecognized image format: " + image.getFormat()); } return data; }
ImageUtil { public static byte[] imageToJpegByteArray(ImageProxy image) throws CodecFailedException { byte[] data = null; if (image.getFormat() == ImageFormat.JPEG) { data = jpegImageToJpegByteArray(image); } else if (image.getFormat() == ImageFormat.YUV_420_888) { data = yuvImageToJpegByteArray(image); } else { Log.w(TAG, "Unrecognized image format: " + image.getFormat()); } return data; } }
ImageUtil { public static byte[] imageToJpegByteArray(ImageProxy image) throws CodecFailedException { byte[] data = null; if (image.getFormat() == ImageFormat.JPEG) { data = jpegImageToJpegByteArray(image); } else if (image.getFormat() == ImageFormat.YUV_420_888) { data = yuvImageToJpegByteArray(image); } else { Log.w(TAG, "Unrecognized image format: " + image.getFormat()); } return data; } private  ImageUtil(); }
ImageUtil { public static byte[] imageToJpegByteArray(ImageProxy image) throws CodecFailedException { byte[] data = null; if (image.getFormat() == ImageFormat.JPEG) { data = jpegImageToJpegByteArray(image); } else if (image.getFormat() == ImageFormat.YUV_420_888) { data = yuvImageToJpegByteArray(image); } else { Log.w(TAG, "Unrecognized image format: " + image.getFormat()); } return data; } private  ImageUtil(); static byte[] imageToJpegByteArray(ImageProxy image); static byte[] cropByteArray(byte[] data, Rect cropRect); static boolean isAspectRatioValid(Rational aspectRatio); static boolean isAspectRatioValid(Size sourceSize, Rational aspectRatio); static Rect computeCropRectFromAspectRatio(Size sourceSize, Rational aspectRatio); static Rational rotate(
            Rational rational, @RotationValue int rotation); }
ImageUtil { public static byte[] imageToJpegByteArray(ImageProxy image) throws CodecFailedException { byte[] data = null; if (image.getFormat() == ImageFormat.JPEG) { data = jpegImageToJpegByteArray(image); } else if (image.getFormat() == ImageFormat.YUV_420_888) { data = yuvImageToJpegByteArray(image); } else { Log.w(TAG, "Unrecognized image format: " + image.getFormat()); } return data; } private  ImageUtil(); static byte[] imageToJpegByteArray(ImageProxy image); static byte[] cropByteArray(byte[] data, Rect cropRect); static boolean isAspectRatioValid(Rational aspectRatio); static boolean isAspectRatioValid(Size sourceSize, Rational aspectRatio); static Rect computeCropRectFromAspectRatio(Size sourceSize, Rational aspectRatio); static Rational rotate(
            Rational rational, @RotationValue int rotation);  }