I researched a lot and tried a bunch of things that don't work. So what I need is:
Thanks.
I capture a picture and display it on page like this:
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
}
Here is the answer:
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
}