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


C# Android.DrawBitmap方法代码示例

本文整理汇总了C#中Android.DrawBitmap方法的典型用法代码示例。如果您正苦于以下问题:C# Android.DrawBitmap方法的具体用法?C# Android.DrawBitmap怎么用?C# Android.DrawBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android的用法示例。


在下文中一共展示了Android.DrawBitmap方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnDraw

        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw (canvas);

            if (bitmap == null || bitmap.Width != canvas.Width || bitmap.Height != canvas.Height) {
                if (bitmap != null)
                    bitmap.Dispose ();

                bitmap = Bitmap.CreateBitmap (canvas.Width, canvas.Height, Bitmap.Config.Argb8888);
            }

            try
            {
                using (var surface = SKSurface.Create (canvas.Width, canvas.Height, SKImageInfo.PlatformColorType, SKAlphaType.Premul, bitmap.LockPixels (), canvas.Width * 4)) {
                    var skcanvas = surface.Canvas;
                    skcanvas.Scale (((float)canvas.Width)/(float)skiaView.Width, ((float)canvas.Height)/(float)skiaView.Height);
                    iskiaView.SendDraw (skcanvas);
                }
            }
            finally {
                bitmap.UnlockPixels ();
            }

            canvas.DrawBitmap (bitmap, 0, 0, null);
        }
开发者ID:Core2D,项目名称:SkiaSharp,代码行数:25,代码来源:NativeSkiaView.cs

示例2: OnDraw

        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            base.OnDraw(canvas);
            //if this is the 1st call of draw
            if (init)
            {
                original = BitmapFactory.DecodeResource(Resources, Resource.Drawable.pitchbg0);
                bm = Bitmap.CreateBitmap(original, 0, 0, original.Width, original.Height, n, true);
                init = false;
            }//end if

            yDiff = Receive_Singleton.Instance.Current_ses.Sensors[Settings_Singleton.Instance.G0Y].Values[Receive_Singleton.Instance.Current_ses.Sensors[Settings_Singleton.Instance.G0Y].Values.Length - 1].Value / divider;

            m.SetTranslate(xOffCenter, yOffCenter + yDiff);

            canvas.DrawBitmap(bm, m, null);
            Invalidate();
        }
开发者ID:OML,项目名称:OML_App,代码行数:18,代码来源:PitchControls.cs

示例3: OnDraw

      protected override void OnDraw(Android.Graphics.Canvas canvas)
      {
         base.OnDraw(canvas);

         lock (this)
         {
            Image<Bgr, byte> image = _bgrBuffers.GetBuffer(0);

            if (image != null && !_imageSize.IsEmpty && canvas != null)
            {
               Stopwatch w = Stopwatch.StartNew();

               if ((_bmpImage != null) && (!_imageSize.Equals(_bmpImage.Size)))
               {
                  _bmpImage.Dispose();
                  _bmpImage = null;
                  _bmp.Dispose();
                  _bmp = null;
               }

               if (_bmpImage == null)
               {
                  _bmp = Android.Graphics.Bitmap.CreateBitmap(_imageSize.Width, _imageSize.Height, Android.Graphics.Bitmap.Config.Rgb565);
                  _bmpImage = new BitmapRgb565Image(_bmp);
               }

               _bmpImage.ConvertFrom(image);

               canvas.DrawBitmap(_bmp, 0, 0, _paint);

               w.Stop();

               _watch.Stop();
               
#if DEBUG
               canvas.DrawText(String.Format("{0:F2} FPS; {1}x{2}; Render Time: {3} ms",
                  1.0 / _watch.ElapsedMilliseconds * 1000,
                  _imageSize.Width,
                  _imageSize.Height,
                  w.ElapsedMilliseconds), 20, 20, _paint);
#endif
               _watch.Reset();
               _watch.Start();
            }
         }
      }
开发者ID:reidblomquist,项目名称:emgucv,代码行数:46,代码来源:ProcessedCameraPreview.cs

