Esempio n. 1
0
        public IImage EndOffscreen()
        {
            var dimg = _offscreen;

            drawcontext ctx = _prev.Pop();

            _offscreen = ctx.img;
            _c         = ctx.c;

            return(dimg);
        }
Esempio n. 2
0
        public IImage ImageFromFile(string path)
        {
            var bmp = BitmapFactory.DecodeFile(path);

            if (bmp == null)
            {
                return(null);
            }

            var dimg = new AndroidImage()
            {
                Bitmap = bmp
            };

            return(dimg);
        }
Esempio n. 3
0
        public void BeginOffscreen(float width, float height, IImage img)
        {
            if (_prev == null)
            {
                _prev = new Stack <drawcontext> ();
            }

            _prev.Push(new drawcontext {
                c = _c, img = _offscreen
            });

            _offscreen = null;
            if (img != null)
            {
                var aimg = img as AndroidImage;
                if (
                    (aimg.Bitmap.Width >= width) &&
                    (aimg.Bitmap.Height >= height))
                {
                    _offscreen = img as AndroidImage;
                }
                else
                {
                    img.Destroy();
                }
            }

            if (null == _offscreen)
            {
                _offscreen        = new AndroidImage();
                _offscreen.Bitmap = Bitmap.CreateBitmap((int)width, (int)height, Bitmap.Config.Rgb565);                  // TODO what bitmap config?
            }

            _c = new Canvas();
            _c.SetBitmap(_offscreen.Bitmap);
                        #if false
            if (img != null)
            {
                SetColor(Xamarin.Forms.Color.Yellow);
                FillRect(0, 0, _offscreen.Bitmap.Width, _offscreen.Bitmap.Height);
            }
                        #endif
        }
        public IImage ImageFromFile(string path)
        {
            var bmp = BitmapFactory.DecodeFile (path);
            if (bmp == null) return null;

            var dimg = new AndroidImage () {
                Bitmap = bmp
            };
            return dimg;
        }