本文整理匯總了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;
}