Skip to content

Commit 17a9964

Browse files
committed
Fix the face oval being sideways
1 parent 34972af commit 17a9964

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

app/src/main/kotlin/com/darkrockstudios/app/securecamera/obfuscation/ObfuscationTools.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ private fun applyOvalMask(sourceBitmap: Bitmap, rect: Rect): Bitmap {
6161
val paint = Paint(Paint.ANTI_ALIAS_FLAG)
6262
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.SRC_IN)
6363

64-
val ovalWidth = rect.width().toFloat()
65-
val ovalHeight = ovalWidth / 1.6f
64+
val scaleFactor = 1.2f
65+
val ovalHeight = rect.height().toFloat() * scaleFactor
66+
val ovalWidth = ovalHeight / 1.6f
6667

68+
val leftOffset = (rect.width() - ovalWidth) / 2f
6769
val topOffset = (rect.height() - ovalHeight) / 2f
6870

69-
val ovalRect = RectF(0f, topOffset.coerceAtLeast(0f), ovalWidth, topOffset.coerceAtLeast(0f) + ovalHeight)
71+
val ovalRect = RectF(leftOffset, topOffset, leftOffset + ovalWidth, topOffset + ovalHeight)
7072
maskCanvas.drawOval(ovalRect, Paint(Paint.ANTI_ALIAS_FLAG).apply { color = Color.WHITE })
7173

7274
maskCanvas.drawBitmap(sourceBitmap, 0f, 0f, paint)

0 commit comments

Comments
 (0)