| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,6 +63,21 @@ export var takePicture = function (options?): Promise<any> { | |||
| 63 | 63 | scaledSizeImage = bitmap; | |
| 64 | 64 | } | |
| 65 | 65 | ||
| 66 | + var ei = new android.media.ExifInterface(tempPicturePath); | ||
| 67 | + var orientation = ei.getAttributeInt(android.media.ExifInterface.TAG_ORIENTATION, android.media.ExifInterface.ORIENTATION_NORMAL); | ||
| 68 | + | ||
| 69 | + switch (orientation) { | ||
| 70 | + case android.media.ExifInterface.ORIENTATION_ROTATE_90: | ||
| 71 | + scaledSizeImage = rotateBitmap(scaledSizeImage, 90); | ||
| 72 | + break; | ||
| 73 | + case android.media.ExifInterface.ORIENTATION_ROTATE_180: | ||
| 74 | + scaledSizeImage = rotateBitmap(scaledSizeImage, 180); | ||
| 75 | + break; | ||
| 76 | + case android.media.ExifInterface.ORIENTATION_ROTATE_270: | ||
| 77 | + scaledSizeImage = rotateBitmap(scaledSizeImage, 270); | ||
| 78 | + break; | ||
| 79 | + } | ||
| 80 | + | ||
| 66 | 81 | var imageSource: typeof imageSourceModule = require("image-source"); | |
| 67 | 82 | ||
| 68 | 83 | resolve(imageSource.fromNativeSource(scaledSizeImage)); | |
@@ -102,4 +117,10 @@ var createDateTimeStamp = function () { | |||
| 102 | 117 | date.getMinutes().toString() + | |
| 103 | 118 | date.getSeconds().toString(); | |
| 104 | 119 | return result; | |
| 120 | + } | ||
| 121 | + | ||
| 122 | + var rotateBitmap = function (source, angle) { | ||
| 123 | + var matrix = new android.graphics.Matrix(); | ||
| 124 | + matrix.postRotate(angle); | ||
| 125 | + return android.graphics.Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); | ||
| 105 | 126 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments