I have a custom camera that works fine in some devices. It works well on Samsung Galaxy Gran Duos (samsung-gt i9082, Android 4.2.2) but when I try to capture an image, that I zoomed in before, it freezes, no crash, the only way to get out is to press the back button. This happen only in the Samsung Galaxy Gran Duos.
The code that I used to take a picture:
Camera.PictureCallback photoCallback = new Camera.PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
try {
} catch (Exception e) {
if (flePicture== null){
Log.d("camera", "Error creating media file, check storage permissions: " +
e.getMessage());
return;
}
}
try {
FileOutputStream fos = new FileOutputStream(flePicture);
fos.write(data);
fos.close();
} catch (FileNotFoundException e) {
Log.d("camera", "File not found: " + e.getMessage());
} catch (IOException e) {
Log.d("camera", "Error accessing file: " + e.getMessage());
}
}
};
And the code used for the zoom in:
private void zoomIn() {
if (pblnInPreview) {
Camera.Parameters parameters = camCamera.getParameters();
if ((parameters.getZoom() + 1) < parameters.getMaxZoom()) {
parameters.setZoom(parameters.getZoom() + 1);
camCamera.setParameters(parameters);
}
}
}
LogCat:
04-07 17:21:14.386: E/BrcmCamera(130): processControlBuffer: Corrupt stream error raised by camera - sensor communication failure
I think you need to confirm that your camera supports zoom by using camera.isZoomSupported()
then if it is supported you need to cancel auto focus with camera.cancelAutoFocus()
to prevent image distorsions.
But this will only work if your device actually supports zoom. If not you need to capture the hold image and zoom in after by using Bitmap.createBitmap
an the section you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With