Maksim
Maksim

Reputation: 131

Android: clip image to shape

(Sorry for my bad english) I have two pictures. One picture is colorful and big. On the other picture shows a black figure arbitrary shape (like a cross or a star or a piece of the classic puzzle) on a transparent background. I want to put the second picture on the first picture and replace the black with part of the first image. Then i need to save the second image in a new file.

Thank you. Max.

Upvotes: 3

Views: 5364

Answers (2)

Mafujul
Mafujul

Reputation: 1100

You can get this by using a library and a single line code. Please try this, hope you will get a better solution.

dependencies {
compile 'com.mafstech.libs:mafs-image-shape:1.0.4'   
}

And this line is your main code

Shaper.shape(context, R.drawable.your_original_image_which_will_be_displayed, R.drawable.shaped_image__your_original_image_will_get_this_images_shape, imageView, height, weight);   

Upvotes: 1

Lumis
Lumis

Reputation: 21629

You need to use xfer modes, unless you are preaperd to create Paths and then clip canvas.

Check my answer here: how to draw pic to Closed curve area

Follow the links for examples...

Upvotes: 0

Related Questions