gad74
gad74

Reputation: 145

How to add an image over another image for cropping in java

I am trying to add an image to another image so that I can crop out what I do not want (all the black areas). I have implemented the camera in my app in an android studio and am saving files to my android device. I don't know how to do this.

I have an image view over the camera so that they can get the "shirt" inside the "outline" so it will be easier to crop once I overlay the image and bitmask out all the black. Black Cookie cutter, Original shirt , Both images overlayed, and the final would be just the shirt and nothing else around it as a png so the surroundings are transparent so that I can load it from my specified file directory onto a mannequin like this: Final output.

Any guidance would be helpful. Also sorry I could not embed the pictures as I am new to the site and it only let me post links that are from this website, so they are safe!

Upvotes: 0

Views: 191

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57203

To set an overlay over a 'saved' (captured) image, your major concern is that the uncompressed image may get huge. I would use partial images only, and a scaled down version for on-screen preview (if you want to let the user to manually fit the shirt). For the latter task, you can use a png with reduced resolution (even less than 900x1200) and transparency: this way you can use two ImageViews.

If you want to match the shirt overlay on top of a live preview coming from the camera, I recommend to load the shirt in a separate texture, and use OpenGL to display the live texture coming from the camera and the shirt RGBA texture 'above' it. Setup of transparent pixels in this case may be handled in a custom shader.

Upvotes: 0

Related Questions