本文整理汇总了C#中RandomStream.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# RandomStream.Seek方法的具体用法?C# RandomStream.Seek怎么用?C# RandomStream.Seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RandomStream
的用法示例。
在下文中一共展示了RandomStream.Seek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToBitmapImageAsync
public async static Task<WriteableBitmap> ToBitmapImageAsync(this Stream imageStream, Tuple<int, int> downscale, bool useDipUnits, InterpolationMode mode, ImageInformation imageInformation = null)
{
if (imageStream == null)
return null;
using (IRandomAccessStream image = new RandomStream(imageStream))
{
if (downscale != null && (downscale.Item1 > 0 || downscale.Item2 > 0))
{
using (var downscaledImage = await image.ResizeImage(downscale.Item1, downscale.Item2, mode, useDipUnits, imageInformation).ConfigureAwait(false))
{
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(downscaledImage);
downscaledImage.Seek(0);
WriteableBitmap resizedBitmap = null;
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, () =>
{
resizedBitmap = new WriteableBitmap((int)decoder.PixelWidth, (int)decoder.PixelHeight);
using (var s = downscaledImage.AsStream())
{
resizedBitmap.SetSource(s);
}
});
return resizedBitmap;
}
}
else
{
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(image);
image.Seek(0);
WriteableBitmap bitmap = null;
if (imageInformation != null)
{
imageInformation.SetCurrentSize((int)decoder.PixelWidth, (int)decoder.PixelHeight);
imageInformation.SetOriginalSize((int)decoder.PixelWidth, (int)decoder.PixelHeight);
}
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, () =>
{
bitmap = new WriteableBitmap((int)decoder.PixelWidth, (int)decoder.PixelHeight);
bitmap.SetSource(imageStream);
});
return bitmap;
}
}
}
示例2: ToBitmapImageAsync
public async static Task<WriteableBitmap> ToBitmapImageAsync(this byte[] imageBytes, Tuple<int, int> downscale, InterpolationMode mode)
{
if (imageBytes == null)
return null;
using (var imageStream = imageBytes.AsBuffer().AsStream())
using (IRandomAccessStream image = new RandomStream(imageStream))
{
if (downscale != null && (downscale.Item1 > 0 || downscale.Item2 > 0))
{
using (var downscaledImage = await image.ResizeImage((uint)downscale.Item1, (uint)downscale.Item2, mode).ConfigureAwait(false))
{
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(downscaledImage);
downscaledImage.Seek(0);
WriteableBitmap resizedBitmap = null;
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, () =>
{
resizedBitmap = new WriteableBitmap((int)decoder.PixelWidth, (int)decoder.PixelHeight);
using (var s = downscaledImage.AsStream())
{
resizedBitmap.SetSource(s);
}
});
return resizedBitmap;
}
}
else
{
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(image);
image.Seek(0);
WriteableBitmap bitmap = null;
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Low, () =>
{
bitmap = new WriteableBitmap((int)decoder.PixelWidth, (int)decoder.PixelHeight);
bitmap.SetSource(imageStream);
});
return bitmap;
}
}
}