我存储图像自动拍摄相机图像。从文件路径获取图像后,bimap值永远为null。我们怎么做?请帮助我们。
private Camera mCamera;
mCamera.takePicture(null, null, mPicture);
自动拍摄相机方法
picture = getOutputMediaFile().getAbsolutePath();
File file=new File(picture);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(),options);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] image = stream.toByteArray();
String img_str = Base64.encodeToString(image, Base64.DEFAULT);
调用相机onCreate
picture = getOutputMediaFile().getPath();(OR)
Bitmap bitmap = BitmapFactory.decodeFile(file.getPath);(OR)
Bitmap bitmap = BitmapFactory.decodeFile(picture);(OR)
我已经获得了图像图片值/storage/emulated/0/Pictures/MyCameraApp/IMG20151215_141506.jpg 当我设置位图时,位图值返回null我们如何将图像文件路径字符串设置为位图
$(function() { // on load
$("#formId").on("submit", function (e) { // use the form submit event
var CheckInDate = $("#CheckInDate").val();
var today = new Date();
var dd = today.getDate();
var c = CheckInDate.split("-");
var cdd = c[0];
var cmm = c[1];
var cyyyy = c[2];
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd='0'+dd
}
if(mm<10) {
mm='0'+mm
}
today = dd+'-'+mm+'-'+yyyy;
if((cyyyy < yyyy) || (cyyyy == yyyy && cmm < mm) || (cyyyy == yyyy && cmm == mm && cdd < dd)) {
$("#DateWarning").html("WrongDate");
e.preventDefault(); // cancel submission
}
else {
$("#DateWarning").html("")
}
});
});
我也像这样尝试
function checkDate() {
var CheckInDate = $("#CheckInDate").val();
var today = new Date();
var dd = today.getDate();
var c = CheckInDate.split("-");
var cdd = c[0];
var cmm = c[1];
var cyyyy = c[2];
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10) {
dd='0'+dd
}
if(mm<10) {
mm='0'+mm
}
today = dd+'-'+mm+'-'+yyyy;
if((cyyyy < yyyy) || (cyyyy == yyyy && cmm < mm) || (cyyyy == yyyy && cmm == mm && cdd < dd)) {
$("#DateWarning").html("WrongDate");
return false;
}
else {
$("#DateWarning").html("");
return true;
}
}
$(function() {
$("#formId").on("submit", function (e) { // use the form submit event
if (!checkDate()) e.preventDefault();
});
});