I'm developing a 2D game. In order to make it easier I have created an item editor and sprite editor. Sprite editor loads all PNGs in the selected directory, packs it into a byte array and saves into a file. Item editor imports that file and displays both sprites and items on two lists. For now everything works fine because there is one sprite per item, so it's very easy to morph a byte array into bitmap and put it into PictureBox. But now I'm going to make larger items, with up to 9 sprites (center and 8 around).
Below is the simple code which loads only one sprite per item:
private void LItemss_SelectedIndexChanged(object sender, EventArgs e)
{
if(this.LItemss.SelectedIndices.Count <= 0)
return;
int intselectedindex = LItemss.SelectedIndices[0];
if(intselectedindex >= 0 && this.itemsSID.ContainsKey(intselectedindex))
{
GameItem item = this.itemsSID[intselectedindex];
this.currentImage = item.Image;
this.TName.Text = item.Name;
this.TServerID.Text = item.ServerID.ToString();
this.TClientID.Text = item.ClientID.ToString();
this.CBlocking.Checked = item.Blocking;
this.CGround.Checked = item.Ground;
this.CTop.Checked = item.Top;
if(item.Image != null && item.Image != "" && this.sprites.ContainsKey(item.Image))
{
MemoryStream memoryStream = new MemoryStream();
byte[] data = this.sprites[item.Image];
memoryStream.Write(data, 0, Convert.ToInt32(data.Length));
Bitmap bm = new Bitmap(memoryStream, false);
memoryStream.Dispose();
this.PSprite.Image = bm;
}
else
this.PSprite.Image = null;
}
}
Let's say for now byte[] data instead of mere byte array will be a 9 size array, from 0 to 8 of byte arrays, each one has different sprite around item. My question is how to join all these arrays of PNG into one single PictureBox?