Skip to content

Grid of images with source rectangle? #2062

Answered by cwensley
Shadowblitz16 asked this question in Q&A
Discussion options

You must be logged in to vote

Not sure what you mean by "with a source rectangle", but there's a few ways:

  1. Use TableLayout:
var table = new TableLayout();
for (int y = 0; y < 16; y++)
{
  var row = new TableRow();
  for (int x = 0; x < 16; x++)
  {
    var image = new ImageView { Image = GetImage(x, y) };
    row.Cells.Add(image);
  }
  table.Rows.Add(row);
}
  1. Use a Drawable and paint them:
var drawable = new Drawable { Size = /*.. some size needed to show all images */ };
drawable.Paint += (sender, e) => {
  for (int y = 0; y < 16; y++)
  for (int x = 0; x < 16; x++)
  {
    e.Graphics.DrawImage(...);
  }
};

Hope this helps!

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Shadowblitz16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants