private void SaveGlyphsToDisk(string folder) { Array groups = Enum.GetValues(typeof(StandardGlyphGroup)); Array items = Enum.GetValues(typeof(StandardGlyphItem)); foreach (var groupName in groups) { int count = 0; string glyphFolder = Path.Combine(folder, groupName.ToString()); var sprite = new WriteableBitmap(16, 16 * (items.Length), 96, 96, PixelFormats.Pbgra32, null); sprite.Lock(); foreach (var itemName in items) { StandardGlyphGroup group = (StandardGlyphGroup)groupName; StandardGlyphItem item = (StandardGlyphItem)itemName; BitmapSource glyph = _glyphService.GetGlyph(group, item) as BitmapSource; if (glyph == null) { continue; } string fileName = Path.Combine(folder, group.ToString(), item.ToString() + ".png"); SaveBitmapToDisk(glyph, fileName); int stride = glyph.PixelWidth * (glyph.Format.BitsPerPixel / 8); byte[] data = new byte[stride * glyph.PixelHeight]; glyph.CopyPixels(data, stride, 0); sprite.WritePixels( new Int32Rect(0, count, glyph.PixelWidth, glyph.PixelHeight), data, stride, 0); count += 16; } sprite.Unlock(); SaveBitmapToDisk(sprite, Path.Combine(folder, "_sprites", groupName + ".png")); } }
/// <summary> /// Provides a description of the specific icon. /// </summary> /// <returns>Group.Item</returns> public override string ToString() { return(string.Format(CultureInfo.InvariantCulture, "{0}.{1}", group.ToString(), item.ToString())); }