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

问题描述 投票:-2回答:1

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

android android-camera
1个回答
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();

}

© www.soinside.com 2019 - 2024. All rights reserved.