Skip to content

Commit

Permalink
Merge pull request #463 from lterminiello/fixArithmeticException
Browse files Browse the repository at this point in the history
fix ArithmeticException in CameraPreview
  • Loading branch information
rkistner authored Sep 7, 2019
2 parents 3133240 + 0e7413e commit 1a1c8d0
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,17 @@ private void calculateFrames() {
frameInPreview.right * previewWidth / surfaceRect.width(),
frameInPreview.bottom * previewHeight / surfaceRect.height());

if (previewFramingRect.width() <= 0 || previewFramingRect.height() <= 0) {
if (surfaceRect.width() != 0 && surfaceRect.height() != 0) {
previewFramingRect = new Rect(frameInPreview.left * previewWidth / surfaceRect.width(),
frameInPreview.top * previewHeight / surfaceRect.height(),
frameInPreview.right * previewWidth / surfaceRect.width(),
frameInPreview.bottom * previewHeight / surfaceRect.height());

} else {
previewFramingRect = null;
}

if (previewFramingRect == null || previewFramingRect.width() <= 0 || previewFramingRect.height() <= 0) {
previewFramingRect = null;
framingRect = null;
Log.w(TAG, "Preview frame is too small");
Expand Down

0 comments on commit 1a1c8d0

Please sign in to comment.