2

I have 2 pictures, A and B, my goal is to put B onto A and save it to the user's device (This is similar to the Paste() function from the Pillow Library in python)

Note that both B and A are user selected with activity so I get the URI

Picture A and B seperatly

Picture B on top of A

Firstly; How would I go about pasting B onto A in Kotlin + Android Studio?

Secondly; How would I resize B to work on a specific aspect ratio for different pictures of type A?

1 Answers1

0

You should put your images into frameLayout:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
    android:id="@+id/imageA"
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_gravity="center"/>

<ImageView
    android:id="@+id/imageB"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:layout_gravity="center"/>

</FrameLayout>
  • Correct me if I'm wrong but this would work if the image is an asset in the project; both image A and B are user input from their gallery, would this still work? Edit: also this merges two images visually inside the app I believe, I am trying to make a new image so I can save it to the user's storage externally – TheFutureKnight Oct 11 '22 at 09:12
  • 1
    There is no difference where is your image. And for merge two image you can use this: https://stackoverflow.com/questions/11322876/how-can-i-merge-two-bitmap-one-over-another-at-selected-point-on-the-first-image – Pooya Jannati Poor Oct 11 '22 at 09:15