GetPixelDataAsync() приватный Метод

private GetPixelDataAsync ( ) : IAsyncOperation
Результат IAsyncOperation
Пример #1
0
        public static async Task <byte[]> ImageToByteArray(Uri uri)
        {
            Windows.Storage.Streams.IRandomAccessStream random = await Windows.Storage.Streams.RandomAccessStreamReference.CreateFromUri(uri).OpenReadAsync();

            Windows.Graphics.Imaging.BitmapDecoder decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(random);

            Windows.Graphics.Imaging.PixelDataProvider pixelData = await decoder.GetPixelDataAsync();

            return(pixelData.DetachPixelData());
        }
Пример #2
0
        private async static Task<byte[]> GetPixelData(BitmapDecoder decoder, uint startPointX, uint startPointY,
            uint width, uint height, uint scaledWidth, uint scaledHeight)
        {
            BitmapTransform transform = new BitmapTransform();
            BitmapBounds bounds = new BitmapBounds();
            bounds.X = startPointX;
            bounds.Y = startPointY;
            bounds.Height = height;
            bounds.Width = width;
            transform.Bounds = bounds;
            transform.ScaledWidth = scaledWidth;
            transform.ScaledHeight = scaledHeight;

            // Get the cropped pixels within the bounds of transform.
            PixelDataProvider pix = await decoder.GetPixelDataAsync(
                BitmapPixelFormat.Bgra8,
                BitmapAlphaMode.Straight,
                transform,
                ExifOrientationMode.IgnoreExifOrientation,
                ColorManagementMode.ColorManageToSRgb);
            byte[] pixels = pix.DetachPixelData();
            return pixels;
        }
Пример #3
0
 protected async Task<byte[]> getPixelData(BitmapDecoder decoder)
 {
     PixelDataProvider pixelProvider = await decoder.GetPixelDataAsync(
         BitmapPixelFormat.Rgba8,
         BitmapAlphaMode.Straight,
         new BitmapTransform(),
         ExifOrientationMode.RespectExifOrientation,
         ColorManagementMode.ColorManageToSRgb
         );
     return pixelProvider.DetachPixelData();
 }