请在下面找到我正在尝试的代码片段。
PictureCallback mPicture = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
Bitmap bMap = BitmapFactory.decodeByteArray(data, 0, data.length);
String encoded = encodeTobase64(bMap);
Intent i = new Intent(Photocapture.this, ConfirmCapture.class);
i.putExtra("img", encoded);
startActivity(i);
}
};
protected String encodeTobase64(Bitmap image) {
Bitmap immagex = image;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
immagex.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] b = baos.toByteArray();
String imageEncoded = Base64.encodeToString(b,Base64.DEFAULT);
return imageEncoded;
}
当我执行此操作时,我的活页夹交易失败。我正在开发自定义相机应用程序。任何输入都将有助于继续!