我想将png文件放在应用程序使用库https://github.com/natario1/CameraView拍摄的图像上任何想法?
你将从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();
}