当前位置: 首页>>代码示例>>C#>>正文


C# Android.Recycle方法代码示例

本文整理汇总了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;
        }
开发者ID:dbeattie71,项目名称:FFImageLoading,代码行数:19,代码来源:BlurTransformation.cs

示例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();
        }
开发者ID:SansSkill,项目名称:Introproject,代码行数:66,代码来源:CameraActivity.cs


注:本文中的Android.Recycle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。