本文整理汇总了C#中IRandomAccessStream.GetInputStreamAt方法的典型用法代码示例。如果您正苦于以下问题:C# IRandomAccessStream.GetInputStreamAt方法的具体用法?C# IRandomAccessStream.GetInputStreamAt怎么用?C# IRandomAccessStream.GetInputStreamAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRandomAccessStream
的用法示例。
在下文中一共展示了IRandomAccessStream.GetInputStreamAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertIRandomAccessStreamByte
private static async Task<byte[]> ConvertIRandomAccessStreamByte(IRandomAccessStream stream)
{
DataReader read = new DataReader(stream.GetInputStreamAt(0));
await read.LoadAsync((uint)stream.Size);
byte[] temp = new byte[stream.Size];
read.ReadBytes(temp);
return temp;
}
示例2: GetPhotoBits
/// <summary>
/// Returns a byte array with the content of the stream.
/// </summary>
/// <param name="stream">stream to get bytes for</param>
/// <returns>awaitable byte array</returns>
public static async Task<byte[]> GetPhotoBits(IRandomAccessStream stream)
{
Debug.Assert(stream != null, "GetPhotoBits should not be called with a null stream.");
var reader = new DataReader(stream.GetInputStreamAt(0));
var bytes = new byte[stream.Size];
await reader.LoadAsync((uint)stream.Size);
reader.ReadBytes(bytes);
return bytes;
}
示例3: IRandomAccessStreamToByteArr
public static async Task<byte[]> IRandomAccessStreamToByteArr(IRandomAccessStream irStream)
{
DataReader reader = new Windows.Storage.Streams.DataReader(irStream.GetInputStreamAt(0));
await reader.LoadAsync((uint)irStream.Size);
byte[] pixels = new byte[irStream.Size];
reader.ReadBytes(pixels);
return pixels;
}
示例4: SaveVideo
private async Task SaveVideo(IRandomAccessStream videoStream)
{
StorageFile videoFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("MyCam.mp4");
using (DataReader reader = new DataReader(videoStream.GetInputStreamAt(0)))
{
await reader.LoadAsync((uint)videoStream.Size);
byte[] data = new byte[(int)videoStream.Size];
reader.ReadBytes(data);
await FileIO.WriteBytesAsync(videoFile, data);
}
}
示例5: RandomAccessStreamToBytes
internal static byte[] RandomAccessStreamToBytes(IRandomAccessStream randomstream)
{
Stream stream = randomstream.GetInputStreamAt(0).AsStreamForRead();
var memoryStream = new MemoryStream();
if (stream != null)
{
return StreamToBytes(stream);
}
else
{
return null;
}
}
示例6: streamToString
//stream to base64
public static async Task<string> streamToString(IRandomAccessStream fileStream)
{
string Base64String = "";
var reader = new DataReader(fileStream.GetInputStreamAt(0));
await reader.LoadAsync((uint)fileStream.Size);
byte[] byteArray = new byte[fileStream.Size];
reader.ReadBytes(byteArray);
Base64String = Convert.ToBase64String(byteArray);
//string s = ByteToString(byteArray);
return Base64String;
}
示例7: ImageInitialize
public async Task<byte[]> ImageInitialize(IRandomAccessStream stream)
{
var size = stream.Size;
byte[] bytes = new byte[size];
var reader = new DataReader(stream.GetInputStreamAt(0));
await reader.LoadAsync((uint)size);
reader.ReadBytes(bytes);
return bytes;
}
示例8: Play
private async Task Play(IRandomAccessStream buffer)
{
if (buffer == null)
throw new ArgumentNullException("buffer");
var storageFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
if (!string.IsNullOrEmpty(_fileName))
{
var oldFile = await storageFolder.GetFileAsync(_fileName);
await oldFile.DeleteAsync();
}
await Dispatcher.RunAsync(
CoreDispatcherPriority.Normal,
async () =>
{
var storageFile = await storageFolder.CreateFileAsync(AudioFileName, CreationCollisionOption.GenerateUniqueName);
_fileName = storageFile.Name;
using (var fileStream = await storageFile.OpenAsync(FileAccessMode.ReadWrite))
{
await RandomAccessStream.CopyAndCloseAsync(
buffer.GetInputStreamAt(0),
fileStream.GetOutputStreamAt(0));
await buffer.FlushAsync();
buffer.Dispose();
}
var stream = await storageFile.OpenAsync(FileAccessMode.Read);
playBack.SetSource(stream, storageFile.FileType);
playBack.Play();
});
}
示例9: UnprotectPDFStream
public static async Task<IRandomAccessStream> UnprotectPDFStream(IRandomAccessStream source)
{
// Create a DataProtectionProvider object.
DataProtectionProvider Provider = new DataProtectionProvider();
InMemoryRandomAccessStream unprotectedData = new InMemoryRandomAccessStream();
IOutputStream dest = unprotectedData.GetOutputStreamAt(0);
await Provider.UnprotectStreamAsync(source.GetInputStreamAt(0), dest);
await unprotectedData.FlushAsync();
unprotectedData.Seek(0);
return unprotectedData;
}
示例10: ProtectPDFStream
public static async Task<IRandomAccessStream> ProtectPDFStream(IRandomAccessStream source)
{
// Create a DataProtectionProvider object for the specified descriptor.
DataProtectionProvider Provider = new DataProtectionProvider("LOCAL=user");
InMemoryRandomAccessStream protectedData = new InMemoryRandomAccessStream();
IOutputStream dest = protectedData.GetOutputStreamAt(0);
await Provider.ProtectStreamAsync(source.GetInputStreamAt(0), dest);
await dest.FlushAsync();
//Verify that the protected data does not match the original
//DataReader reader1 = new DataReader(source.GetInputStreamAt(0));
//DataReader reader2 = new DataReader(protectedData.GetInputStreamAt(0));
//var size1 = await reader1.LoadAsync((uint)(source.Size < 10000 ? source.Size : 10000));
//var size2 = await reader2.LoadAsync((uint)(protectedData.Size < 10000 ? protectedData.Size : 10000));
//IBuffer buffOriginalData = reader1.ReadBuffer((uint)size1);
//IBuffer buffProtectedData = reader2.ReadBuffer((uint)size2);
//if (CryptographicBuffer.Compare(buffOriginalData, buffProtectedData))
//{
// throw new Exception("ProtectPDFStream returned unprotected data");
//}
//protectedData.Seek(0);
//await protectedData.FlushAsync();
// Return the encrypted data.
return protectedData;
}
示例11: GetStringFromStream
public static async Task<string> GetStringFromStream(IRandomAccessStream stream)
{
using (var dataReader = new DataReader(stream.GetInputStreamAt(0)))
{
var size = await dataReader.LoadAsync((uint)stream.Size);
return dataReader.ReadString(size);
}
}
示例12: StoreToFolderAsync
public static async Task<StorageFile> StoreToFolderAsync(string fullName, StorageFolder folder, IRandomAccessStream inputStream, CancellationToken cancelToken = default(CancellationToken))
{
if (fullName == "") return null;
var file = await folder.CreateFileAsync(fullName, CreationCollisionOption.ReplaceExisting);
using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite))
{
await RandomAccessStream.CopyAndCloseAsync(inputStream.GetInputStreamAt(0), stream.GetOutputStreamAt(0)).AsTask(cancelToken);
}
return file;
}
示例13: GetStreamToBytesAsync
// ToDo refactor please if EncodeHelper is not the apropiate place
public static async Task<byte[]> GetStreamToBytesAsync(IRandomAccessStream fileStream)
{
using (DataReader reader = new DataReader(fileStream.GetInputStreamAt(0)))
{
await reader.LoadAsync((uint)fileStream.Size);
byte[] pixeByte = new byte[fileStream.Size];
reader.ReadBytes(pixeByte);
return pixeByte;
}
}
示例14: GetBytesFromStream
public async Task<byte[]> GetBytesFromStream(IRandomAccessStream randomStream)
{
var reader = new DataReader(randomStream.GetInputStreamAt(0));
var bytes = new byte[randomStream.Size];
await reader.LoadAsync((uint)randomStream.Size);
reader.ReadBytes(bytes);
return bytes;
}
示例15: ConvertImagetoByte
/// <summary>
/// Convert ImageObject to Byte Array
/// </summary>
/// <param name="fileStream">IRandomAccessStream</param>
/// <returns>Byte Array</returns>
public static async Task<byte[]> ConvertImagetoByte(IRandomAccessStream fileStream)
{
var reader = new DataReader(fileStream.GetInputStreamAt(0));
await reader.LoadAsync((uint)fileStream.Size);
byte[] pixels = new byte[fileStream.Size];
reader.ReadBytes(pixels);
return pixels;
}