0

I trying to use Canvas from such methods:

 Canvas mCanvas = mSurface.lockCanvas(null);   
 mSurface.unlockCanvasAndPost(mCanvas);

I need to display images or text on camera preview. The way I choose is to create texture from canvas, which contains views. I gonna combine this texture and texture of video frame. Is it right way?

Chickin Nick
  • 517
  • 1
  • 6
  • 21
  • Possibly related: http://stackoverflow.com/questions/29914448/how-can-i-add-overlay-images-or-text-on-top-of-videos-in-android – Morrison Chang Jan 19 '17 at 15:33
  • @MorrisonChang , I've edit question, thanks! As 'video' I mean a GlSurfaceView which handle frames from camera and recording video file. Sorry – Chickin Nick Jan 19 '17 at 15:50

1 Answers1

1

It is going to be much harder than making a texture in OpenGL.

  Bitmap  bitmap = Bitmap.createBitmap(this.getWidth(), this.getHeight(), Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(bitmap);
  this.draw(canvas); 
  File file = new File(Environment.getExternalStorageDirectory() + "/texture.png");
  bitmap.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(file));

Technically, a Bitmap file or each camera frame is not a texture. To make them textures, you should call a gl function like gltex****(,,,bitmap);

Sung
  • 1,036
  • 1
  • 8
  • 22