public void Processed(object sender, ProcessedObjectEventArgs e) { if (e.Successful) { PixMap pixmap = e.Object as PixMap; if (pixmap != null) { pixmap.Compress(); } } }
private void Initialize() { _behaviours = new PedestriansFile()._pedestrians; List <string> loadedFiles = new List <string>(); foreach (PedestrianBehaviour behaviour in _behaviours) { if (!loadedFiles.Contains(behaviour.PixFile)) { PixFile pixFile = new PixFile(behaviour.PixFile); _pixMaps.AddRange(pixFile.PixMaps); loadedFiles.Add(behaviour.PixFile); } } foreach (PedestrianBehaviour behaviour in _behaviours) { foreach (PedestrianSequence seq in behaviour.Sequences) { var allFrames = new List <PedestrianFrame>(); allFrames.AddRange(seq.InitialFrames); allFrames.AddRange(seq.LoopingFrames); foreach (PedestrianFrame frame in allFrames) { PixMap pix = _pixMaps.Find(a => a.Name.Equals(frame.PixName, StringComparison.InvariantCultureIgnoreCase)); if (pix == null) { PixFile pixFile = new PixFile(frame.PixName); _pixMaps.AddRange(pixFile.PixMaps); pix = pixFile.PixMaps.Find(a => a.Name.Equals(frame.PixName, StringComparison.InvariantCultureIgnoreCase)); } if (pix != null) { frame.Texture = pix.Texture; } } } } CreateGeometry(); }
public void ResolveTexture(List <PixMap> pixmaps) { if (Texture != null) { return; //weve already resolved this material } if (!String.IsNullOrEmpty(PixName)) { PixMap pixmap = null; if (pixmaps != null) { pixmap = pixmaps.Find(p => p.Name.Equals(PixName, StringComparison.InvariantCultureIgnoreCase)); } else { PixFile pixfile = new PixFile(PixName); if (pixfile.Exists) { pixmap = pixfile.PixMaps[0]; } } if (pixmap != null) { Texture = pixmap.Texture; } } if (Texture == null) { //simp mat if (SimpMatGradientCount > 1) { GenerateSimpMatGradient(); } else { Texture = TextureGenerator.Generate(GameVars.Palette.GetRGBColorForPixel(SimpMatPixelIndex)); } } }
public void TestDependencyInjectionOnPixMap() { Stopwatch sw = new Stopwatch(); for (int i = 0; i < 1001; i++) { if (i == 1) sw.Start(); PixMap m = new PixMap(PixelFormat.RGBA, 100, 100); IGraphics g = m.CreateGraphics(); Debug.Assert(g != null); g.BeginGraphicsContext(); g.EndGraphicsContext(); g.AlphaMask = null; } sw.Stop(); Debug.WriteLine(string.Format("{0}ms to create 1000 PixMaps", sw.ElapsedMilliseconds)); }
public void TestDependencyInjectionOnPixMap() { Stopwatch sw = new Stopwatch(); for (int i = 0; i < 1001; i++) { if (i == 1) { sw.Start(); } PixMap m = new PixMap(PixelFormat.RGBA, 100, 100); IGraphics g = m.CreateGraphics(); Debug.Assert(g != null); g.BeginGraphicsContext(); g.EndGraphicsContext(); g.AlphaMask = null; } sw.Stop(); Debug.WriteLine(string.Format("{0}ms to create 1000 PixMaps", sw.ElapsedMilliseconds)); }