示例4: OnDraw

        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            // On draw or redraw, we should
            // get our cached bitmap
            Bitmap gameTargetBitmap = GetBitmapFromMemCache("target");

            // For multiple dragging object, but for
            // now we only have one. :)
            foreach (DragObject dObject in dragObjects) {

                #region Draw transparent target area
                paint.SetStyle(Paint.Style.Fill);
                // Set tranparent paint
                // Change this to another ARGB color to
                // see the target area
                paint.SetARGB(128, 255, 255, 255);

                // Coords for target drop area
                const int x1 = 767;
                const int x2 = 990;
                const int y1 = 204;
                const int y2 = 560;

                // Draw target area
                canvas.DrawRect(x1, y1, x2, y2, paint);

                // Set target drop area for our check if the
                // dragged object is within the drop area bounds
                this.targetDropX1 = x1;
                this.targetDropX2 = x2;
                this.targetDropY1 = y1;
                this.targetDropY2 = y2;

                // Offset the bitmap overlay just a
                // bit to look nice
                const int xOffset = 10;
                const int yOffset = 10;

                // Draw target bitmap overlay
                canvas.DrawBitmap(gameTargetBitmap, targetDropX1 + xOffset, targetDropY1 + yOffset, null);
                #endregion Draw transparent target area with a image overlay

                // Draw object bitmap to drag
                canvas.DrawBitmap(dObject.GetBitmap(), dObject.GetX(), dObject.GetY(), null);
            }
        }
开发者ID:rondelrosario,项目名称:DragAndDrop,代码行数:46,代码来源:DrawView.cs

示例5: OnDraw

        protected override void OnDraw(Android.Graphics.Canvas canvas)
        {
            if (mixerValue == null) // don't do anything if we're not connected to a mixervalue
                return;

            if (bmp == null) {
                bmp = BitmapFactory.DecodeResource (Resources, Resource.Drawable.Fader_Knob);
                Bitmap scaled = Bitmap.CreateScaledBitmap (bmp, 25, 55, true);
                bmp.Recycle();
                bmp = scaled;
            }

            int margin = 60;
            float radius = 4;
            int center = (Width / 2) + 5;
            int minY1 = margin - (bmp.Height / 2);
            int maxY1 = Height - margin - (bmp.Height / 2);
            rangeY = maxY1 - minY1;
            float factor = (float)mixerValue.GetValue() / (float)maxValue;

            bitmapX1 = center - bmp.Width / 2;
            bitmapY1 = maxY1 - (int)(factor * (float)rangeY);

            base.OnDraw (canvas);

            var paint = new Paint ();
            paint.Color = Color.White;
            paint.TextAlign = Paint.Align.Center;
            paint.TextSize = (float)12.0;
            paint.SetTypeface(Typeface.DefaultBold);

            if (channel_name != null)
                canvas.DrawText (channel_name, center - 5, 14, paint); // align with pan control

            int levelX1 = center - (bmp.Width / 2) - 2;
            int levelX2 = center + (bmp.Width / 2);

            paint.TextSize = (float)10.0;
            paint.TextAlign = Paint.Align.Right;

            foreach (var level in faderLevels) {
                float factorLevel = (float)level.Key / (float)maxValue;
                int levelY = maxY1 - (int)(factorLevel * (float)rangeY) + (bmp.Height / 2);

                canvas.DrawRect (levelX1, levelY - 1, levelX2, levelY, paint);
                canvas.DrawText (level.Value, levelX1 - 4, levelY + 3, paint);
            }

            paint.Color = Color.DarkGray;
            RectF rect = new RectF (center - 2, margin, center + 2, Height - margin);
            canvas.DrawRoundRect(rect, radius, radius, paint);
            paint.Color = Color.Black;
            rect = new RectF (center - 1, margin + 1, center + 1, Height - margin - 1);
            canvas.DrawRoundRect(rect, radius, radius, paint);

            bitmapX2 = bitmapX1 + bmp.Width;
            bitmapY2 = bitmapY1 + bmp.Height;

            if (isActive) {
                paint.Alpha = 255;
            } else {
                paint.Alpha = 180;
            }

            canvas.DrawBitmap (bmp, bitmapX1, bitmapY1, paint);

            //bmp.Recycle ();
        }
