Merge pull request #51 from yku-yku/master

fix for issue #50
pull/84/head
Florent CHAMPIGNY 7 years ago committed by GitHub
commit 64cf2f430f
  1. 2
      build.gradle
  2. 9
      camerafragment/src/main/java/com/github/florent37/camerafragment/internal/utils/ImageSaver.java

@ -23,6 +23,6 @@ ext {
sdk = 25 sdk = 25
buildTools = "25.0.2" buildTools = "25.0.2"
minSdk = 10 minSdk = 10
libraryVersion = "1.0.7" libraryVersion = "1.0.7.1"
supportVersion = "25.0.0" supportVersion = "25.0.0"
} }

@ -36,17 +36,20 @@ public class ImageSaver implements Runnable {
@TargetApi(Build.VERSION_CODES.KITKAT) @TargetApi(Build.VERSION_CODES.KITKAT)
@Override @Override
public void run() { public void run() {
ByteBuffer buffer = image.getPlanes()[0].getBuffer();
byte[] bytes = new byte[buffer.remaining()];
buffer.get(bytes);
FileOutputStream output = null; FileOutputStream output = null;
try { try {
ByteBuffer buffer = image.getPlanes()[0].getBuffer();
byte[] bytes = new byte[buffer.remaining()];
buffer.get(bytes);
output = new FileOutputStream(file); output = new FileOutputStream(file);
output.write(bytes); output.write(bytes);
imageSaverCallback.onSuccessFinish(bytes); imageSaverCallback.onSuccessFinish(bytes);
} catch (IOException ignore) { } catch (IOException ignore) {
Log.e(TAG, "Can't save the image file."); Log.e(TAG, "Can't save the image file.");
imageSaverCallback.onError(); imageSaverCallback.onError();
} catch (IllegalStateException e) {
Log.e(TAG, "Can't read the image file.", e);
imageSaverCallback.onError();
} finally { } finally {
image.close(); image.close();
if (null != output) { if (null != output) {

Loading…
Cancel
Save