/[gr2lib]/trunk/gr2lib_UnitTest/Program.cs
ViewVC logotype

Contents of /trunk/gr2lib_UnitTest/Program.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 72 - (show annotations) (download)
Thu Jul 15 14:22:00 2010 UTC (9 years, 6 months ago) by william
File size: 6324 byte(s)
add: reading of textures

1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 using gr2lib.core;
6 //using gr2lib.core.coretypes;
7 using gr2lib.core.apiversion;
8 using gr2lib.core.exceptions;
9 using gr2lib.core.helpers;
10 using gr2lib.core.coretypes.implementation;
11
12 namespace gr2lib_UnitTest
13 {
14
15 class Program
16 {
17 static void Main(string[] args)
18 {
19 string GrannyFilename = shared.GRANNY_TEST_FILE;
20 try
21 {
22 #region Check Granny2 API Version
23 // Setup access to check loaded Granny2 API Version
24 granny2apiversion apiversion = new granny2apiversion(shared.EXPECTED_API_VERSION);
25
26 // Check if the Loaded API Version Matches
27 if (!apiversion.apiversionsmatch)
28 {
29 // the loaded version does not match
30 Console.WriteLine("Warning:\n" +
31 "\t Loaded Granny2 DLL Version: " + apiversion.apiversion.version + "\n" +
32 "\t Expected Version: " + apiversion.expectedapiversion.version);
33 // return from void to exit application
34 return;
35 }
36 else
37 {
38 // the loaded version matches
39 Console.WriteLine("Loaded granny2.dll: " + apiversion.apiversion.version);
40 }
41 #endregion
42
43 #region Parse Commandline
44 if (args.Length == 1)
45 {
46 GrannyFilename = args[0];
47 }
48 else if (args.Length > 1)
49 {
50 throw new InvalidOperationException("ERROR: Recieved Invalid Commandline: " + new arraytostring<string,string[]>(args));
51 }
52
53 if (System.IO.File.Exists(GrannyFilename))
54 {
55 Console.WriteLine("Using Granny2 File: " + GrannyFilename);
56 }
57 else
58 {
59 throw new System.IO.FileNotFoundException("Unable to find: " + GrannyFilename);
60 }
61 #endregion
62
63 #region test
64 unsafe
65 {
66
67
68 grnfileinfo info = grnfileinfo.ReadFromFile(GrannyFilename);
69
70 #region Read FromFileName
71 Console.WriteLine();
72 Console.WriteLine("From File Name: ");
73 Console.WriteLine("\t" + info.FromFileName);
74 #endregion
75
76 #region Read ArtToolInfo
77 Console.WriteLine();
78 Console.WriteLine("Art Tool Data:");
79 Console.WriteLine("\tTool Name: " + info.ArtToolInfo.FromArtToolName);
80 Console.WriteLine("\tTool Version: " + string.Format("{0}.{1}", info.ArtToolInfo.ArtToolMajorRevision, info.ArtToolInfo.ArtToolMinorRevision));
81 Console.WriteLine("\tTool Units Per Meter: " + info.ArtToolInfo.UnitsPerMeter);
82
83 Console.WriteLine("\tTool Origin: " + string.Format("[{0},{1},{2}]", info.ArtToolInfo.Origin.X, info.ArtToolInfo.Origin.Y, info.ArtToolInfo.Origin.Z));
84 Console.WriteLine("\tTool Right: " + string.Format("[{0},{1},{2}]", info.ArtToolInfo.Right.X, info.ArtToolInfo.Right.Y, info.ArtToolInfo.Right.Z));
85 Console.WriteLine("\tTool Up: " + string.Format("[{0},{1},{2}]", info.ArtToolInfo.Up.X, info.ArtToolInfo.Up.Y, info.ArtToolInfo.Up.Z));
86 Console.WriteLine("\tTool Back: " + string.Format("[{0},{1},{2}]", info.ArtToolInfo.Back.X, info.ArtToolInfo.Back.Y, info.ArtToolInfo.Back.Z));
87
88 Console.WriteLine("\tTool ExtendedData: " + info.ArtToolInfo.ExtendedData);
89 #endregion
90
91 #region Read ExporterInfo
92 Console.WriteLine();
93 Console.WriteLine("Exporter Info:");
94 Console.WriteLine("\tExporter Name: " + info.ExporterInfo.ExporterName);
95
96 Console.WriteLine("\tExporter Version: " +
97 string.Format("{0}.{1}.{2}.{3}",
98 info.ExporterInfo.ExporterMajorRevision,
99 info.ExporterInfo.ExporterMinorRevision,
100 info.ExporterInfo.ExporterCustomization,
101 info.ExporterInfo.ExporterBuildNumber));
102
103 Console.WriteLine("\tExporter ExtendedData: " + info.ExporterInfo.ExtendedData);
104 #endregion
105
106 #region Read Textures
107 Console.WriteLine();
108 Console.WriteLine("Texture List:");
109 foreach (Texture t in info.Textures)
110 {
111 Console.WriteLine("\tName: " + t.FromFileName);
112 Console.WriteLine("\tType: " + t.TextureType);
113 Console.WriteLine("\tWidth: " + t.Width);
114 Console.WriteLine("\tHeight: " + t.Height);
115 Console.WriteLine("\tEncoding: " + t.Encoding);
116 Console.WriteLine("\tSubFormat: " + t.SubFormat);
117 // layout
118 Console.WriteLine("\tBytes Per Pixel: " + t.Layout.BytesPerPixel);
119 Console.WriteLine("\tShiftForComponent: " + new arraytostring<int, int[]>(t.Layout.ShiftForComponent));
120 Console.WriteLine("\tBitsForComponent: " + new arraytostring<int, int[]>(t.Layout.BitsForComponent));
121 // images
122 Console.WriteLine("\tExtendedData: " + t.ExtendedData);
123 Console.WriteLine();
124 }
125 #endregion
126
127 }
128 #endregion
129
130 }
131 catch (granny2apiloadexception ex)
132 {
133 Console.WriteLine(ex.Message);
134 }
135 catch (Exception ex)
136 {
137 Console.WriteLine(ex.Message);
138 }
139 }
140 }
141 }
142

  ViewVC Help
Powered by ViewVC 1.1.22