best303 Posted November 12, 2019 Share Posted November 12, 2019 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? Quote Link to comment Share on other sites More sharing options...
toe_head2001 Posted November 12, 2019 Share Posted November 12, 2019 4 hours ago, best303 said: ColorBgra[, ,] pixels = new ColorBgra[24, 16, 16]; pixels[indy*4 + indx, x%16, y%16] = src[x,y]; The computed value of indy*4 + indx must always be less than 24 (that's the length you chose), but sometimes it's not. 1 Quote (September 25th, 2023) Sorry about any broken images in my posts. I am aware of the issue. My Gallery | My Plugin Pack Layman's Guide to CodeLab Link to comment Share on other sites More sharing options...
best303 Posted November 13, 2019 Author Share Posted November 13, 2019 thank you for your quick answer I've had some wrong calculations Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.