将图像放置在相机拍摄的照片上

时间:2019-04-25 12:04:53

标签: android android-camera

我想使用库将png文件放在应用程序拍摄的图像上 https://github.com/natario1/CameraView 有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您将从onPictureTaken的此代码中获取位图

pictureResult.toBitmap(1000, 1000, new BitmapCallback() {

            @Override
            public void onBitmapReady(Bitmap bitmap) {
                //here bitmap you will get
            }
        });

从位图可以转换png文件

ByteArrayOutputStream bos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 0, bos);
bitmapData = bos.toByteArray();

File f = new File(getCacheDir(), "temp.png");
try {
   boolean newFile = f.createNewFile();

   if (newFile) {
       FileOutputStream fos = new FileOutputStream(f);
       fos.write(bitmapData);
       fos.flush();
       fos.close();
   }

} catch (IOException e) {
   e.printStackTrace();

}

相关问题