本文整理汇总了C#中Android.Recycle方法的典型用法代码示例。如果您正苦于以下问题:C# Android.Recycle方法的具体用法?C# Android.Recycle怎么用?C# Android.Recycle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android
的用法示例。
在下文中一共展示了Android.Recycle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Transform
protected override Android.Graphics.Bitmap Transform(Android.Graphics.Bitmap source)
{
Bitmap outBitmap = Bitmap.CreateBitmap(source.Width, source.Height, Bitmap.Config.Argb8888);
Canvas canvas = new Canvas(outBitmap);
canvas.DrawBitmap(source, 0, 0, null);
RenderScript rs = RenderScript.Create(mContext);
Allocation overlayAlloc = Allocation.CreateFromBitmap(rs, outBitmap);
ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.Create(rs, overlayAlloc.Element);
blur.SetInput(overlayAlloc);
blur.SetRadius(mRadius);
blur.ForEach(overlayAlloc);
overlayAlloc.CopyTo(outBitmap);
source.Recycle();
rs.Destroy();
return outBitmap;
}
示例2: SetPreviews
/// <summary>
/// Create 6 binarized images with different threshholds
/// </summary>
/// <param name="bmp"></param>
public void SetPreviews(Android.Graphics.Bitmap bmp)
{
if (_boxThread.IsAlive)
{
_cameraActive = false;
}
//wait for thread to abort
int c = 0;
while (_boxThread.IsAlive && c < 5000)
{
Thread.Sleep(1);
c++;
}
if (_boxThread.IsAlive)
{
HandleError("Drawing error. Restarting application...");
return;
}
double scaleWidth = (double)(screenWidth / 2) / (double)bmp.Width;
double scaleHeight = (double)(screenHeight / 3) / (double)bmp.Height;
Android.Graphics.Bitmap croppedPreviewBitmap = null;
if (scaleWidth <= scaleHeight)
{
croppedPreviewBitmap = Android.Graphics.Bitmap.CreateScaledBitmap(bmp, (int)(bmp.Width * scaleWidth), (int)(bmp.Height * scaleWidth), false);
}
else
{
croppedPreviewBitmap = Android.Graphics.Bitmap.CreateScaledBitmap(bmp, (int)(bmp.Width * scaleHeight), (int)(bmp.Height * scaleHeight), false);
}
bmp.Recycle();
GC.Collect();
Android.Graphics.Bitmap previewImage1 = BitmapHelpers.Binarize(croppedPreviewBitmap, threshholds[0]);
Android.Graphics.Bitmap previewImage2 = BitmapHelpers.Binarize(croppedPreviewBitmap, threshholds[1]);
Android.Graphics.Bitmap previewImage3 = BitmapHelpers.Binarize(croppedPreviewBitmap, threshholds[2]);
Android.Graphics.Bitmap previewImage4 = BitmapHelpers.Binarize(croppedPreviewBitmap, threshholds[3]);
Android.Graphics.Bitmap previewImage5 = BitmapHelpers.Binarize(croppedPreviewBitmap, threshholds[4]);
Android.Graphics.Bitmap previewImage6 = BitmapHelpers.Binarize(croppedPreviewBitmap, threshholds[5]);
croppedPreviewBitmap.Recycle();
GC.Collect();
//stop camera
if (_camera != null)
{
_camera.Unlock();
_camera.StopPreview();
_camera.SetPreviewCallback(null);
_camera.Release();
_camera = null;
}
DrawResult(previewImage1, previewImage2, previewImage3, previewImage4, previewImage5, previewImage6, 0);
previewImage1.Recycle();
previewImage2.Recycle();
previewImage3.Recycle();
previewImage4.Recycle();
previewImage5.Recycle();
previewImage6.Recycle();
GC.Collect();
}