.sph,.spaフォーマット判別クラス作成
@@ -0,0 +1,52 @@ | ||
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Text; | |
5 | +using System.Drawing; | |
6 | +using System.Drawing.Imaging; | |
7 | + | |
8 | +namespace MikuMikuDance.XNA | |
9 | +{ | |
10 | + static class ImageExtAnalyzer | |
11 | + { | |
12 | + public static void Analyze(Image img, out string Extention) | |
13 | + { | |
14 | + ImageFormat format = img.RawFormat; | |
15 | + if (format.Guid == ImageFormat.Bmp.Guid) | |
16 | + Extention = ".bmp"; | |
17 | + else if (format.Guid == ImageFormat.Emf.Guid) | |
18 | + { | |
19 | + Extention = ".png";//エンコーダがないのでpngで | |
20 | + format = ImageFormat.Png; | |
21 | + } | |
22 | + else if (format.Guid == ImageFormat.Exif.Guid) | |
23 | + Extention = ".jpg";//Exifはjpeg扱い | |
24 | + else if (format.Guid == ImageFormat.Gif.Guid) | |
25 | + Extention = ".gif"; | |
26 | + else if (format.Guid == ImageFormat.Icon.Guid) | |
27 | + { | |
28 | + Extention = ".png";//エンコーダがないのでpngで | |
29 | + format = ImageFormat.Png; | |
30 | + } | |
31 | + else if (format.Guid == ImageFormat.Jpeg.Guid) | |
32 | + Extention = ".jpg"; | |
33 | + else if (format.Guid == ImageFormat.MemoryBmp.Guid) | |
34 | + { | |
35 | + Extention = ".bmp"; | |
36 | + format = ImageFormat.Bmp; | |
37 | + } | |
38 | + else if (format.Guid == ImageFormat.Png.Guid) | |
39 | + Extention = ".png"; | |
40 | + else if (format.Guid == ImageFormat.Tiff.Guid) | |
41 | + Extention = ".tif"; | |
42 | + else if (format.Guid == ImageFormat.Wmf.Guid) | |
43 | + { | |
44 | + Extention = ".png";//エンコーダがないのでpngで | |
45 | + format = ImageFormat.Png; | |
46 | + } | |
47 | + else | |
48 | + throw new NotImplementedException("未実装のスフィアマップファイルフォーマット"); | |
49 | + | |
50 | + } | |
51 | + } | |
52 | +} |