Confession.toString()



  •  Tiny bit of background:

    • Making WP8 app
    • No clue how to use azure
    • Never worked with images in code
    • 3-4 hours of time left
    • Primary function of app: store images in Azure

    Code snippet says the rest :)

     

    async void uploadToAzure(BitmapImage bmp, String a, String b,String c)
            {
                System.Windows.Media.Imaging.WriteableBitmap wbmp = new System.Windows.Media.Imaging.WriteableBitmap(bmp);
                wbmp = wbmp.Resize(200, 200, WriteableBitmapExtensions.Interpolation.Bilinear);
                byte[] _imageBytes = wbmp.ToByteArray();
                String s = Convert.ToBase64String(_imageBytes, 0, _imageBytes.Length);
                ittab item = new ittab {Image=s,A=a,B=b,C=c,f=1};
                await App.MobileService.GetTable<ittab>().InsertAsync(item);
            }

     

    To get the stuff back,

     await App.MobileService.GetTable<ittab>().ToListAsync() (or something of the sort) , then iterate through the list ...

     



  • I see the WTF. You should be writing out the image to a MemoryStream in PNG format instead of using a WritableBitmap.


Log in to reply