我经常研究并尝试了一些不起作用的东西。 所以我需要的是:
感谢。
我拍摄照片并在页面上显示如下:
function captureImage()
{
//S1: Create a new Camera Capture UI Object
var cam = Windows.Media.Capture.CameraCaptureUI();
var name = document.getElementById('ticketnum').innerHTML+'.jpg';
var folder = Windows.Storage.KnownFolders.picturesLibrary; //was windows.storage
//S2: Perform an Async operation where the Capture
// Image will be stored as file
cam.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo)
.done(function (data) {
if (data)
{
//S3: Create a URL for the capture image
// and assign it to the <Img>
var urlpic= window.URL.createObjectURL(data);
document.getElementById('imgCapture').src
= urlpic;
//**save picture to memory as ticket number, creating new img, how to put the file inside?
folder.createFileAsync(name, Windows.Storage.CreationCollisionOption.replaceExisting) //creates new file?
.then(function (file) {
//file.copyAndReplaceAsync(window.URL.createObjectURL(data));
// HOW TO SAVE IMAGE TO pictures library?
});
}
}
, error);
document.getElementById('txtserver').value = "Done";
//save image to memory?
//clean up resources
}
答案 0 :(得分:0)
以下是答案:
function testSavePictureDisk() {
// S1: Create a new Camera Capture UI Object
var cam = Windows.Media.Capture.CameraCaptureUI();
//location?
var name = document.getElementById('ticketnum').innerHTML + '.jpg';
var folder = Windows.Storage.KnownFolders.picturesLibrary; //was windows.storage
// S2: Perform an Async operation where the Capture
// Image will be stored as file
folder.createFileAsync(name,
Windows.Storage.CreationCollisionOption.replaceExisting) //creates new file?
.then(function (file) {
cam.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo)
.done(function (data) {
if (data) {
//S3: Create a URL for the capture image
// and assign it to the <Img>
document.getElementById('imgCapture').src = window.URL.createObjectURL(data);
//**save picture to memory as ticket number
data.moveAndReplaceAsync(file);
//**end testing for local save
}
}
, error);
document.getElementById('txtserver').value = "Done";
//save image to memory?
//clean up resources
});//end of new file creation
}