本文整理汇总了C#中Windows.Storage.Streams.IBuffer.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# IBuffer.ToArray方法的具体用法?C# IBuffer.ToArray怎么用?C# IBuffer.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows.Storage.Streams.IBuffer
的用法示例。
在下文中一共展示了IBuffer.ToArray方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EncodeToBase64String
/// <summary>
/// Encodes a buffer to a base64 string.
/// </summary>
/// <param name="buffer">Input buffer.</param>
/// <returns>Base64-encoded output string.</returns>
public static string EncodeToBase64String( IBuffer buffer )
{
if (buffer == null)
throw new ArgumentNullException("buffer");
return Convert.ToBase64String(buffer.ToArray());
}
示例2: Sign
/// <summary>
/// Signs digital content. For more information, see MACs, Hashes, and Signatures.
/// </summary>
/// <param name="key">Key used for signing.</param>
/// <param name="data">Data to be signed.</param>
/// <returns>Signed data.</returns>
public static IBuffer Sign( CryptographicKey key, IBuffer data )
{
if (key.Hash != null)
{
var signature = key.Hash.ComputeHash(data.ToArray());
return new WindowsRuntimeBuffer(signature);
}
throw new NotImplementedException();
}
示例3: SaveToPicturesLibraryAsync
public static async Task SaveToPicturesLibraryAsync(IBuffer bufImage, string fileName, CancellationToken cancellationToken = default(CancellationToken))
{
var folder = await KnownFolders.PicturesLibrary.CreateFolderAsync("ImageVerificationExtras", CreationCollisionOption.OpenIfExists).AsTask(cancellationToken).ConfigureAwait(false);
var file = await folder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting).AsTask(cancellationToken).ConfigureAwait(false);
using (var stream = await file.OpenStreamForWriteAsync().ConfigureAwait(false))
{
var data = bufImage.ToArray();
await stream.WriteAsync(data, 0, data.Length, cancellationToken).ConfigureAwait(false);
await stream.FlushAsync(cancellationToken).ConfigureAwait(false);
}
}
示例4: Salsa20RandomGenerator
public Salsa20RandomGenerator(IBuffer key)
{
if (key == null)
throw new ArgumentNullException("key");
key = HashAlgorithmProvider
.OpenAlgorithm(HashAlgorithmNames.Sha256)
.HashData(key);
var iv = new byte[]
{
0xE8, 0x30, 0x09, 0x4B,
0x97, 0x20, 0x5D, 0x2A
};
_cipher = new Salsa20Cipher(key.ToArray(), iv);
}
示例5: GetDataLabelString
string GetDataLabelString(IBuffer data, uint scanDataType)
{
string result = null;
// Only certain data types contain encoded text.
// To keep this simple, we'll just decode a few of them.
if (data == null)
{
result = "No data";
}
else
{
switch (BarcodeSymbologies.GetName(scanDataType))
{
case "Upca":
case "UpcaAdd2":
case "UpcaAdd5":
case "Upce":
case "UpceAdd2":
case "UpceAdd5":
case "Ean8":
case "Ean13":
// The UPC, EAN8, EAN13, and 2 of 5 families encode the digits 0..9
// which are then sent to the app in a UTF8 string (like "01234")
// This is not an exhaustive list of symbologies that can be converted to a string
case "Qr":
// Need to distinguish the scan data among Numeric, Alphanumeric, Binary/Byte, and Kanji/Kana.
// But as current barcode scanner could not distinguish the data is in Binary/Byte format or in rest 3 formats.
// So to read the decoded data as string.
result = string.Format("{0}", System.Text.Encoding.UTF8.GetString(data.ToArray()));
break;
default:
// Some other unsupport symbologies and just leave it as binary data
result = string.Format("Decoded data unavailable. Raw label data: {0}", GetDataString(data));
break;
}
}
return result;
}
示例6: SetAsync
public async Task SetAsync(string key, IBuffer buffer, DateTime expires)
{
if (key == null)
{
throw new ArgumentNullException("The parameter key must not be null.");
}
if (buffer == null)
{
throw new ArgumentNullException("The parameter buffer must not be null.");
}
if (fileDb.IsOpen)
{
var bytes = buffer.ToArray();
var ok = await Task.Run(() => AddOrUpdateRecord(key, bytes, expires));
if (!ok && (await RepairDatabase()))
{
await Task.Run(() => AddOrUpdateRecord(key, bytes, expires));
}
}
}
示例7: CreateStringFromBuffer
public async Task<string> CreateStringFromBuffer(IBuffer buffer)
{
var bytes = buffer.ToArray();
return await Task.FromResult(Encoding.UTF8.GetString(bytes, 0, bytes.Length));
}
示例8: WriteAsyncInternal
internal async Task<WriteResponse> WriteAsyncInternal(byte handle, IBuffer data)
{
await brick.SendCommandAsyncInternal(RequestTelegram.Write(handle, data.ToArray()));
return ResponseTelegram.Write(brick.LastResponse);
}
示例9: SaveImage
private async void SaveImage(IBuffer pixelBuffer)
{
//Rendu du composant Xaml, ici le graphique 'Syncfusion.Chart', sous forme d'image en mémoire.
RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap();
//await renderTargetBitmap.RenderAsync(doughnutMadelin, (int)myDoughnutActualWidth, (int)myDoughnut.ActualHeight);
// var pixelBuffer = await renderTargetBitmap.GetPixelsAsync();
var localFolder = Windows.Storage.KnownFolders.PicturesLibrary;
string filepicname = homewebview.DocumentTitle;
// var localFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
var saveFile = await localFolder.CreateFileAsync(filepicname+".png", Windows.Storage.CreationCollisionOption.OpenIfExists);
// Encodage de l'image en mémoire dans le fichier désigné sur le disque
using (var fileStream = await saveFile.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite))
{
var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, fileStream);
encoder.SetPixelData(
BitmapPixelFormat.Rgba8,
BitmapAlphaMode.Premultiplied,
(uint)homewebview.ActualWidth,
(uint)homewebview.ActualHeight,
DisplayInformation.GetForCurrentView().LogicalDpi,
DisplayInformation.GetForCurrentView().LogicalDpi,
pixelBuffer.ToArray());
await encoder.FlushAsync();
}
MessageDialog one = new MessageDialog("截图保存到图片库");
await one.ShowAsync();
}
示例10: MessageWriteAsyncInternal
internal async Task MessageWriteAsyncInternal(int inboxNumber, IBuffer message)
{
await brick.SendCommandAsyncInternal(RequestTelegram.MessageWrite(inboxNumber, message.ToArray()));
}
示例11: LowSpeedWriteAsyncInternal
internal async Task LowSpeedWriteAsyncInternal(SensorPort sensorPort, IBuffer data, byte responseLength)
{
await brick.SendCommandAsyncInternal(RequestTelegram.LowSpeedWrite(sensorPort, data.ToArray(), responseLength));
}
示例12: _colorImage_ImageOpened
private async void _colorImage_ImageOpened(object sender, RoutedEventArgs e)
{
if (_rtb != null) _rtb = null;
_rtb = new RenderTargetBitmap();
await _rtb.RenderAsync(_colorImage);
_pixelBuffer = await _rtb.GetPixelsAsync();
_pixelBufferData = _pixelBuffer.ToArray();
}
示例13: GetVersion
/// <summary>
/// Gets the database schema version.
/// </summary>
/// <param name="buffer">The version bytes buffer</param>
/// <returns>The database schema version.</returns>
private static Version GetVersion(IBuffer buffer)
{
if (buffer == null)
throw new ArgumentNullException("buffer");
var bytes = buffer.ToArray(0, 4);
var minor = BitConverter.ToUInt16(bytes, 0);
var major = BitConverter.ToUInt16(bytes, 2);
return new Version(major, minor);
}
示例14: GetHeaders
/// <summary>
/// Parse the headers fields.
/// </summary>
/// <param name="input">The input stream.</param>
/// <param name="buffer">The header bytes reader.</param>
/// <returns>The file headers.</returns>
private static async Task<FileHeaders> GetHeaders(
IInputStream input, IBuffer buffer)
{
var result = new FileHeaders();
while (true)
{
buffer = await input.ReadAsync(buffer, 3);
var field = (HeaderFields)buffer.GetByte(0);
var size = BitConverter.ToUInt16(buffer.ToArray(1, 2), 0);
if (size > 0)
buffer = await input.ReadAsync(buffer, size);
switch (field)
{
case HeaderFields.EndOfHeader:
return result;
case HeaderFields.CompressionFlags:
result.UseGZip = buffer.GetByte(0) == 1;
break;
case HeaderFields.EncryptionIV:
result.EncryptionIV = buffer
.ToArray().AsBuffer();
break;
case HeaderFields.MasterSeed:
result.MasterSeed = buffer
.ToArray().AsBuffer();
break;
case HeaderFields.StreamStartBytes:
result.StartBytes = buffer
.ToArray().AsBuffer();
break;
case HeaderFields.TransformSeed:
result.TransformSeed = buffer
.ToArray().AsBuffer();
break;
case HeaderFields.TransformRounds:
result.TransformRounds = BitConverter.ToUInt64(
buffer.ToArray(), 0);
break;
case HeaderFields.ProtectedStreamKey:
result.ProtectedStreamKey = buffer
.ToArray().AsBuffer();
break;
case HeaderFields.InnerRandomStreamID:
result.RandomAlgorithm = (CrsAlgorithm)
BitConverter.ToUInt32(buffer.ToArray(), 0);
break;
}
}
}