/// <summary> /// Create tile /// </summary> internal MapTile(byte[] data) { if (data.Length != 256 * 4) { throw new InvalidDataException("Wrong length of tile data array, must be 1024 bytes."); } averageColor = Color.Black; texture = WWTexture.FromRawData(16, 16, data); int avgR = 0; int avgG = 0; int avgB = 0; // Calc average color for (int i = 0; i < 256; i += 4) { avgR += data[i + 0]; avgG += data[i + 1]; avgB += data[i + 2]; } averageColor.R = (byte)(avgR / 64); averageColor.G = (byte)(avgG / 64); averageColor.B = (byte)(avgB / 64); averageColor.A = 255; } // Tile(data)
private SpriteFrameData(SpriteResource resource) { MaxWidth = resource.MaxWidth; MaxHeight = resource.MaxHeight; Frames = new SpriteFrame[resource.FrameCount]; for (int i = 0; i < resource.FrameCount; i++) { Performance.Push("SetData"); WWTexture tex = WWTexture.FromRawData(resource.MaxWidth, resource.MaxHeight, resource.Frames[i].image_data); Performance.Pop(); Frames[i] = new SpriteFrame(); Frames[i].OffsetX = resource.Frames [i].disp_x; Frames[i].OffsetY = resource.Frames [i].disp_y; Frames[i].Width = resource.Frames [i].width; Frames[i].Height = resource.Frames [i].height; Performance.Push("FromDXTexture"); Frames[i].texture = tex; Performance.Pop(); } }
internal void Init() { minimapTex = WWTexture.FromRawData(Width, Height, null); }