public static Bitmap GetImage(int width, int height) { sizeBlocks = width / 7; int amountImages = 56; List <Bitmap> bitmaps = DrawImages.CreateBitmapBlocks(amountImages, false); Paint p = new Paint(); p.StrokeWidth = 0.5f; p.SetStyle(Paint.Style.Fill); p.Color = Color.White; Bitmap b = Bitmap.CreateBitmap(width, height, Bitmap.Config.Argb8888); Canvas c = new Canvas(b); //Make background White c.DrawRect(new Rect(0, 0, width, height), p); //Draw Blocks for (int i = 0; i < amountImages; i++) { c.DrawBitmap(bitmaps[i], (i % 7) * (width / 7), (i % 8) * (height / 8), p); } p.Dispose(); c.Dispose(); return(b); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); Utils.Util.SetDisplayMetrics(Resources.DisplayMetrics); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button> (Resource.Id.btn_draw); ImageView iv = FindViewById <ImageView> (Resource.Id.imageView_output); button.Click += delegate { int width = Utils.Util.DetectScreenSize().Width; int height = Utils.Util.DetectScreenSize().Height; if (b != null) { iv.SetImageBitmap(null); } b = DrawImages.GetImage(width, height); iv.SetImageBitmap(b); b.Dispose(); }; }