Arj*_*ini 15 camera android ffmpeg opengl-es chromakey
我想用Gif或图像像Vigo更改Surface预览底部叠加层
像这样
请告诉我任何sdk或我用于此过滤器的内容
我可以使用此更改顶视图上的叠加层
PictureCallback cameraPictureCallbackJpeg = new PictureCallback()
{
@Override
public void onPictureTaken(byte[] data, Camera camera)
{
// TODO Auto-generated method stub
Bitmap cameraBitmap = BitmapFactory.decodeByteArray
(data, 0, data.length);
int wid = cameraBitmap.getWidth();
int hgt = cameraBitmap.getHeight();
// Toast.makeText(getApplicationContext(), wid+""+hgt, Toast.LENGTH_SHORT).show();
Bitmap newImage = Bitmap.createBitmap
(wid, hgt, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(newImage);
canvas.drawBitmap(cameraBitmap, 0f, 0f, null);
Drawable drawable = getResources().getDrawable
(R.drawable.mark3);
drawable.setBounds(20, 30, drawable.getIntrinsicWidth()+20, drawable.getIntrinsicHeight()+30);
drawable.draw(canvas);
File storagePath = new File(Environment.
getExternalStorageDirectory() + "/PhotoAR/");
storagePath.mkdirs();
File myImage = new File(storagePath,
Long.toString(System.currentTimeMillis()) + ".jpg");
try
{
FileOutputStream out = new FileOutputStream(myImage);
newImage.compress(Bitmap.CompressFormat.JPEG, 80, out);
out.flush();
out.close();
}
catch(FileNotFoundException e)
{
Log.d("In Saving File", e + "");
}
catch(IOException e)
{
Log.d("In Saving File", e + "");
}
camera.startPreview();
newImage.recycle();
newImage = null;
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file://" + myImage.getAbsolutePath()), "image/*");
startActivity(intent);
}
};
Run Code Online (Sandbox Code Playgroud)
输出
使用GLSurfaceView.基本思想是在GLSurfaceView中预览相机并绘制OpenGL渲染.
常见的方法是继承GLSurfaceView并实现GLSurfaceView.Renderer.渲染任务通过实现接口来执行.
public class CameraRenderer extends GLSurfaceView implements GLSurfaceView.Renderer, SurfaceTexture.OnFrameAvailableListener {
@Override
public synchronized void onSurfaceCreated(GL10 gl, EGLConfig config) {
...
//compile shader here
}
@Override
public synchronized void onSurfaceChanged(GL10 gl, int width, int height) {
...
//open camera and start preview here
}
@Override
public synchronized void onDrawFrame(GL10 gl) {
...
//draw frame as required
}
}
Run Code Online (Sandbox Code Playgroud)
看看这个grafika项目,以获得一个更好的想法,这个项目接近你想要做的事情.
归档时间: |
|
查看次数: |
662 次 |
最近记录: |