Skip to content

Commit

Permalink
Make image immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
goncalocostamendes committed Aug 9, 2023
1 parent 974e2d8 commit 9d1b68b
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class MainActivity : AppCompatActivity(), PermissionCallbacks {
class logoWatermark(private val resources: Resources) : CustomVideoTransformer {

// Get the image in bitmap format
private final var image: Bitmap = BitmapFactory.decodeResource(resources, R.drawable.vonage_logo)
private val image: Bitmap = BitmapFactory.decodeResource(resources, R.drawable.vonage_logo)

fun resizeImage(image: Bitmap?, width: Int, height: Int): Bitmap {
return Bitmap.createScaledBitmap(image!!, width, height, true)
Expand All @@ -271,9 +271,9 @@ class MainActivity : AppCompatActivity(), PermissionCallbacks {
val desiredHeight: Int = (image.getHeight() * (desiredWidth.toFloat() / image.getWidth())).toInt()

// Resize the image to the desired size
val reizedImage = resizeImage(image, desiredWidth, desiredHeight)
val logoWidth: Int = reizedImage.getWidth()
val logoHeight: Int = reizedImage.getHeight()
val resizedImage = resizeImage(image, desiredWidth, desiredHeight)
val logoWidth: Int = resizedImage.getWidth()
val logoHeight: Int = resizedImage.getHeight()

// Location of the image (center of video)
val logoPositionX = videoWidth * 1 / 2 - logoWidth // Adjust this as needed for the desired position
Expand All @@ -285,7 +285,7 @@ class MainActivity : AppCompatActivity(), PermissionCallbacks {
val frameOffset = (logoPositionY + y) * videoWidth + (logoPositionX + x)

// Get the logo pixel color
val logoPixel: Int = reizedImage.getPixel(x, y)
val logoPixel: Int = resizedImage.getPixel(x, y)

// Extract the color channels (ARGB)
val logoAlpha = logoPixel shr 24 and 0xFF
Expand Down

0 comments on commit 9d1b68b

Please sign in to comment.