windows 8 - Save InkManager images to byte array -
i'm new win8 app programming has been assigned write windows store app capture customers' signature , save sql server. after research found great tutorial http://www.codeproject.com/articles/416878/metro-paint shows how draw , save image locally. question how use inkmanager class in tutorial save image byte arrays can save image sqlserver? thanks!
private async void btnsavewritingasimage_click(object sender, routedeventargs e) { if (myinkmanager.getstrokes().count > 0) { try { windows.storage.pickers.filesavepicker savepicker = new windows.storage.pickers.filesavepicker(); savepicker.suggestedstartlocation = windows.storage.pickers.pickerlocationid.desktop; savepicker.defaultfileextension = ".png"; savepicker.filetypechoices.add("png", new string[] { ".png" }); savepicker.filetypechoices.add("jpg", new string[] { ".jpg" }); storagefile filesave = await savepicker.picksavefileasync(); ioutputstream ab = await filesave.openasync(fileaccessmode.readwrite); if (ab != null) await myinkmanager.saveasync(ab); } catch (exception) { var msgdlg = new messagedialog("only handwriting can saved image.", "error while saving"); msgdlg.showasync(); } } else { var msgdlg = new messagedialog("only handwriting can saved image.", "error while saving"); await msgdlg.showasync(); } }
add: (ibuffer.toarray() defined in windowsruntimebufferextensions)
using system.runtime.interopservices.windowsruntime;
then do:
var buffer = await fileio.readbufferasync(image);//replace ab instead of image var bytes = buffer.toarray();
Comments
Post a Comment