Skip to content

Commit

Permalink
Fix camera images can be upside down from rare camera.
Browse files Browse the repository at this point in the history
  • Loading branch information
percy-g2 committed Jan 13, 2018
1 parent 1baf43d commit 53d0418
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/org/havenapp/main/sensors/motion/Preview.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import org.havenapp.main.PreferenceManager;
import org.havenapp.main.model.EventTrigger;
import org.havenapp.main.sensors.media.ImageCodec;
import org.havenapp.main.sensors.media.MotionAsyncTask;
import org.havenapp.main.service.MonitorService;

Expand Down Expand Up @@ -290,7 +291,12 @@ public void onProcess(Bitmap oldBitmap, Bitmap newBitmap,

File fileImage = new File(fileImageDir, "detected.original." + ts);
FileOutputStream stream = new FileOutputStream(fileImage);
rawBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
if (prefs.getCamera().equalsIgnoreCase(PreferenceManager.BACK)) {
Bitmap bmps = ImageCodec.rotate(rawBitmap, 180, false);
bmps.compress(Bitmap.CompressFormat.JPEG, 100, stream);
} else {
rawBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
}
stream.flush();
stream.close();
message.getData().putString("path", fileImage.getAbsolutePath());
Expand Down

0 comments on commit 53d0418

Please sign in to comment.