예제 #1
0
        private async void OnFilesOpenPicked(IReadOnlyList <StorageFile> files)
        {
            // Load picked file
            if (files.Count > 0)
            {
                // Check if image and pick first file to show
                var imageFile = files.FirstOrDefault(f => SupportedImageFileTypes.Contains(f.FileType.ToLower()));
                var imageExt  = imageFile.FileType.ToLower();
                if (imageFile != null)
                {
                    // Use WriteableBitmapEx to easily load from a stream
                    using (var stream = await imageFile.OpenReadAsync())
                    {
                        originalBitmap = await new WriteableBitmap(1, 1).FromStream(stream);
                        BitmapEncoder encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream);

                        Stream pixelStream = originalBitmap.PixelBuffer.AsStream();
                        byte[] pixels      = new byte[pixelStream.Length];
                        //doUpload(pixels);
                    }
                    postControl newPost = new postControl();
                    newPost.imgPost.Source = originalBitmap;
                    ImageBrush userBrush = new ImageBrush();
                    userBrush = userBImg;
                    newPost.imgUserPost.Fill = userBrush;
                    content.Children.Add(newPost);
                    Debug.WriteLine("funcionou até aqui");
                }
            }
        }
예제 #2
0
        private async void LoadPosts()
        {
            content.Children.Clear();
            var posts = await GetPosts();

            foreach (var post in posts)
            {
                postControl newPost = new postControl();
                byte[]      img     = Convert.FromBase64String(post.image);
                originalBitmap         = new WriteableBitmap(400, 360).FromByteArray(img, img.Length);
                newPost.imgPost.Source = originalBitmap;
                ImageBrush userBrush = new ImageBrush();
                userBrush = userBImg;
                newPost.imgUserPost.Fill = userBrush;
                newPost.description.Text = post.description;
                content.Children.Add(newPost);
                Debug.WriteLine("funcionou até aqui");
            }
            log = true;
        }