无法将叠加层图像与相机响应数据合并

时间:2018-09-07 07:19:43

标签: android camera android-camera android-textureview camera-overlay

我有以下代码将字节保存到相册中。问题是怎么可能 将我在frameLayout中附加的图像合并到相机响应的字节数据中?

我想将在以下FrameLayout中设置的图像添加到字节数据中

mTextureView = (AutoFitTextureView) findViewById(R.id.TextureView);
mainFrame = (FrameLayout)findViewById(R.id.frame);
ImageView img = new ImageView(this);
img.setImageResource(R.drawable.overlay);
mainFrame.addView(img);

下面是保存图像的代码。

public void onClickShutter(View view) {
  mCamera2.takePicture(new ImageReader.OnImageAvailableListener() {
    @Override
    public void onImageAvailable(ImageReader reader) {
      final Image image = reader.acquireLatestImage();
      ByteBuffer buffer = image.getPlanes()[0].getBuffer();
      byte[] bytes = new byte[buffer.remaining()];
      Uri uriTarget = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues());
      OutputStream imageFileOS;
      try {

        imageFileOS = getContentResolver().openOutputStream(uriTarget);
        imageFileOS.write(bytes);
        imageFileOS.flush();
        imageFileOS.close();

        Toast.makeText(MainActivity.this,
            "Image saved: " + uriTarget.toString(),
            Toast.LENGTH_LONG).show();
        //mPreviewState
      } 

0 个答案:

没有答案