0

I have a camerapreview displayed on a textureView which works pretty well. But I can't mask the textureView with a circular mask. As soon as I use masking nothing gets displayed. Is this not possible? Or is there another way?

  • It's easy to put an ImageView overlay above the preview surface, and load a png with transparent areas where you need them. Doing this in OpenGL is much more work – Alex Cohn Mar 07 '16 at 19:00
  • Yeah but my background is not static - its an animated gradient. – Alexander Braunreuther Mar 07 '16 at 22:01
  • Are you overlaying the preview texture with your animated texture? Please disclose the relevant part of your code. Setting transparency in OpenGL may be tricky. – Alex Cohn Mar 07 '16 at 22:42
  • I used this library: https://github.com/christophesmet/android_maskable_layout .. It worked for all other views and layouts but not on the texture view. I also managed to create a circular view with an glsurfaceview but this lay on top of the application and doesn't get animated with the layout it should lay in. – Alexander Braunreuther Mar 07 '16 at 22:45
  • If you have code that displays a camera preview in a circular area on a GLSurfaceView, you should be able to just render that on a TextureView. – fadden Mar 08 '16 at 06:40
  • Okay how? I thought I can't change the geometry of a textureview – Alexander Braunreuther Mar 08 '16 at 08:18

1 Answers1

0

You should use the API SurfaceTexture.

  1. render camera frames to a SurfaceTexture created by yourself
  2. draw the frame in the surfaceTexture to screen. During the drawing, you use a specific opengl vertex array to implement round corners.

Here is an very helpful article with source code on github.

https://medium.com/@fabrantes/rounded-video-corners-on-android-3467841cc1b

dragonfly
  • 1,151
  • 14
  • 35
  • This should be a comment, not an answer. If it is a duplicate question then [vote to close](http://stackoverflow.com/help/privileges/close-questions) as such and/or leave a comment once you [earn](http://meta.stackoverflow.com/q/146472) enough [reputation](http://stackoverflow.com/help/whats-reputation). If the question is not a duplicate then tailor the answer to this specific question. – Petter Friberg May 16 '17 at 08:16