本文整理汇总了C#中System.ByteBuffer.rewind方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.rewind方法的具体用法?C# ByteBuffer.rewind怎么用?C# ByteBuffer.rewind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.rewind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: decodeToBitmap
private Bitmap decodeToBitmap(ByteBuffer jpegData, int sampleSize)
{
sbyte[] jpegDataArray = new sbyte[jpegData.remaining()];
jpegData.get(jpegDataArray);
jpegData.rewind();
BitmapFactory.Options option = new BitmapFactory.Options();
option.inSampleSize = sampleSize;
return BitmapFactory.decodeByteArray(jpegDataArray, 0, jpegDataArray.Length, option);
}
示例2: decodeToBitmap
private Bitmap decodeToBitmap(ByteBuffer jpegData, int sampleSize, int cropWidth)
{
sbyte[] jpegDataArray = new sbyte[jpegData.remaining()];
jpegData.get(jpegDataArray);
jpegData.rewind();
BitmapFactory.Options option = new BitmapFactory.Options();
option.inSampleSize = sampleSize;
if (cropWidth == 0)
{
return BitmapFactory.decodeByteArray(jpegDataArray, 0, jpegDataArray.Length, option);
}
Bitmap bitmap = null;
try
{
BitmapRegionDecoder decoder = BitmapRegionDecoder.newInstance(jpegDataArray, 0, jpegDataArray.Length, true);
int cropHeight = cropWidth * decoder.Height / decoder.Width;
Rect cropRect = new Rect(decoder.Width / 2 - cropWidth, decoder.Height / 2 - cropHeight, decoder.Width / 2 + cropWidth, decoder.Height / 2 + cropHeight);
bitmap = decoder.decodeRegion(cropRect, option);
}
catch (IOException e)
{
Console.WriteLine(e.ToString());
Console.Write(e.StackTrace);
}
return bitmap;
}