added shortcuts to standard formats as static properties of ImageFormat and AudioFormat.

namely,
ImageFormat.Jpeg
ImageFormat.Png
ImageFormat.Bmp
AudioFormat.Wav
This commit is contained in:
morkt
2015-08-14 06:05:15 +04:00
parent 7fb26371e3
commit a9ffd7cccc
3 changed files with 21 additions and 2 deletions

View File

@@ -178,5 +178,18 @@ namespace GameRes
{
get { return this.GetType().Assembly == typeof(ImageFormat).Assembly; }
}
public static ImageFormat FindByTag (string tag)
{
return FormatCatalog.Instance.ImageFormats.FirstOrDefault (x => x.Tag == tag);
}
static readonly Lazy<ImageFormat> s_JpegFormat = new Lazy<ImageFormat> (() => FindByTag ("JPEG"));
static readonly Lazy<ImageFormat> s_PngFormat = new Lazy<ImageFormat> (() => FindByTag ("PNG"));
static readonly Lazy<ImageFormat> s_BmpFormat = new Lazy<ImageFormat> (() => FindByTag ("BMP"));
public static ImageFormat Jpeg { get { return s_JpegFormat.Value; } }
public static ImageFormat Png { get { return s_PngFormat.Value; } }
public static ImageFormat Bmp { get { return s_BmpFormat.Value; } }
}
}