开发者ID:GeorgeWieggers,项目名称:QuMixDroid_xamarin,代码行数:68,代码来源:Fader.cs

示例6: Draw

            public override void Draw(Android.Graphics.Canvas canvas)
            {
                if (Control == null) return;

                Control.CreateGraphicBuffers();

                var ctime = System.Environment.TickCount;
                Fleux.UIElements.Canvas.drawtime = 0;

                if (Control.offUpdated)
                {
                    lock(Control.offBmp)
                    {

                        Control.Draw(new PaintEventArgs(Control.offGr, new Rectangle(0,0, Control.offBmp.Width, Control.offBmp.Height)));

                        updcnt++;
                    }
                }
                Control.offUpdated = false;

                lock(Control.offBmp)
                {
                    if (Fleux.Core.FleuxApplication.HorizontalMirror)
                    {
                        canvas.Save();
                        canvas.Scale (-1, 1);
                        canvas.Translate (-(float)Control.drect.Width(), 0);
                    }else if (Fleux.Core.FleuxApplication.VerticalMirror)
                    {
                        canvas.Save();
                        canvas.Scale (1, -1);
                        canvas.Translate (0, -(float)Control.drect.Height());
                    }

                    Control.offGr.Flush();

                    canvas.DrawBitmap(Control.offBmp.ABitmap, Control.srect, Control.drect, paint);

                    updcntflush++;
                }
                if (PerfData)
                {
                    ctime = System.Environment.TickCount - ctime;
                    {
                        totime += ctime;
                    }
                    var cavg = totime / (updcnt+1);

                    var cpaint = new Android.Graphics.Paint();
                    cpaint.Color = new Android.Graphics.Color(0xA0, 0xFF, 0xFF, 0xFF);
                    cpaint.SetStyle(Android.Graphics.Paint.Style.Fill);
                    canvas.DrawRect(0,0, 250, 20, cpaint);
                    canvas.DrawText(""+updcnt+":"+updcntflush+":"+updcntinval+" ctime: "+ctime+"cavg:"+cavg+" canv: "+Fleux.UIElements.Canvas.drawtime, 0,20, spaint);
                    cpaint.Dispose();
                    if (updcnt > 100)
                    {
                        totime = 0;
                        updcnt = 0;
                    }
                }
            }
开发者ID:cail,项目名称:fleux,代码行数:62,代码来源:DoubleBufferedControl.cs

示例7: Draw

        public override void Draw(Android.Graphics.Canvas canvas)
        {
            canvas.DrawCircle (mainCenter, mainCenter + 2, radius + radiusBorder, shadowPaint);
            canvas.DrawCircle (mainCenter, mainCenter, radius + radiusBorder, darkerBackPaint);
            canvas.DrawCircle (mainCenter, mainCenter, radius, backPaint);
            canvas.DrawBitmap (icon, mainCenter - icon.Width / 2, mainCenter - icon.Height / 2, imgPaint);

            if (Count != 0) {
                int bubbleCenter = center - removeRadius - bubbleOffset;
                greenPaint.Alpha = redPaint.Alpha = currentBubbleTransparency;
                removePaint.Alpha = 255 - currentBubbleTransparency;
                canvas.DrawCircle (bubbleCenter, bubbleCenter, removeRadius, removePaint);
                canvas.DrawCircle (bubbleCenter, bubbleCenter, innerRadius, Count < 0 ? redPaint : greenPaint);

                var c = Math.Abs (Count).ToString ();
                var textBounds = new Rect ();
                removePaint.GetTextBounds (c, 0, c.Length, textBounds);

                canvas.DrawText (c, bubbleCenter, bubbleCenter + textBounds.Height () / 2, removePaint);
            }
            DrawingCacheEnabled = true;
        }
