Hello I am developing a plugin which converts the tilesets from RPG maker format to a common format. I split the tile into minitiles and reassemble them according to a certain criteria, this is the code:
// Name:
// Submenu:
// Author:
// Title:
// Version:
// Desc:
// Keywords:
// URL:
// Help:
#region UICode
bool Amount1 = false; // [0,1] Use Secondary Color
#endregion
void Render(Surface dst, Surface src, Rectangle rect)
{
int[] values = new int[] { 1, 2, 1, 10, 10, 11, 11, 12, 14, 4, 10, 11, 10, 11, 3, 15, 1, 11, 3, 4, 10, 11, 10, 12,
13, 16, 13, 8, 7, 8, 7, 16, 7, 8, 7, 19, 18, 8, 7, 8, 17, 19, 18, 19, 18, 19, 18, 20,
13, 16, 13, 4, 3, 4, 3, 16, 13, 4, 3, 15, 14, 4, 3, 16, 13, 15, 3, 15, 14, 15, 14, 4,
17, 20, 17, 8, 7, 8, 7, 20, 17, 15, 18, 19, 18, 19, 18, 20, 17, 19, 18, 8, 18, 19, 18, 8,
17, 20, 17, 4, 3, 4, 3, 20, 13, 19, 14, 15, 14, 15, 14, 16, 3, 15, 14, 15, 14, 4, 14, 16,
5, 6, 21, 22, 22, 23, 23, 24, 17, 8, 7, 19, 18, 8, 7, 20, 7, 19, 18, 19, 7, 19, 18, 20,
1, 2, 1, 10, 10, 11, 11, 2, 3, 4, 3, 15, 14, 4, 3, 4, 13, 15, 14, 15, 14, 15, 14, 16,
5, 6, 5, 22, 22, 23, 23, 6, 18, 8, 22, 23, 22, 23, 7, 19, 21, 23, 22, 23, 7, 8, 22, 24};
ColorBgra[, ,] pixels = new ColorBgra[24,16,16];
for (int y = 0; y < 192 ; y++)
{
for (int x = 0; x < 128; x++)
{
int indx = x/16;
int indy = y/16;
pixels[indy*4 + indx,x%16,y%16] = src[x,y];
}
}
for (int y = rect.Top; y < rect.Bottom; y++)
{
if (IsCancelRequested) return;
for (int x = rect.Left; x < rect.Right; x++)
{
int indx = x/16;
int indy = y/16;
int val = values[indy*24 + indx] - 1;
dst[x,y] = pixels[val,y%16,x%16];
}
}
}
but I get an error "out of matrix limits" .. can anybody help me?