protected Color[] GetImageData(Color[] colorData, int totWidth, MultiTexture4x3 multiTexture) { Rectangle rectangle; switch (multiTexture) { default: case MultiTexture4x3.Keep0x0: rectangle = new Rectangle(0, 0, _width, _height); break; case MultiTexture4x3.Keep1x0: rectangle = new Rectangle(_width, 0, _width, _height); break; case MultiTexture4x3.Keep2x0: rectangle = new Rectangle(_width * 2, 0, _width, _height); break; case MultiTexture4x3.Keep3x0: rectangle = new Rectangle(_width * 3, 0, _width, _height); break; case MultiTexture4x3.Keep0x1: rectangle = new Rectangle(0, _height, _width, _height); break; case MultiTexture4x3.Keep1x1: rectangle = new Rectangle(_width, _height, _width, _height); break; case MultiTexture4x3.Keep2x1: rectangle = new Rectangle(_width * 2, _height, _width, _height); break; case MultiTexture4x3.Keep3x1: rectangle = new Rectangle(_width * 3, _height, _width, _height); break; case MultiTexture4x3.Keep0x2: rectangle = new Rectangle(0, _height * 2, _width, _height); break; case MultiTexture4x3.Keep1x2: rectangle = new Rectangle(_width, _height * 2, _width, _height); break; case MultiTexture4x3.Keep2x2: rectangle = new Rectangle(_width * 2, _height * 2, _width, _height); break; case MultiTexture4x3.Keep3x2: rectangle = new Rectangle(_width * 3, _height * 2, _width, _height); break; } Color[] color = new Color[rectangle.Width * rectangle.Height]; for (int x = 0; x < rectangle.Width; x++) { for (int y = 0; y < rectangle.Height; y++) { color[x + y * rectangle.Width] = colorData[x + rectangle.X + (y + rectangle.Y) * totWidth]; } } return(color); }
public ArrayTexture(Color[] textureArray, int totWidth, int totHeight, MultiTexture4x3 multiTexture) { _width = totWidth / 4; _height = totHeight / 3; _textureArray = GetImageData(textureArray, totWidth, multiTexture); }