开发者ID:Andrea,项目名称:FriendTab,代码行数:22,代码来源:CategoryBadge.cs

示例8: Draw

            public override void Draw(Android.Graphics.Canvas canvas)
            {
                if (Control == null) return;

                Control.CreateGraphicBuffers();

                if (origMatrix == null)
                {
                    origMatrix = new Android.Graphics.Matrix();
                    origMatrix.Set (canvas.Matrix);
                }
                if (hMatrix == null)
                {
                    hMatrix = new Android.Graphics.Matrix();
                    hMatrix.Set(origMatrix);
                    hMatrix.PostTranslate(-Control.offBmp.Width, 0);
                    hMatrix.PostScale(-1, 1);
                }
                if (vMatrix == null)
                {
                    vMatrix = new Android.Graphics.Matrix();
                    vMatrix.Set(origMatrix);
                    vMatrix.PostTranslate(0, -Control.offBmp.Height);
                    vMatrix.PostScale(1, -1);
                }

                var ctime = System.Environment.TickCount;
                var realupdate = false;
                Fleux.UIElements.Canvas.drawtime = 0;
                /**/
                if (Control.offNeedExtraDraw && Control.offUpdated)
                lock(Control.offBmp){
                    Control.offNeedExtraDraw = false;
                    Control.offUpdated = false;

                    Control.offBmpDraw = true;
                    Control.Draw(new PaintEventArgs(Control.offGr, new Rectangle(0,0, Control.offBmp.Width, Control.offBmp.Height)));
                    Control.offBmpDraw = false;

                    updcnt++;
                    realupdate = true;
                }
                //*/
                lock(Control.offBmp)
                {
                    if (Fleux.Core.FleuxApplication.HorizontalMirror)
                    {
                        canvas.Matrix = hMatrix;
                    }else if (Fleux.Core.FleuxApplication.VerticalMirror)
                    {
                        canvas.Matrix = vMatrix;
                    }else
                        canvas.Matrix = origMatrix;

                    // Thats for FastGraphics.cs
                    Control.offGr.Flush();

                    canvas.DrawBitmap(Control.offBmp.ABitmap, 0,0, paint);
                    Control.offUpdated = false;
                    updcntflush++;
                }
                if (PerfData)
                {
                    ctime = System.Environment.TickCount - ctime;
                    //if (realupdate)
                    {
                        totime += ctime;
                    }
                    var cavg = totime / (updcnt+1);

                    var cpaint = new Android.Graphics.Paint();
                    cpaint.Color = new Android.Graphics.Color(0xA0, 0xFF, 0xFF, 0xFF);
                    cpaint.SetStyle(Android.Graphics.Paint.Style.Fill);
                    canvas.DrawRect(0,0, 250, 20, cpaint);
                    canvas.DrawText(""+updcnt+":"+updcntflush+":"+updcntinval+" ctime: "+ctime+"cavg:"+cavg+" canv: "+Fleux.UIElements.Canvas.drawtime, 0,20, spaint);
                    cpaint.Dispose();
                    if (updcnt > 100)
                    {
                        totime = 0;
                        updcnt = 0;
                    }
                }
            }
开发者ID:flts,项目名称:fleux,代码行数:83,代码来源:DoubleBufferedControl.cs

示例9: OnDraw

		protected override void OnDraw (Android.Graphics.Canvas canvas)
		{
			canvas.DrawBitmap (canvasBitmap, 0, 0, canvasPaint);
			canvas.DrawPath (drawPath, drawPaint);
		}
开发者ID:Ajhenk0955,项目名称:BlueNet,代码行数:5,代码来源:DrawTest.cs


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