Beispiel #1
0
        public Bitmap GetPin(float ratio, int number, int width, int height, float alpha = 1)
        {
            int    key = number + ((int)(ratio * 10000)) << 6;
            Bitmap bmp;

            if (pinCache.TryGetValue(key, out bmp))
            {
                return(bmp);
            }

            var svg = SVGParser.ParseSVGFromResource(context.Resources,
                                                     Resource.Raw.pin,
                                                     SvgColorMapperFactory.FromFunc(c => ColorReplacer(c, ratio, alpha)));

            bmp = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888);
            using (var c = new Canvas(bmp)) {
                var dst = new RectF(0, 0, width, height);
                c.DrawPicture(svg.Picture, dst);
                c.DrawText(number.ToString(), width / 2 - 1, 16.ToPixels (), textPaint);
            }

            pinCache [key] = bmp;
            return(bmp);
        }