├── .gitignore
├── LICENSE
├── README.md
└── src
└── GameImageUtil
├── GameImageUtil.sln
└── GameImageUtil
├── App.config
├── App.xaml
├── App.xaml.cs
├── FileProcessorConfig.cs
├── FodyWeavers.xml
├── FodyWeavers.xsd
├── GameImageUtil.csproj
├── IFileProcessor.cs
├── Icon.ico
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Notifiable.cs
├── ProgressWindow.xaml
├── ProgressWindow.xaml.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── Settings.cs
├── ViewModels
├── AppViewModel.cs
└── ProgressViewModel.cs
├── data
├── IMPORTANT.txt
├── lib
│ ├── PhilLibX.Interop.dll
│ └── PhilLibX.dll
└── scripts
│ ├── AutomaticProcessor.cs_script
│ ├── BC5XYNormalMapProcessor.cs_script
│ ├── CastProcessor.cs_script
│ ├── CoDFusedCSProcessor.cs_script
│ ├── CoDMW2RBlueImageProcessor.cs_script
│ ├── CoDNOGImageProcessor.cs_script
│ ├── CoDSpecGlossProcessor.cs_script
│ ├── CoDSplitCSProcessor.cs_script
│ ├── CoDWW2GreenImageProcessor.cs_script
│ ├── CoDXYNormalMapProcessor.cs_script
│ ├── DirectConvertProcessor.cs_script
│ ├── MergeRGBAProcessor.cs_script
│ ├── SplitColorAlphaProcessor.cs_script
│ └── SplitRGBAProcessor.cs_script
└── packages.config
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Ignore Libraries and tests
28 | Misc
29 | PhilLibX
30 | Tyrant.Testing
31 | Tyrant.UITests
32 | Tyrant.AssetNameFinder
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUNIT
47 | *.VisualState.xml
48 | TestResult.xml
49 |
50 | # Build Results of an ATL Project
51 | [Dd]ebugPS/
52 | [Rr]eleasePS/
53 | dlldata.c
54 |
55 | # Benchmark Results
56 | BenchmarkDotNet.Artifacts/
57 |
58 | # .NET Core
59 | project.lock.json
60 | project.fragment.lock.json
61 | artifacts/
62 | **/Properties/launchSettings.json
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_i.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *.log
88 | *.vspscc
89 | *.vssscc
90 | .builds
91 | *.pidb
92 | *.svclog
93 | *.scc
94 |
95 | # Chutzpah Test files
96 | _Chutzpah*
97 |
98 | # Visual C++ cache files
99 | ipch/
100 | *.aps
101 | *.ncb
102 | *.opendb
103 | *.opensdf
104 | *.sdf
105 | *.cachefile
106 | *.VC.db
107 | *.VC.VC.opendb
108 |
109 | # Visual Studio profiler
110 | *.psess
111 | *.vsp
112 | *.vspx
113 | *.sap
114 |
115 | # Visual Studio Trace Files
116 | *.e2e
117 |
118 | # TFS 2012 Local Workspace
119 | $tf/
120 |
121 | # Guidance Automation Toolkit
122 | *.gpState
123 |
124 | # ReSharper is a .NET coding add-in
125 | _ReSharper*/
126 | *.[Rr]e[Ss]harper
127 | *.DotSettings.user
128 |
129 | # JustCode is a .NET coding add-in
130 | .JustCode
131 |
132 | # TeamCity is a build add-in
133 | _TeamCity*
134 |
135 | # DotCover is a Code Coverage Tool
136 | *.dotCover
137 |
138 | # AxoCover is a Code Coverage Tool
139 | .axoCover/*
140 | !.axoCover/settings.json
141 |
142 | # Visual Studio code coverage results
143 | *.coverage
144 | *.coveragexml
145 |
146 | # NCrunch
147 | _NCrunch_*
148 | .*crunch*.local.xml
149 | nCrunchTemp_*
150 |
151 | # MightyMoose
152 | *.mm.*
153 | AutoTest.Net/
154 |
155 | # Web workbench (sass)
156 | .sass-cache/
157 |
158 | # Installshield output folder
159 | [Ee]xpress/
160 |
161 | # DocProject is a documentation generator add-in
162 | DocProject/buildhelp/
163 | DocProject/Help/*.HxT
164 | DocProject/Help/*.HxC
165 | DocProject/Help/*.hhc
166 | DocProject/Help/*.hhk
167 | DocProject/Help/*.hhp
168 | DocProject/Help/Html2
169 | DocProject/Help/html
170 |
171 | # Click-Once directory
172 | publish/
173 |
174 | # Publish Web Output
175 | *.[Pp]ublish.xml
176 | *.azurePubxml
177 | # Note: Comment the next line if you want to checkin your web deploy settings,
178 | # but database connection strings (with potential passwords) will be unencrypted
179 | *.pubxml
180 | *.publishproj
181 |
182 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
183 | # checkin your Azure Web App publish settings, but sensitive information contained
184 | # in these scripts will be unencrypted
185 | PublishScripts/
186 |
187 | # NuGet Packages
188 | *.nupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 |
214 | # Visual Studio cache files
215 | # files ending in .cache can be ignored
216 | *.[Cc]ache
217 | # but keep track of directories ending in .cache
218 | !*.[Cc]ache/
219 |
220 | # Others
221 | ClientBin/
222 | ~$*
223 | *~
224 | *.dbmdl
225 | *.dbproj.schemaview
226 | *.jfm
227 | *.pfx
228 | *.publishsettings
229 | orleans.codegen.cs
230 |
231 | # Including strong name files can present a security risk
232 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
233 | #*.snk
234 |
235 | # Since there are multiple workflows, uncomment next line to ignore bower_components
236 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
237 | #bower_components/
238 |
239 | # RIA/Silverlight projects
240 | Generated_Code/
241 |
242 | # Backup & report files from converting an old project file
243 | # to a newer Visual Studio version. Backup files are not needed,
244 | # because we have git ;-)
245 | _UpgradeReport_Files/
246 | Backup*/
247 | UpgradeLog*.XML
248 | UpgradeLog*.htm
249 | ServiceFabricBackup/
250 | *.rptproj.bak
251 |
252 | # SQL Server files
253 | *.mdf
254 | *.ldf
255 | *.ndf
256 |
257 | # Business Intelligence projects
258 | *.rdl.data
259 | *.bim.layout
260 | *.bim_*.settings
261 | *.rptproj.rsuser
262 |
263 | # Microsoft Fakes
264 | FakesAssemblies/
265 |
266 | # GhostDoc plugin setting file
267 | *.GhostDoc.xml
268 |
269 | # Node.js Tools for Visual Studio
270 | .ntvs_analysis.dat
271 | node_modules/
272 |
273 | # Visual Studio 6 build log
274 | *.plg
275 |
276 | # Visual Studio 6 workspace options file
277 | *.opt
278 |
279 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
280 | *.vbw
281 |
282 | # Visual Studio LightSwitch build output
283 | **/*.HTMLClient/GeneratedArtifacts
284 | **/*.DesktopClient/GeneratedArtifacts
285 | **/*.DesktopClient/ModelManifest.xml
286 | **/*.Server/GeneratedArtifacts
287 | **/*.Server/ModelManifest.xml
288 | _Pvt_Extensions
289 |
290 | # Paket dependency manager
291 | .paket/paket.exe
292 | paket-files/
293 |
294 | # FAKE - F# Make
295 | .fake/
296 |
297 | # JetBrains Rider
298 | .idea/
299 | *.sln.iml
300 |
301 | # CodeRush
302 | .cr/
303 |
304 | # Python Tools for Visual Studio (PTVS)
305 | __pycache__/
306 | *.pyc
307 |
308 | # Cake - Uncomment if you are using it
309 | # tools/**
310 | # !tools/packages.config
311 |
312 | # Tabs Studio
313 | *.tss
314 |
315 | # Telerik's JustMock configuration file
316 | *.jmconfig
317 |
318 | # BizTalk build output
319 | *.btp.cs
320 | *.btm.cs
321 | *.odx.cs
322 | *.xsd.cs
323 |
324 | # OpenCover UI analysis results
325 | OpenCover/
326 |
327 | # Azure Stream Analytics local run output
328 | ASALocalRun/
329 |
330 | # MSBuild Binary and Structured Log
331 | *.binlog
332 |
333 | # NVidia Nsight GPU debugger configuration file
334 | *.nvuser
335 |
336 | # MFractors (Xamarin productivity tool) working folder
337 | .mfractor/
338 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GameImageUtil
2 | [](https://github.com/Scobalula/GameImageUtil/releases) [](https://github.com/Scobalula/GameImageUtil/blob/master/LICENSE) [](https://discord.gg/RyqyThu)
3 |
4 | GameImageUtil is a tool to work with and process various images from various games for use within rendering, modding, ugc, etc. As with most games, developers pack images, perform conversions, etc. and this will help with unpacking them. This tool is released especially for RaGe and ZeRoY because of how much I love them.
5 |
6 | ## Requirements
7 |
8 | * Windows 10 x64 or above (Windows 7/8/8.1 should work, but are untested)
9 | * Microsoft Visual Studio 2019 Runtime and .NET Framework 4.7.2
10 |
11 | ## Links:
12 | * Discord Server: [https://discord.gg/fGVpV39](https://discord.gg/RyqyThu)
13 | * Github Repo: [https://github.com/Scobalula/GameImageUtil](https://github.com/Scobalula/GameImageUtil)
14 | * Latest Release: [https://github.com/Scobalula/GameImageUtil/releases](https://github.com/Scobalula/GameImageUtil/releases)
15 |
16 | ## Using GameImageUtil
17 |
18 | To use GameImageUtil, download the latest version from the [Releases](https://github.com/Scobalula/GameImageUtil/releases) page and run the exe. From here it is pretty easy, just select a mode and output format, and drag and drop images.
19 |
20 | ## Modes
21 |
22 | GameImageUtil comes with multiple built-in "modes" for processing different images:
23 |
24 | **Drag and Dropping Images**
25 |
26 | * **Automatic**: this mode attempts to resolve the mode based off the input image name. Currently this is only tested on Call of Duty: Modern Warfare 2019 and Call of Duty: Infinite Warfare and Cast, but will support others soon including txt files generated by various tools of mine such as Tyrant.
27 | * **Cast Files**: This mode will accept Cast files from DTZxPorter's Legion and simply rename the hashed images to match the behaviour of his Maya plug-in (naming each image by their material + slot)
28 | * **CoD Greyscale XY Normal Map w/ Alpha (MW/WaW/MW2/MW3/BO1)**: this will compute the Z (B channel) of a DXT5 normal map with only XY components and move the channels. These are also known as "Grey Normal Maps" due their color.
29 | * **CoD S/G/O (Blue Image) (Modern Warfare 2 Remastered)**: This will split the blue image from some Modern Warfare 2 Remastered images that contain a specular color map, gloss map, and occlusion map.
30 | * **CoD Normal/Gloss/Occlusion (Infinite Warfare/Modern Warfare)**: This will split the NOG/NG image from Infinite Warfare/Modern Warfare that contain a normal map, gloss map, and occlusion map. It will also perform a proper conversion of the Hemi-Octahedron normal map to a standard tangent space normal map.
31 | * **CoD Spec/Gloss (RGB/A) (Multiple CoDs)**: This will split the specular color map and gloss map from multiple CoD Games.
32 | * **CoD Specular/Albedo (Infinite Warfare/Modern Warfare)**: This will split the fused specular color map and albedo map from Infinite Warfare/Modern Warfare, using the alpha channel as the mask.
33 | * **CoD Specular/Albedo (World War II)**: This will split the fused specular color map and albedo map from World War II, using an image with the same name as the input image with _s at the end as the mask. For example: `colormap_and_specimage.png` the tool would expect `colormap_and_specimage_s.png` in the same folder.
34 | * **XY Normal Map (BC5 Grey/Yellow w/ No Alpha) (Modern Games/Global)**: this will compute the Z (B channel) of a BC5 normal map with only XY components, also known as "Yellow Normal Maps" due their color. Note this is also used for Call of Duty: World War 2, MWR, etc., even though they are grey, they are XY normal maps.
35 | * **CoD WW2 S/G/O (Green Image) (World War II)**: This splits World War II's green image that contains specular mask, occlusion, and gloss maps.
36 | * **Direct Convert (Global)**: Simply converts the image to the provided format.
37 | * **Split Color/Alpha (Global)**: Splits Color and Alpha into their own images.
38 | * **Split All Channels (Global)**: Splits all channels into their own images.
39 | * **Merge RGB/Alpha (Global)**: Merges an RGB Image with another Image to be the Alpha Mask. It uses an image with the same name as the given image + _a. For example: `colormap.png` the tool would expect `colormap__a.png` in the same folder.
40 |
41 | You're free to write your own scripts, etc. but no support or documentation is provided for such. Just look at the provided scripts to get an idea of how it works.
42 |
43 | You can modify the number of threads that GameImageUtil uses, by default it's set to your CPU's "Processor Count" (which includes cores + threads), note that both memory and cpu usuage will increase with higher thread counts.
44 |
45 | ## License/Disclaimer
46 |
47 | GameImageUtil is licensed under the General Public License 3.0, you are free to use it under the terms of the GPL, including editing it, etc. to extend it. GameImageUtil is distributed in the hope it will be useful to, but it comes WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, see the [LICENSE](https://github.com/Scobalula/GameImageUtil/blob/master/LICENSE) file for more information.
48 |
49 | To build GameImageUtil you can simply load the project and compile, libraries are precompiled and including in the source, it is recommended to use VS 2019 with .NET Framework 4.7.2 as it is what is used for the release builds.
50 |
51 | ## Reporting Bugs
52 |
53 | Bugs can be reported through the Github issues or through the Discord server.
54 |
55 | ## Credits
56 |
57 | * **raptroes**: the sexy icon you all know you love
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29926.136
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GameImageUtil", "GameImageUtil\GameImageUtil.csproj", "{452F915B-CF21-4ED6-A3FB-AD33C274D9F5}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Release|x64 = Release|x64
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {452F915B-CF21-4ED6-A3FB-AD33C274D9F5}.Debug|x64.ActiveCfg = Debug|x64
15 | {452F915B-CF21-4ED6-A3FB-AD33C274D9F5}.Debug|x64.Build.0 = Debug|x64
16 | {452F915B-CF21-4ED6-A3FB-AD33C274D9F5}.Release|x64.ActiveCfg = Release|x64
17 | {452F915B-CF21-4ED6-A3FB-AD33C274D9F5}.Release|x64.Build.0 = Release|x64
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {F6426453-A4BA-46F9-A416-6688C8D33189}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/App.xaml.cs:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System.Windows;
19 |
20 | namespace GameImageUtil
21 | {
22 | ///
23 | /// Interaction logic for App.xaml
24 | ///
25 | public partial class App : Application
26 | {
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/FileProcessorConfig.cs:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.Collections.Generic;
20 | using System.IO;
21 |
22 | namespace GameImageUtil
23 | {
24 | ///
25 | /// A class to hold File Processor Config
26 | ///
27 | public class FileProcessorConfig : IDisposable
28 | {
29 | ///
30 | /// Message Types for logging
31 | ///
32 | public enum MessageType
33 | {
34 | INFO,
35 | WARNING,
36 | ERROR,
37 | }
38 |
39 | ///
40 | /// Gets or Sets the Log Writer
41 | ///
42 | private StreamWriter LogWriter { get; set; }
43 |
44 | ///
45 | /// Gets the Settings List
46 | ///
47 | public Dictionary Settings { get; } = new Dictionary();
48 |
49 | ///
50 | /// Gets or Sets the App View Model
51 | ///
52 | public AppViewModel ViewModel { get; set; }
53 |
54 | ///
55 | /// Initializes a new instance of the FileProcessorConfig Class
56 | ///
57 | public FileProcessorConfig()
58 | {
59 | try
60 | {
61 | var logPath = Path.Combine("data\\Logs", string.Format("Log_{0}.txt", DateTime.Now.ToString("dd_MM_yyyy___HH_mm_ss")));
62 |
63 | if (Directory.Exists(Path.GetDirectoryName("data\\Logs")))
64 | Directory.CreateDirectory("data\\Logs");
65 |
66 | LogWriter = new StreamWriter(logPath);
67 | }
68 | catch
69 | {
70 | LogWriter?.Dispose();
71 | }
72 | }
73 |
74 | ///
75 | /// Initializes a new instance of the FileProcessorConfig Class with existing values
76 | ///
77 | /// Existing values to copy
78 | public FileProcessorConfig(Dictionary existingValues) : this()
79 | {
80 | foreach (var val in existingValues)
81 | Settings[val.Key] = val.Value;
82 | }
83 |
84 | ///
85 | /// Gets the Setting for the key
86 | ///
87 | /// Key to obtain
88 | /// Default Value
89 | /// Key if found, otherwise default
90 | public T GetValue(string setting, T defaultVal) => Settings.TryGetValue(setting, out var val) && val is T result ? result : defaultVal;
91 |
92 |
93 | ///
94 | /// Writes a message to the log
95 | ///
96 | /// Message to write
97 | /// Message Type
98 | public void Log(object message, MessageType messageType)
99 | {
100 | // Write to file
101 | lock (LogWriter)
102 | {
103 | LogWriter?.WriteLine(string.Format("{0} [ {1} ] {2}", DateTime.Now.ToString("dd-MM-yyyy - HH:mm:ss"), messageType, message));
104 | LogWriter?.Flush();
105 | }
106 | }
107 |
108 | ///
109 | /// Disposes of the config
110 | ///
111 | public void Dispose()
112 | {
113 | LogWriter?.Dispose();
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/FodyWeavers.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks
13 |
14 |
15 |
16 |
17 | A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.
18 |
19 |
20 |
21 |
22 | A list of unmanaged 32 bit assembly names to include, delimited with line breaks.
23 |
24 |
25 |
26 |
27 | A list of unmanaged 64 bit assembly names to include, delimited with line breaks.
28 |
29 |
30 |
31 |
32 | The order of preloaded assemblies, delimited with line breaks.
33 |
34 |
35 |
36 |
37 |
38 | This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.
39 |
40 |
41 |
42 |
43 | Controls if .pdbs for reference assemblies are also embedded.
44 |
45 |
46 |
47 |
48 | Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.
49 |
50 |
51 |
52 |
53 | As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.
54 |
55 |
56 |
57 |
58 | Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.
59 |
60 |
61 |
62 |
63 | Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.
64 |
65 |
66 |
67 |
68 | A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |
69 |
70 |
71 |
72 |
73 | A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.
74 |
75 |
76 |
77 |
78 | A list of unmanaged 32 bit assembly names to include, delimited with |.
79 |
80 |
81 |
82 |
83 | A list of unmanaged 64 bit assembly names to include, delimited with |.
84 |
85 |
86 |
87 |
88 | The order of preloaded assemblies, delimited with |.
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
97 |
98 |
99 |
100 |
101 | A comma-separated list of error codes that can be safely ignored in assembly verification.
102 |
103 |
104 |
105 |
106 | 'false' to turn off automatic generation of the XML Schema file.
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/GameImageUtil.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {452F915B-CF21-4ED6-A3FB-AD33C274D9F5}
9 | WinExe
10 | GameImageUtil
11 | GameImageUtil
12 | v4.8
13 | 512
14 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
15 | 4
16 | true
17 | true
18 |
19 |
20 |
21 |
22 | true
23 | bin\x64\Debug\
24 | DEBUG;TRACE
25 | full
26 | x64
27 | 7.3
28 | prompt
29 | MinimumRecommendedRules.ruleset
30 | true
31 |
32 |
33 | bin\x64\Release\
34 | TRACE
35 | true
36 | pdbonly
37 | x64
38 | 7.3
39 | prompt
40 | MinimumRecommendedRules.ruleset
41 | true
42 |
43 |
44 | Icon.ico
45 |
46 |
47 |
48 | ..\packages\ControlzEx.4.3.0\lib\net462\ControlzEx.dll
49 |
50 |
51 | ..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll
52 |
53 |
54 | ..\packages\MahApps.Metro.2.0.1\lib\net47\MahApps.Metro.dll
55 |
56 |
57 | ..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.19\lib\net45\Microsoft.Xaml.Behaviors.dll
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | 4.0
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | MSBuild:Compile
81 | Designer
82 |
83 |
84 |
85 |
86 |
87 |
88 | MSBuild:Compile
89 | Designer
90 |
91 |
92 | App.xaml
93 | Code
94 |
95 |
96 |
97 | MainWindow.xaml
98 | Code
99 |
100 |
101 | Designer
102 | MSBuild:Compile
103 |
104 |
105 |
106 |
107 |
108 | ProgressWindow.xaml
109 |
110 |
111 | Code
112 |
113 |
114 | True
115 | True
116 | Resources.resx
117 |
118 |
119 | True
120 | Settings.settings
121 | True
122 |
123 |
124 | ResXFileCodeGenerator
125 | Resources.Designer.cs
126 |
127 |
128 | Always
129 |
130 |
131 | Always
132 |
133 |
134 | Always
135 |
136 |
137 | Always
138 |
139 |
140 | Always
141 |
142 |
143 | Always
144 |
145 |
146 | Always
147 |
148 |
149 | Always
150 |
151 |
152 | Always
153 |
154 |
155 | Always
156 |
157 |
158 | Always
159 |
160 |
161 | Always
162 |
163 |
164 | Always
165 |
166 |
167 | Always
168 |
169 |
170 |
171 | SettingsSingleFileGenerator
172 | Settings.Designer.cs
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 | Always
181 |
182 |
183 |
184 |
185 |
186 | Always
187 |
188 |
189 | Always
190 |
191 |
192 |
193 |
194 |
195 |
196 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
197 |
198 |
199 |
200 |
201 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/IFileProcessor.cs:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2018 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 |
19 | namespace GameImageUtil
20 | {
21 | ///
22 | /// An interface for file processors
23 | ///
24 | public interface IFileProcessor
25 | {
26 | ///
27 | /// Gets the ID of this Processor
28 | ///
29 | string ID { get; }
30 |
31 | ///
32 | /// Gets the Name of this Processor
33 | ///
34 | string Name { get; }
35 |
36 | ///
37 | /// Processes the provided file
38 | ///
39 | /// File to process
40 | /// Config with settings
41 | void Process(string file, FileProcessorConfig config);
42 |
43 | ///
44 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
45 | ///
46 | /// File to process
47 | /// Config with settings
48 | /// True if we can, otherwise False
49 | bool CanProcessFile(string file, FileProcessorConfig config);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/Icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Scobalula/GameImageUtil/5cfb6b3b1cb1f0fd4f08ad55c432d3b8cc3f832f/src/GameImageUtil/GameImageUtil/Icon.ico
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.ComponentModel;
20 | using System.Diagnostics;
21 | using System.IO;
22 | using System.Linq;
23 | using System.Reflection;
24 | using System.Threading.Tasks;
25 | using System.Windows;
26 |
27 | namespace GameImageUtil
28 | {
29 | ///
30 | /// Interaction logic for MainWindow.xaml
31 | ///
32 | public partial class MainWindow
33 | {
34 | ///
35 | /// Gets the Main View Model
36 | ///
37 | public AppViewModel ViewModel { get; } = new AppViewModel();
38 |
39 | ///
40 | /// Gets Progress Messages
41 | ///
42 | private string[] ProgressMessages { get; } =
43 | {
44 | "GameImageUtil | Doing the all thing....",
45 | "GameImageUtil | Taking over the world....",
46 | "GameImageUtil | Enhancing your life....",
47 | "GameImageUtil | Creating Black Ops II Mod Tools....",
48 | "GameImageUtil | Starting World War III....",
49 | "GameImageUtil | Getting rid of Shiba Charmy....",
50 | "GameImageUtil | Building Shot Shobe's Arena....",
51 | "GameImageUtil | Porting images in 600 hours....",
52 | "GameImageUtil | Deleting Box Maps off BO3 Workshop....",
53 | "GameImageUtil | Optimizing your map....",
54 | "GameImageUtil | Creating a keylogger....",
55 | "GameImageUtil | Calling in the moderation team on Discord....",
56 | "GameImageUtil | A bit slow are we....",
57 | "GameImageUtil | Developing nuclear weapons....",
58 | "GameImageUtil | xSanz78....",
59 | "GameImageUtil | Releasing the FX Pack....",
60 | "GameImageUtil | Shot Shobe > Shiba Charmy....",
61 | "GameImageUtil | Scamming someone for character ports....",
62 | "GameImageUtil | Creating a pandemic....",
63 | "GameImageUtil | Rocks in the brain....",
64 | "GameImageUtil | Nevis Christmas Release....",
65 | "GameImageUtil | E-Begging for Reece....",
66 | };
67 |
68 | ///
69 | /// Initializes new Window
70 | ///
71 | public MainWindow()
72 | {
73 | DataContext = ViewModel;
74 | InitializeComponent();
75 |
76 | AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;
77 | }
78 |
79 | ///
80 | /// Attempts to resolve missing assemblys that are in the lib directories
81 | /// Fixes probing "probing privatePath="dir"" failing once outside Releases/Debug....
82 | ///
83 | private Assembly ResolveAssembly(object sender, ResolveEventArgs args)
84 | {
85 | // We should attempt to see if the assembly is already loaded first
86 | var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName == args.Name);
87 |
88 | if (assembly == null)
89 | {
90 | try
91 | {
92 | // We're given a full string of info, so we need to split for just the name
93 | assembly = Assembly.LoadFrom(Path.Combine("data\\lib", args.Name.Split(',')[0] + ".dll".ToLower()));
94 | }
95 | #if DEBUG
96 | catch (Exception ex)
97 | {
98 | Console.WriteLine(ex);
99 | }
100 | #else
101 | catch { }
102 | #endif
103 | }
104 |
105 | return assembly;
106 | }
107 |
108 | ///
109 | /// Opens the donation window (something you should do right now :))
110 | ///
111 | private void DonateClick(object sender, RoutedEventArgs e)
112 | {
113 | Process.Start("https://www.paypal.me/Scobalula");
114 | }
115 |
116 | ///
117 | /// Handles on drop
118 | ///
119 | private void DropBoxDrop(object sender, DragEventArgs e)
120 | {
121 | if (e.Data.GetDataPresent(DataFormats.FileDrop))
122 | {
123 | string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
124 | new ProgressWindow(ProcessFiles, null, null, "Processing Images", files, files.Length, this, ProgressMessages[new Random().Next(0, ProgressMessages.Length)]).ShowDialog();
125 | }
126 | }
127 |
128 | ///
129 | /// Processes the provided files
130 | ///
131 | public void ProcessFiles(object sender, DoWorkEventArgs e)
132 | {
133 | var window = e.Argument as ProgressWindow;
134 |
135 | using (var config = new FileProcessorConfig() { ViewModel = ViewModel })
136 | {
137 | config.Settings["Extension"] = ViewModel.Extensions[ViewModel.SelectedExtension].ToLower();
138 |
139 | var processor = ViewModel.Processors[ViewModel.SelectedProcessor];
140 |
141 | switch (ViewModel.DXGIFormats[ViewModel.SelectedDXGIFormat])
142 | {
143 | case "DXT1":
144 | config.Settings["DXGIFormat"] = 71;
145 | break;
146 | case "DXT3":
147 | config.Settings["DXGIFormat"] = 74;
148 | break;
149 | case "DXT5":
150 | config.Settings["DXGIFormat"] = 77;
151 | break;
152 | case "BC4":
153 | config.Settings["DXGIFormat"] = 80;
154 | break;
155 | case "BC5":
156 | config.Settings["DXGIFormat"] = 83;
157 | break;
158 | default:
159 | config.Settings["DXGIFormat"] = 71;
160 | break;
161 | }
162 |
163 | Parallel.ForEach(window.Data as string[], new ParallelOptions { MaxDegreeOfParallelism = ViewModel.ThreadCount }, (file, loop) =>
164 | {
165 | try
166 | {
167 | config.Log(string.Format("Processing {0}....", file), FileProcessorConfig.MessageType.INFO);
168 | processor.Process(file, config);
169 | config.Log(string.Format("Processed {0} successfully", file), FileProcessorConfig.MessageType.INFO);
170 | }
171 | catch (Exception exception)
172 | {
173 | config.Log(string.Format("Failed to process file {0}. Error:\n{1}", Path.GetFileNameWithoutExtension(file), exception), FileProcessorConfig.MessageType.ERROR);
174 | }
175 |
176 | window.Worker.ReportProgress(0);
177 |
178 | if (window.Worker.CancellationPending)
179 | loop.Break();
180 | });
181 | }
182 | }
183 |
184 | ///
185 | /// Handles on Window Closing
186 | ///
187 | private void WindowClosing(object sender, CancelEventArgs e)
188 | {
189 | ViewModel.CurrentSettings.Save("data\\Settings.bcfg");
190 | }
191 | }
192 | }
193 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/Notifiable.cs:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System.Collections.Generic;
19 | using System.ComponentModel;
20 | using System.Runtime.CompilerServices;
21 |
22 | namespace GameImageUtil
23 | {
24 | public class Notifiable : INotifyPropertyChanged
25 | {
26 | ///
27 | /// Gets the Backing Variables Dictionary
28 | ///
29 | private Dictionary BackingVariables { get; } = new Dictionary();
30 |
31 | ///
32 | /// Property Changed Event Handler
33 | ///
34 | public event PropertyChangedEventHandler PropertyChanged;
35 |
36 | ///
37 | /// Gets the value of the given property
38 | ///
39 | protected T GetValue([CallerMemberName] string propertyName = "", T defaultValue = default)
40 | {
41 | if (BackingVariables.TryGetValue(propertyName, out var value))
42 | return (T)value;
43 | else
44 | return defaultValue;
45 | }
46 |
47 | ///
48 | /// Sets the value of the given property
49 | ///
50 | protected void SetValue(T newValue, [CallerMemberName] string propertyName = "")
51 | {
52 | BackingVariables[propertyName] = newValue;
53 | NotifyPropertyChanged(propertyName);
54 | }
55 |
56 | ///
57 | /// Notifies that the property has changed
58 | ///
59 | protected void NotifyPropertyChanged([CallerMemberName] string propertyName = "") => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/ProgressWindow.xaml:
--------------------------------------------------------------------------------
1 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/ProgressWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.ComponentModel;
20 | using System.Diagnostics;
21 | using System.Windows;
22 |
23 | namespace GameImageUtil
24 | {
25 | ///
26 | /// Interaction logic for ProgressWindow.xaml
27 | ///
28 | public partial class ProgressWindow
29 | {
30 | ///
31 | /// Gets the Progress Window View Model
32 | ///
33 | private ProgressWindowViewModel ViewModel { get; } = new ProgressWindowViewModel();
34 |
35 | ///
36 | /// Gets or Sets the Background Worker
37 | ///
38 | public BackgroundWorker Worker { get; set; }
39 |
40 | ///
41 | /// Gets or Sets the Worker Args
42 | ///
43 | public object Data { get; set; }
44 |
45 | ///
46 | /// Initializes Progress Window
47 | ///
48 | public ProgressWindow(DoWorkEventHandler work, ProgressChangedEventHandler changed, RunWorkerCompletedEventHandler complete, string message, object data, double count, Window owner, string title)
49 | {
50 | InitializeComponent();
51 |
52 | // Init Worker
53 | Worker = new BackgroundWorker
54 | {
55 | WorkerSupportsCancellation = true,
56 | WorkerReportsProgress = true,
57 | };
58 |
59 | Worker.ProgressChanged += ProgressChanged;
60 | Worker.RunWorkerCompleted += ProgressComplete;
61 |
62 | if (work != null)
63 | Worker.DoWork += work;
64 | if (changed != null)
65 | Worker.ProgressChanged += changed;
66 | if (complete != null)
67 | Worker.RunWorkerCompleted += complete;
68 |
69 | // Set up initial data
70 | DataContext = ViewModel;
71 | Owner = owner;
72 | Data = data;
73 | ViewModel.Count = count;
74 | ViewModel.Value = 0;
75 | ViewModel.Text = message;
76 |
77 | Title = title;
78 |
79 | // We only need to run the worker once loaded
80 | Loaded += StartWorker;
81 | }
82 |
83 | ///
84 | /// Starts the worker
85 | ///
86 | private void StartWorker(object sender, RoutedEventArgs e)
87 | {
88 | Worker.RunWorkerAsync(this);
89 | }
90 |
91 | ///
92 | /// Handles on progress complete
93 | ///
94 | private void ProgressComplete(object sender, RunWorkerCompletedEventArgs e)
95 | {
96 | Close();
97 | }
98 |
99 | ///
100 | /// Updates bar on progress changed
101 | ///
102 | private void ProgressChanged(object sender, ProgressChangedEventArgs e)
103 | {
104 | if (!Worker.CancellationPending)
105 | {
106 | if (e.UserState != null)
107 | ViewModel.Text = e.UserState?.ToString();
108 | ViewModel.Indeterminate = e.ProgressPercentage < 0;
109 | ViewModel.Value++;
110 | }
111 | }
112 |
113 | ///
114 | /// Sets Cancelled to true to update current task
115 | ///
116 | private void WindowClosing(object sender, CancelEventArgs e)
117 | {
118 | ViewModel.Text = "Cancelling task, please wait...";
119 | Worker?.CancelAsync();
120 | e.Cancel = Worker.IsBusy;
121 | }
122 |
123 | ///
124 | /// Closes Window on Cancel click
125 | ///
126 | private void RightButtonClick(object sender, RoutedEventArgs e)
127 | {
128 | ViewModel.Text = "Cancelling task, please wait...";
129 | Worker?.CancelAsync();
130 | }
131 | }
132 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("GameImageUtil")]
11 | [assembly: AssemblyDescription("Game Image Processing Tool")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("Philip/Scobalula")]
14 | [assembly: AssemblyProduct("GameImageUtil")]
15 | [assembly: AssemblyCopyright("Copyright © Philip/Scobalula 2020")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.2")]
55 | [assembly: AssemblyFileVersion("1.0.0.2")]
56 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace GameImageUtil.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GameImageUtil.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace GameImageUtil.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/Settings.cs:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2018 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System.Collections.Generic;
19 | using System.IO;
20 |
21 | namespace GameImageUtil
22 | {
23 | public class Settings
24 | {
25 | ///
26 | /// Setting Values
27 | ///
28 | private Dictionary Values = new Dictionary();
29 |
30 | ///
31 | /// Gets the setting with the given name, if not found, returns defaultVal
32 | ///
33 | public string this[string key, string defaultVal]
34 | {
35 | get
36 | {
37 | return Values.TryGetValue(key, out var val) ? val : defaultVal;
38 | }
39 | }
40 |
41 | ///
42 | /// Sets the setting with the given name
43 | ///
44 | public string this[string key]
45 | {
46 | set
47 | {
48 | Values[key] = value;
49 | }
50 | }
51 |
52 | ///
53 | /// Initializes an instance of the Settings Class
54 | ///
55 | public Settings() { }
56 |
57 | ///
58 | /// Initializes an instance of the Settings Class and loads the settings
59 | ///
60 | /// File Name
61 | public Settings(string fileName)
62 | {
63 | Load(fileName);
64 | }
65 |
66 | ///
67 | /// Loads Settings from a file
68 | ///
69 | /// File Name
70 | public void Load(string fileName)
71 | {
72 | try
73 | {
74 | if (!File.Exists(fileName))
75 | {
76 | Save(fileName);
77 | }
78 | else
79 | {
80 | using (var reader = new BinaryReader(new FileStream(fileName, FileMode.Open)))
81 | {
82 | if (reader.ReadUInt32() == 0x47464348)
83 | {
84 | int count = reader.ReadInt32();
85 |
86 | for (int i = 0; i < count; i++)
87 | Values[reader.ReadString()] = reader.ReadString();
88 | }
89 | }
90 | }
91 | }
92 | catch
93 | {
94 | return;
95 | }
96 | }
97 |
98 | ///
99 | /// Saves all settings to a file
100 | ///
101 | /// File Name
102 | public void Save(string fileName)
103 | {
104 | try
105 | {
106 | using (var writer = new BinaryWriter(new FileStream(fileName, FileMode.Create)))
107 | {
108 | writer.Write(0x47464348);
109 | writer.Write(Values.Count);
110 |
111 | foreach (var value in Values)
112 | {
113 | writer.Write(value.Key);
114 | writer.Write(value.Value);
115 | }
116 | }
117 | }
118 | catch
119 | {
120 | return;
121 | }
122 | }
123 | }
124 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/ViewModels/AppViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.CodeDom.Compiler;
3 | using Microsoft.CSharp;
4 | using System.Collections.Generic;
5 | using System.Collections.ObjectModel;
6 | using System.Reflection;
7 | using System.IO;
8 | using System.Windows;
9 |
10 | namespace GameImageUtil
11 | {
12 | ///
13 | /// App View Model
14 | ///
15 | public class AppViewModel : Notifiable
16 | {
17 | ///
18 | /// Gets or Sets the selected Processor
19 | ///
20 | public int SelectedProcessor
21 | {
22 | get
23 | {
24 | return GetValue("SelectedProcessor");
25 | }
26 | set
27 | {
28 | CurrentSettings["SelectedProcessor"] = value.ToString();
29 | SetValue(value, "SelectedProcessor");
30 | }
31 | }
32 |
33 | ///
34 | /// Gets or Sets the selected Extension
35 | ///
36 | public int SelectedExtension
37 | {
38 | get
39 | {
40 | return GetValue("SelectedExtension");
41 | }
42 | set
43 | {
44 | CurrentSettings["SelectedExtension"] = value.ToString();
45 | SetValue(value, "SelectedExtension");
46 | NotifyPropertyChanged("DXGIVisibility");
47 | }
48 | }
49 |
50 | ///
51 | /// Gets or Sets the selected DXGI Format
52 | ///
53 | public int SelectedDXGIFormat
54 | {
55 | get
56 | {
57 | return GetValue("SelectedDXGIFormat");
58 | }
59 | set
60 | {
61 | CurrentSettings["SelectedDXGIFormat"] = value.ToString();
62 | SetValue(value, "SelectedDXGIFormat");
63 | }
64 | }
65 |
66 | ///
67 | /// Gets or Sets the number of processing threads
68 | ///
69 | public int ThreadCount
70 | {
71 | get
72 | {
73 | return GetValue("ThreadCount", Environment.ProcessorCount);
74 | }
75 | set
76 | {
77 | CurrentSettings["ThreadCount"] = value.ToString();
78 | SetValue(value, "ThreadCount");
79 | }
80 | }
81 |
82 | ///
83 | /// Gets or Sets the DXGI Visibility
84 | ///
85 | public Visibility DXGIVisibility
86 | {
87 | get
88 | {
89 | return GetValue("DXGIVisibility", Extensions[SelectedExtension] == ".DDS" ? Visibility.Visible : Visibility.Hidden);
90 | }
91 | set
92 | {
93 | SetValue(value, "DXGIVisibility");
94 | }
95 | }
96 |
97 | ///
98 | /// Gets the File Processors
99 | ///
100 | public ObservableCollection Processors { get; private set; }
101 |
102 | ///
103 | /// Gets the valid File Extensions for Read/Write
104 | ///
105 | public ObservableCollection Extensions { get; private set; }
106 |
107 | ///
108 | /// Gets the valid DXGI Formats for DDS
109 | ///
110 | public ObservableCollection DXGIFormats { get; private set; }
111 |
112 | ///
113 | /// Gets or Sets the Current Settings
114 | ///
115 | public Settings CurrentSettings { get; set; }
116 |
117 | ///
118 | /// Initializes the View Model
119 | ///
120 | public AppViewModel()
121 | {
122 | CurrentSettings = new Settings("data\\Settings.bcfg");
123 |
124 | Processors = new ObservableCollection();
125 | Extensions = new ObservableCollection()
126 | {
127 | ".PNG",
128 | ".TIF",
129 | ".TIFF",
130 | ".JPG",
131 | ".TGA",
132 | ".BMP",
133 | ".DDS",
134 | };
135 | DXGIFormats = new ObservableCollection()
136 | {
137 | "DXT1",
138 | "DXT3",
139 | "DXT5",
140 | "BC4",
141 | "BC5",
142 | };
143 |
144 | LoadScripts("data\\scripts");
145 |
146 | var tempList = new List();
147 | BuildTypeList(tempList);
148 |
149 | tempList.Sort((x, y) => x.Name.CompareTo(y.Name));
150 |
151 | foreach (var list in tempList)
152 | Processors.Add(list);
153 |
154 | SelectedProcessor = int.TryParse(CurrentSettings["SelectedProcessor", Math.Max(FindProcessorIndex("AutomaticProcessor"), 0).ToString()], out var a) ? a : SelectedProcessor;
155 | SelectedExtension = int.TryParse(CurrentSettings["SelectedExtension", "0"], out var b) ? b : SelectedExtension;
156 | SelectedDXGIFormat = int.TryParse(CurrentSettings["SelectedDXGIFormat", "0"], out var c) ? c : SelectedDXGIFormat;
157 | ThreadCount = int.TryParse(CurrentSettings["ThreadCount", Environment.ProcessorCount.ToString()], out var d) ? d : ThreadCount;
158 | }
159 |
160 | private void LoadScripts(string folder)
161 | {
162 | try
163 | {
164 | foreach (var script in Directory.EnumerateFiles(folder, "*.cs_script", SearchOption.AllDirectories))
165 | {
166 | try
167 | {
168 | var options = new CompilerParameters
169 | {
170 | GenerateExecutable = false,
171 | GenerateInMemory = true
172 | };
173 |
174 | options.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);
175 | options.ReferencedAssemblies.Add("System.dll");
176 | options.ReferencedAssemblies.Add("System.Linq.dll");
177 | options.ReferencedAssemblies.Add(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Data\\Lib\\PhilLibX.dll"));
178 | options.ReferencedAssemblies.Add(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Data\\Lib\\PhilLibX.Interop.dll"));
179 | options.ReferencedAssemblies.Add("System.Numerics.dll");
180 |
181 | var result = new CSharpCodeProvider().CompileAssemblyFromSource(options, File.ReadAllText(script));
182 |
183 | if (result.Errors.HasErrors)
184 | File.WriteAllText(script + ".errors.txt", result.Errors[0].ToString());
185 | if (result.Errors.HasWarnings)
186 | File.WriteAllText(script + ".warnings.txt", result.Errors[0].ToString());
187 | }
188 | catch (Exception e)
189 | {
190 | File.WriteAllText(script + ".fatal.txt", e.ToString());
191 | }
192 | }
193 | }
194 | #if DEBUG
195 | catch(Exception e)
196 | {
197 | Console.WriteLine(e);
198 | }
199 | #else
200 | catch { }
201 | #endif
202 | }
203 |
204 | public static void BuildTypeList(IList list)
205 | {
206 | foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
207 | {
208 | foreach (var type in assembly.GetTypes())
209 | {
210 | if (!type.IsInterface && !type.IsAbstract && typeof(T).IsAssignableFrom(type))
211 | {
212 | list.Add((T)Activator.CreateInstance(type));
213 | }
214 | }
215 | }
216 | }
217 |
218 | ///
219 | /// Attempts to locate the processor by ID
220 | ///
221 | /// ID to search for
222 | /// Processor if found, otherwise null
223 | public IFileProcessor FindProcessor(string id)
224 | {
225 | id = id.ToLower();
226 |
227 | foreach (var processor in Processors)
228 | if (processor.ID.ToLower() == id)
229 | return processor;
230 |
231 | return null;
232 | }
233 |
234 | ///
235 | /// Attempts to locate the processor by ID
236 | ///
237 | /// ID to search for
238 | /// Processor index if found, otherwise -1
239 | public int FindProcessorIndex(string id)
240 | {
241 | id = id.ToLower();
242 |
243 | for(int i = 0; i < Processors.Count; i++)
244 | if (Processors[i].ID.ToLower() == id)
245 | return i;
246 |
247 | return -1;
248 | }
249 | }
250 | }
251 |
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/ViewModels/ProgressViewModel.cs:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 |
19 | namespace GameImageUtil
20 | {
21 | ///
22 | /// Progress Window View Model
23 | ///
24 | internal class ProgressWindowViewModel : Notifiable
25 | {
26 | ///
27 | /// Gets or Sets the number of items
28 | ///
29 | public double Count
30 | {
31 | get
32 | {
33 | return GetValue("Count");
34 | }
35 | set
36 | {
37 | SetValue(value, "Count");
38 | }
39 | }
40 |
41 | ///
42 | /// Gets or Sets the current progress value
43 | ///
44 | public double Value
45 | {
46 | get
47 | {
48 | return GetValue("Value");
49 | }
50 | set
51 | {
52 | SetValue(value, "Value");
53 | }
54 | }
55 |
56 | ///
57 | /// Gets or Sets if the progress bar is Indeterminate
58 | ///
59 | public bool Indeterminate
60 | {
61 | get
62 | {
63 | return GetValue("Indeterminate");
64 | }
65 | set
66 | {
67 | SetValue(value, "Indeterminate");
68 | }
69 | }
70 |
71 | ///
72 | /// Gets or Sets the Display Text
73 | ///
74 | public string Text
75 | {
76 | get
77 | {
78 | return GetValue("Text");
79 | }
80 | set
81 | {
82 | SetValue(value, "Text");
83 | }
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/IMPORTANT.txt:
--------------------------------------------------------------------------------
1 | CS Scripts have full access to do whatever they need to do, this also means you should only install scripts you trust
2 |
3 | Always double check a script has no malicious code before installing it, if the script is obsfucated, etc. in any way,
4 | it is recommended to not install it
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/lib/PhilLibX.Interop.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Scobalula/GameImageUtil/5cfb6b3b1cb1f0fd4f08ad55c432d3b8cc3f832f/src/GameImageUtil/GameImageUtil/data/lib/PhilLibX.Interop.dll
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/lib/PhilLibX.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Scobalula/GameImageUtil/5cfb6b3b1cb1f0fd4f08ad55c432d3b8cc3f832f/src/GameImageUtil/GameImageUtil/data/lib/PhilLibX.dll
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/AutomaticProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 |
20 | namespace GameImageUtil
21 | {
22 | ///
23 | /// A class to handle reconstructing Z component of a BC5 XY normal map
24 | ///
25 | public class AutomaticProcessor : IFileProcessor
26 | {
27 | ///
28 | /// Gets the ID of this Processor
29 | ///
30 | public string ID { get { return "AutomaticProcessor"; } }
31 |
32 | ///
33 | /// Gets the Name of this Processor
34 | ///
35 | public string Name { get { return "Automatic"; } }
36 |
37 | ///
38 | /// Processes the provided image
39 | ///
40 | /// File to process
41 | /// Config with settings
42 | public void Process(string file, FileProcessorConfig config)
43 | {
44 | // Loop and do match, if we find a valid processor, roll with it
45 | foreach(var processor in config.ViewModel.Processors)
46 | {
47 | if(processor.CanProcessFile(file, config))
48 | {
49 | processor.Process(file, config);
50 | return;
51 | }
52 | }
53 |
54 | // If all else fails, direct convert
55 | var defaultProcessor = config.ViewModel.FindProcessor("DirectConvertProcessor");
56 |
57 | if(defaultProcessor != null)
58 | defaultProcessor.Process(file, config);
59 | }
60 |
61 | ///
62 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
63 | ///
64 | /// File to process
65 | /// Config with settings
66 | /// True if we can, otherwise False
67 | public bool CanProcessFile(string file, FileProcessorConfig config)
68 | {
69 | return false;
70 | }
71 |
72 | ///
73 | /// Returns a string that represents the current object.
74 | ///
75 | /// A string that represents the current object.
76 | public override string ToString()
77 | {
78 | return Name;
79 | }
80 | }
81 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/BC5XYNormalMapProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.IO;
20 | using System.Numerics;
21 | using PhilLibX.Imaging;
22 |
23 | namespace GameImageUtil
24 | {
25 | ///
26 | /// A class to handle reconstructing Z component of a BC5 XY normal map
27 | ///
28 | public class BC5XYNormalMapProcessor : IFileProcessor
29 | {
30 | ///
31 | /// Gets the ID of this Processor
32 | ///
33 | public string ID { get { return "BC5XYNormalMapProcessor"; } }
34 |
35 | ///
36 | /// Gets the Name of this Processor
37 | ///
38 | public string Name { get { return "XY Normal Map (BC5 Grey/Yellow w/ No Alpha) (Modern Games/Global)"; } }
39 |
40 | ///
41 | /// Processes the provided image
42 | ///
43 | /// File to process
44 | /// Config with settings
45 | public void Process(string file, FileProcessorConfig config)
46 | {
47 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
48 | return;
49 |
50 | using (var image = new ScratchImage(file))
51 | {
52 | var ext = config.GetValue("Extension", ".PNG");
53 | var dxgi = config.GetValue("DXGIFormat", 77);
54 | var outputPath = config.GetValue("OutputPath", "");
55 |
56 | if(string.IsNullOrWhiteSpace(outputPath))
57 | outputPath = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file));
58 |
59 | // Force the image to a standard format
60 | image.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
61 |
62 | for (int x = 0; x < image.Width; x++)
63 | {
64 | for (int y = 0; y < image.Height; y++)
65 | {
66 | // Get Pixel
67 | var pixel = image.GetPixel(0, 0, 0, x, y);
68 |
69 | var nX = pixel.X * 2.0f - 1.0f;
70 | var nY = pixel.Y * 2.0f - 1.0f;
71 | var nZ = 1.0f - (nX * nX) - (nY * nY);
72 |
73 | image.SetPixel(0, 0, 0, x, y, new Vector4(nX * 0.5f + 0.5f, nY * 0.5f + 0.5f, nZ > 0.0f ? (float)Math.Sqrt(nZ) * 0.5f + 0.5f : 0.0f, 1.0f));
74 | }
75 | }
76 |
77 | if (ext == ".dds")
78 | image.ConvertImage((ScratchImage.DXGIFormat)dxgi);
79 |
80 | image.Save(outputPath + ext);
81 | }
82 | }
83 |
84 | ///
85 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
86 | ///
87 | /// File to process
88 | /// Config with settings
89 | /// True if we can, otherwise False
90 | public bool CanProcessFile(string file, FileProcessorConfig config)
91 | {
92 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
93 | return false;
94 |
95 | return false;
96 | }
97 |
98 | ///
99 | /// Returns a string that represents the current object.
100 | ///
101 | /// A string that represents the current object.
102 | public override string ToString()
103 | {
104 | return Name;
105 | }
106 | }
107 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/CastProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.Collections.Generic;
20 | using System.IO;
21 | using System.Linq;
22 | using System.Text;
23 |
24 | namespace GameImageUtil
25 | {
26 | ///
27 | /// A class to handle processing Cast files
28 | ///
29 | /// This is more orientated atm towards Apex Legend's exports and simply copies
30 | /// and provides conversion where necessary
31 | /// References:
32 | /// https://github.com/dtzxporter/cast
33 | ///
34 | public class CastProcessor : IFileProcessor
35 | {
36 | ///
37 | /// Gets the ID of this Processor
38 | ///
39 | public string ID { get { return "CastProcessor"; } }
40 |
41 | ///
42 | /// Gets the Name of this Processor
43 | ///
44 | public string Name { get { return "Cast Files (Apex Legends/Global)"; } }
45 |
46 | ///
47 | /// Processes the provided image
48 | ///
49 | /// File to process
50 | /// Config with settings
51 | public void Process(string file, FileProcessorConfig config)
52 | {
53 | if (Path.GetExtension(file) != ".cast")
54 | return;
55 |
56 | var cast = new Cast();
57 | cast.Load(file);
58 |
59 | var dir = Path.GetDirectoryName(file);
60 |
61 | foreach (var root in cast.RootNodes)
62 | {
63 | foreach (var model in root.Value.ChildrenOfType())
64 | {
65 | foreach (var material in model.Materials)
66 | {
67 | var mtlName = material.Name;
68 |
69 | foreach (var slot in material.Slots)
70 | {
71 | try
72 | {
73 | var castFile = slot.Value as CastFile;
74 |
75 | if (castFile != null)
76 | {
77 | var curPath = Path.Combine(dir, castFile.Path);
78 |
79 | if (File.Exists(curPath))
80 | {
81 | var newPath = Path.Combine(dir, mtlName, string.Format("{0}_{1}", mtlName, slot.Key));
82 |
83 | Directory.CreateDirectory(Path.GetDirectoryName(newPath));
84 |
85 | config.Settings["OutputPath"] = newPath;
86 |
87 | IFileProcessor processor = null;
88 |
89 | switch (slot.Key)
90 | {
91 | case "normal":
92 | processor = config.ViewModel.FindProcessor("BC5XYNormalMapProcessor");
93 | break;
94 | default:
95 | processor = config.ViewModel.FindProcessor("DirectConvertProcessor");
96 | break;
97 | }
98 |
99 | if(processor != null)
100 | processor.Process(curPath, config);
101 | }
102 | }
103 | }
104 | catch(Exception e)
105 | {
106 | config.Log(string.Format("Failed to convert image in Cast file {0}. Error:\n{1}", Path.GetFileNameWithoutExtension(file), e), FileProcessorConfig.MessageType.ERROR);
107 | }
108 | }
109 | }
110 | }
111 | }
112 | }
113 |
114 | ///
115 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
116 | ///
117 | /// File to process
118 | /// Config with settings
119 | /// True if we can, otherwise False
120 | public bool CanProcessFile(string file, FileProcessorConfig config)
121 | {
122 | // Simply check for cast extension
123 | return Path.GetExtension(file) == ".cast";
124 | }
125 |
126 | ///
127 | /// Returns a string that represents the current object.
128 | ///
129 | /// A string that represents the current object.
130 | public override string ToString()
131 | {
132 | return Name;
133 | }
134 | }
135 |
136 | ///
137 | /// Cast Property Types
138 | ///
139 | enum CastPropertyType : ushort
140 | {
141 | ///
142 | /// 8-Bit Integer (uint8_t/byte)
143 | ///
144 | Byte = 'b',
145 |
146 | ///
147 | /// 16-Bit Integer (uint16_t/ushort)
148 | ///
149 | Short = 'h',
150 |
151 | ///
152 | /// 32-Bit Integer (uint32_t/uint)
153 | ///
154 | Integer32 = 'i',
155 |
156 | ///
157 | /// 64-Bit Integer (uint64_t/ulong)
158 | ///
159 | Integer64 = 'l',
160 |
161 | ///
162 | /// Single Precision Value (float)
163 | ///
164 | Float = 'f',
165 |
166 | ///
167 | /// Double Precision Value (double)
168 | ///
169 | Double = 'd',
170 |
171 | ///
172 | /// Null terminated UTF-8 string
173 | ///
174 | String = 's',
175 |
176 | ///
177 | /// Float precision vector XYZ
178 | ///
179 | Vector2 = 0x7632,
180 |
181 | ///
182 | /// Float precision vector XYZ
183 | ///
184 | Vector3 = 0x7633,
185 |
186 | ///
187 | /// Float precision vector XYZW
188 | ///
189 | Vector4 = 0x7634
190 | }
191 |
192 | ///
193 | /// Cast IDs
194 | ///
195 | enum CastIdentifier : uint
196 | {
197 | Root = 0x746F6F72,
198 | Model = 0x6C646F6D,
199 | Mesh = 0x6873656D,
200 | Skeleton = 0x6C656B73,
201 | Bone = 0x656E6F62,
202 | Animation = 0x6D696E61,
203 | Curve = 0x76727563,
204 | NotificationTrack = 0x6669746E,
205 | Material = 0x6C74616D,
206 | File = 0x656C6966,
207 | };
208 |
209 | ///
210 | /// Cast Property
211 | ///
212 | class CastProperty
213 | {
214 | ///
215 | /// Gets or Sets the Name of the Property
216 | ///
217 | public string Name { get; set; }
218 |
219 | ///
220 | /// Gets or Sets the Property Type
221 | ///
222 | public CastPropertyType Type { get; set; }
223 |
224 | ///
225 | /// Gets or Sets the Values
226 | ///
227 | public object Values { get; set; }
228 |
229 | ///
230 | /// Initializes a new instance of the CastProperty class
231 | ///
232 | public CastProperty() { }
233 |
234 | ///
235 | /// Initializes a new instance of the CastProperty class and loads the property from the given reader
236 | ///
237 | /// Reader to load from
238 | public CastProperty(BinaryReader reader)
239 | {
240 | Load(reader);
241 | }
242 |
243 | ///
244 | /// Loads the property from the given reader
245 | ///
246 | /// Reader to load from
247 | public void Load(BinaryReader reader)
248 | {
249 | var type = reader.ReadUInt16();
250 | var nameSize = reader.ReadUInt16();
251 | var valueCount = reader.ReadInt32();
252 |
253 | Name = new string(reader.ReadChars(nameSize));
254 | Type = (CastPropertyType)type;
255 |
256 | switch (Type)
257 | {
258 | case CastPropertyType.Byte:
259 | {
260 | Values = reader.ReadBytes(valueCount);
261 | break;
262 | }
263 | case CastPropertyType.Short:
264 | {
265 | Values = new ushort[valueCount];
266 | Buffer.BlockCopy(reader.ReadBytes(valueCount * 2), 0, (ushort[])Values, 0, valueCount * 2);
267 | break;
268 | }
269 | case CastPropertyType.Integer32:
270 | {
271 | Values = new uint[valueCount];
272 | Buffer.BlockCopy(reader.ReadBytes(valueCount * 4), 0, (uint[])Values, 0, valueCount * 4);
273 | break;
274 | }
275 | case CastPropertyType.Integer64:
276 | {
277 | Values = new ulong[valueCount];
278 | Buffer.BlockCopy(reader.ReadBytes(valueCount * 8), 0, (ulong[])Values, 0, valueCount * 8);
279 | break;
280 | }
281 | case CastPropertyType.Float:
282 | {
283 | Values = new float[valueCount];
284 | Buffer.BlockCopy(reader.ReadBytes(valueCount * 4), 0, (float[])Values, 0, valueCount * 4);
285 | break;
286 | }
287 | case CastPropertyType.Double:
288 | {
289 | Values = new double[valueCount];
290 | Buffer.BlockCopy(reader.ReadBytes(valueCount * 8), 0, (double[])Values, 0, valueCount * 8);
291 | break;
292 | }
293 | case CastPropertyType.Vector2:
294 | {
295 | Values = new float[valueCount * 2];
296 | Buffer.BlockCopy(reader.ReadBytes(valueCount * 8), 0, (float[])Values, 0, valueCount * 8);
297 | break;
298 | }
299 | case CastPropertyType.Vector3:
300 | {
301 | Values = new float[valueCount * 3];
302 | Buffer.BlockCopy(reader.ReadBytes(valueCount * 12), 0, (float[])Values, 0, valueCount * 12);
303 | break;
304 | }
305 | case CastPropertyType.Vector4:
306 | {
307 | Values = new float[valueCount * 4];
308 | Buffer.BlockCopy(reader.ReadBytes(valueCount * 16), 0, (float[])Values, 0, valueCount * 16);
309 | break;
310 | }
311 | case CastPropertyType.String:
312 | {
313 | Values = new string[valueCount];
314 |
315 | for (int i = 0; i < valueCount; i++)
316 | {
317 | StringBuilder str = new StringBuilder();
318 | int byteRead;
319 |
320 | while ((byteRead = reader.BaseStream.ReadByte()) != 0x0)
321 | str.Append(Convert.ToChar(byteRead));
322 |
323 | ((string[])Values)[i] = str.ToString();
324 | }
325 |
326 | break;
327 | }
328 | }
329 | }
330 | }
331 |
332 | class CastModel : CastNode
333 | {
334 | ///
335 | /// Initializes a new instance of the CastModel class
336 | ///
337 | public CastModel() : base() { }
338 |
339 | ///
340 | /// Initializes a new instance of the CastModel class and loads the node from the given reader
341 | ///
342 | /// Reader to load from
343 | public CastModel(BinaryReader reader) : base(reader)
344 | {
345 | Load(reader);
346 | }
347 |
348 | ///
349 | /// Initializes a new instance of the CastModel class and copies from the base node
350 | ///
351 | /// Node to copy from
352 | public CastModel(CastNode baseNode)
353 | {
354 | ChildNodes = baseNode.ChildNodes;
355 | Properties = baseNode.Properties;
356 | Hash = baseNode.Hash;
357 | Identifier = baseNode.Identifier;
358 | }
359 |
360 | ///
361 | /// Gets the Model Materials
362 | ///
363 | public List Materials
364 | {
365 | get
366 | {
367 | return ChildrenOfType();
368 | }
369 | }
370 | }
371 |
372 | class CastFile : CastNode
373 | {
374 | ///
375 | /// Initializes a new instance of the CastFile class
376 | ///
377 | public CastFile() : base()
378 | {
379 |
380 | }
381 |
382 | ///
383 | /// Initializes a new instance of the CastFile class and loads the node from the given reader
384 | ///
385 | /// Reader to load from
386 | public CastFile(BinaryReader reader) : base(reader)
387 | {
388 | Load(reader);
389 | }
390 |
391 | ///
392 | /// Initializes a new instance of the CastFile class and copies from the base node
393 | ///
394 | /// Node to copy from
395 | public CastFile(CastNode baseNode)
396 | {
397 | ChildNodes = baseNode.ChildNodes;
398 | Properties = baseNode.Properties;
399 | Hash = baseNode.Hash;
400 | Identifier = baseNode.Identifier;
401 | }
402 |
403 | ///
404 | /// Gets the file path
405 | ///
406 | public string Path
407 | {
408 | get
409 | {
410 | CastProperty prop = null;
411 |
412 | if (Properties.TryGetValue("p", out prop))
413 | {
414 | var str = prop.Values as string[];
415 |
416 | if(str != null && str.Length > 0)
417 | return str[0];
418 | }
419 |
420 | return "";
421 | }
422 | }
423 | }
424 |
425 | class CastMaterial : CastNode
426 | {
427 | ///
428 | /// Initializes a new instance of the CastMaterial class
429 | ///
430 | public CastMaterial() : base() { }
431 |
432 | ///
433 | /// Initializes a new instance of the CastMaterial class and loads the node from the given reader
434 | ///
435 | /// Reader to load from
436 | public CastMaterial(BinaryReader reader) : base(reader)
437 | {
438 | Load(reader);
439 | }
440 |
441 | ///
442 | /// Initializes a new instance of the CastMaterial class and copies from the base node
443 | ///
444 | /// Node to copy from
445 | public CastMaterial(CastNode baseNode)
446 | {
447 | ChildNodes = baseNode.ChildNodes;
448 | Properties = baseNode.Properties;
449 | Hash = baseNode.Hash;
450 | Identifier = baseNode.Identifier;
451 | }
452 |
453 | ///
454 | /// Gets the name of the material
455 | ///
456 | public string Name
457 | {
458 | get
459 | {
460 | CastProperty prop = null;
461 |
462 | if (Properties.TryGetValue("n", out prop))
463 | {
464 | var str = prop.Values as string[];
465 |
466 | if(str != null && str.Length > 0)
467 | return str[0];
468 | }
469 |
470 | return "";
471 | }
472 | }
473 |
474 | ///
475 | /// Gets the type of the material
476 | ///
477 | public string Type
478 | {
479 | get
480 | {
481 | CastProperty prop = null;
482 |
483 | if (Properties.TryGetValue("t", out prop))
484 | {
485 | var str = prop.Values as string[];
486 |
487 | if(str != null && str.Length > 0)
488 | return str[0];
489 | }
490 |
491 | return "";
492 | }
493 | }
494 |
495 | ///
496 | /// Gets the type of the image slots for this material
497 | ///
498 | public Dictionary Slots
499 | {
500 | get
501 | {
502 | var results = new Dictionary();
503 |
504 | foreach (var prop in Properties)
505 | {
506 | if (prop.Value.Name != "n" && prop.Value.Name != "t")
507 | {
508 | var hash = prop.Value.Values as ulong[];
509 |
510 | if(hash != null && hash.Length > 0)
511 | {
512 | results[prop.Value.Name] = ChildByHash(hash[0]);
513 | }
514 | }
515 | }
516 |
517 | return results;
518 | }
519 | }
520 | }
521 |
522 | class CastNode
523 | {
524 | ///
525 | /// Gets or Sets the Child Nodes
526 | ///
527 | public Dictionary ChildNodes { get; set; }
528 |
529 | ///
530 | /// Gets or Sets the Child Nodes
531 | ///
532 | public Dictionary Properties { get; set; }
533 |
534 | ///
535 | /// Gets or Sets the Hash
536 | ///
537 | public ulong Hash { get; set; }
538 |
539 | ///
540 | /// Gets or Sets the Cast Identifier
541 | ///
542 | public CastIdentifier Identifier { get; set; }
543 |
544 | ///
545 | /// Initializes a new instance of the CastNode class
546 | ///
547 | public CastNode() { }
548 |
549 | ///
550 | /// Initializes a new instance of the CastNode class and loads the node from the given reader
551 | ///
552 | /// Reader to load from
553 | public CastNode(BinaryReader reader)
554 | {
555 | Load(reader);
556 | }
557 |
558 | ///
559 | /// Gets the node by type, if not found, null is returned
560 | ///
561 | /// Type to search for
562 | /// Node with the given id, otherwise null
563 | public Dictionary ChildrenOfType(CastIdentifier id)
564 | {
565 | var results = new Dictionary();
566 |
567 | foreach (var node in ChildNodes)
568 | if (node.Value.Identifier == id)
569 | results[node.Key] = node.Value;
570 |
571 | return results;
572 | }
573 |
574 | ///
575 | /// Gets the node by type, if not found, null is returned
576 | ///
577 | /// Node with the given type, otherwise null
578 | public List ChildrenOfType() where T : CastNode
579 | {
580 | var list = new List();
581 |
582 | foreach(var x in ChildNodes)
583 | {
584 | if(x.Value.GetType() == typeof(T))
585 | {
586 | list.Add((T)x.Value);
587 | }
588 | }
589 |
590 | return list;
591 |
592 | // return ChildNodes.Where(x => x.Value.GetType() == typeof(T)).Select(x => x.Value).Cast().ToList();
593 | }
594 |
595 | ///
596 | /// Gets the node by hash, if not found, null is returned
597 | ///
598 | /// Hash to search for
599 | /// Node with the given hash, otherwise null
600 | public CastNode ChildByHash(ulong hash)
601 | {
602 | CastNode node = null;
603 | return ChildNodes.TryGetValue(hash, out node) ? node : null;
604 | }
605 |
606 | ///
607 | /// Loads the property from the given reader
608 | ///
609 | /// Reader to load from
610 | public void Load(BinaryReader reader)
611 | {
612 | Properties = new Dictionary();
613 | ChildNodes = new Dictionary();
614 |
615 | var identifier = reader.ReadUInt32();
616 | var nodeSize = reader.ReadUInt32();
617 | var nodeHash = reader.ReadUInt64();
618 | var propCount = reader.ReadUInt32();
619 | var childCount = reader.ReadUInt32();
620 |
621 | Identifier = (CastIdentifier)identifier;
622 | Hash = nodeHash;
623 |
624 | for (uint i = 0; i < propCount; i++)
625 | {
626 | var prop = new CastProperty(reader);
627 | Properties[prop.Name] = prop;
628 | }
629 |
630 | for (uint i = 0; i < childCount; i++)
631 | {
632 | var node = new CastNode(reader);
633 |
634 | // Quick switch will do for the purpose of just getting materials
635 | switch (node.Identifier)
636 | {
637 | case CastIdentifier.Material:
638 | ChildNodes[node.Hash] = new CastMaterial(node);
639 | break;
640 | case CastIdentifier.Model:
641 | ChildNodes[node.Hash] = new CastModel(node);
642 | break;
643 | case CastIdentifier.File:
644 | ChildNodes[node.Hash] = new CastFile(node);
645 | break;
646 | default:
647 | ChildNodes[node.Hash] = node;
648 | break;
649 | }
650 | }
651 | }
652 | }
653 |
654 | class Cast
655 | {
656 | ///
657 | /// Gets or Sets the Root Nodes
658 | ///
659 | public Dictionary RootNodes { get; set; }
660 |
661 | public Cast() { }
662 |
663 | public void Load(string path)
664 | {
665 | RootNodes = new Dictionary();
666 |
667 | using (var reader = new BinaryReader(File.OpenRead(path)))
668 | {
669 | if (reader.ReadUInt32() != 0x74736163)
670 | throw new Exception("Invalid cast file magic");
671 |
672 | var version = reader.ReadUInt32();
673 | var rootNodes = reader.ReadInt32();
674 | var flags = reader.ReadUInt32();
675 |
676 | for (int i = 0; i < rootNodes; i++)
677 | {
678 | var node = new CastNode(reader);
679 | RootNodes[node.Hash] = node;
680 | }
681 | }
682 | }
683 |
684 | public void Load(Stream stream)
685 | {
686 |
687 | }
688 |
689 | public void Load(BinaryReader reader)
690 | {
691 | if (reader.ReadUInt32() != 0x74736163)
692 | throw new Exception("Invalid cast file magic");
693 |
694 | var version = reader.ReadUInt32();
695 | var rootNodes = reader.ReadInt32();
696 | var flags = reader.ReadUInt32();
697 |
698 | for (int i = 0; i < rootNodes; i++)
699 | {
700 | var node = new CastNode(reader);
701 | }
702 | }
703 | }
704 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/CoDFusedCSProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.IO;
20 | using System.Numerics;
21 | using PhilLibX;
22 | using PhilLibX.Imaging;
23 |
24 | namespace GameImageUtil
25 | {
26 | ///
27 | /// A class to handle processing CoD CS Images (Infinite Warfare/Modern Warfare)
28 | /// They are stored as follows:
29 | /// Fused Diffuse/Specular Color (RGB of colorMap)
30 | /// Metalness Mask (stored in Red Channel of S/G/O image)
31 | /// References:
32 | /// https://www.activision.com/cdn/research/2017_DD_Rendering_of_COD_IW.pdf
33 | /// RenderDoc for Shader Debugging
34 | ///
35 | public class CoDFusedCSProcessor : IFileProcessor
36 | {
37 | ///
38 | /// Gets the ID of this Processor
39 | ///
40 | public string ID { get { return "CoDFusedCSProcessor"; } }
41 |
42 | ///
43 | /// Gets the Name of this Processor
44 | ///
45 | public string Name { get { return "CoD Specular/Albedo (Infinite Warfare/Modern Warfare)"; } }
46 |
47 | ///
48 | /// Whether or not to check the directory for "infinite_warfare"/"modern_warfare_4"
49 | ///
50 | public bool CheckDirectoryName { get { return false; } }
51 |
52 | ///
53 | /// Processes the provided image
54 | ///
55 | /// File to process
56 | /// Config with settings
57 | public void Process(string file, FileProcessorConfig config)
58 | {
59 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
60 | return;
61 |
62 | using (var inputImage = new ScratchImage(file))
63 | {
64 | var ext = config.GetValue("Extension", ".PNG");
65 | var dxgi = config.GetValue("DXGIFormat", 77);
66 | var outputPath = config.GetValue("OutputPath", "");
67 |
68 | if(string.IsNullOrWhiteSpace(outputPath))
69 | outputPath = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file).Split(new string[] { "_c&", "_c_" }, StringSplitOptions.None)[0]);
70 |
71 | // Force the image to a standard format
72 | inputImage.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
73 |
74 | const float insulatorSpecRange = 0.1f;
75 |
76 | using (var cMap = new ScratchImage(inputImage.Metadata))
77 | using (var sMap = new ScratchImage(inputImage.Metadata))
78 | {
79 | for (int x = 0; x < inputImage.Width; x++)
80 | {
81 | for (int y = 0; y < inputImage.Height; y++)
82 | {
83 | // Get Pixel
84 | var pixel = inputImage.GetPixel(0, 0, 0, x, y);
85 |
86 | // Compute Metal/Diffuse Mask Values
87 | var m = MathUtilities.Clamp(pixel.W - insulatorSpecRange, 1.0f, 0.0f) * (1.0f / (1.0f - insulatorSpecRange));
88 | var d = MathUtilities.Clamp(1.0f - m, 1.0f, 0.0f);
89 | var r = Math.Min(pixel.W, insulatorSpecRange);
90 |
91 | // Set pixels, clamped to 56/56/56
92 | cMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.X * d, pixel.Y * d, pixel.Z * d, 1.0f));
93 | sMap.SetPixel(0, 0, 0, x, y, new Vector4(Math.Max(r + m * pixel.X, 0.21f), Math.Max(r + m * pixel.Y, 0.21f), Math.Max(r + m * pixel.Z, 0.21f), 1.0f));
94 | }
95 | }
96 |
97 | // Convert to desired DXGI format for DDS
98 | if(ext == ".DDS")
99 | {
100 | cMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
101 | sMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
102 | }
103 |
104 | cMap.Save(outputPath + "_c" + ext);
105 | sMap.Save(outputPath + "_s" + ext);
106 | }
107 | }
108 | }
109 |
110 | ///
111 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
112 | ///
113 | /// File to process
114 | /// Config with settings
115 | /// True if we can, otherwise False
116 | public bool CanProcessFile(string file, FileProcessorConfig config)
117 | {
118 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
119 | return false;
120 |
121 | // Check directory names
122 | if(CheckDirectoryName)
123 | if(!file.Contains("modern_warfare_4") && !file.Contains("infinite_warfare"))
124 | return false;
125 |
126 | // Check for Modern Warfare's String
127 | if(file.Contains("_c&") || file.Contains("_s~"))
128 | return true;
129 |
130 | // Check for Infinite Warfare's String
131 | if(file.Contains("packed_cs"))
132 | return true;
133 |
134 | return false;
135 | }
136 |
137 | ///
138 | /// Returns a string that represents the current object.
139 | ///
140 | /// A string that represents the current object.
141 | public override string ToString()
142 | {
143 | return Name;
144 | }
145 | }
146 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/CoDMW2RBlueImageProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.IO;
20 | using System.Numerics;
21 | using PhilLibX.Imaging;
22 |
23 | namespace GameImageUtil
24 | {
25 | ///
26 | /// A class to handle splitting R/G/B from MW2R Blue Image
27 | ///
28 | public class CoDMW2RBlueImageProcessor : IFileProcessor
29 | {
30 | ///
31 | /// Gets the ID of this Processor
32 | ///
33 | public string ID { get { return "CoDMW2RBlueImageProcessor"; } }
34 |
35 | ///
36 | /// Gets the Name of this Processor
37 | ///
38 | public string Name { get { return "CoD S/G/O (Blue Image) (Modern Warfare 2 Remastered)"; } }
39 |
40 | ///
41 | /// Processes the provided image
42 | ///
43 | /// File to process
44 | /// Config with settings
45 | public void Process(string file, FileProcessorConfig config)
46 | {
47 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
48 | return;
49 |
50 | using (var inputImage = new ScratchImage(file))
51 | {
52 | var ext = config.GetValue("Extension", ".PNG");
53 | var dxgi = config.GetValue("DXGIFormat", 77);
54 | var outputPath = config.GetValue("OutputPath", "");
55 |
56 | if (string.IsNullOrWhiteSpace(outputPath))
57 | outputPath = Path.Combine(Path.GetDirectoryName(file), string.Join("_", Path.GetFileNameWithoutExtension(file).Split(new string[] { "~", "" }, StringSplitOptions.RemoveEmptyEntries)).Replace('~', '_').Replace('&', '_').Replace('$', '_').Replace('-', '_'));
58 |
59 | // Force the image to a standard format
60 | inputImage.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
61 |
62 | using (var rMap = new ScratchImage(inputImage.Metadata))
63 | using (var gMap = new ScratchImage(inputImage.Metadata))
64 | using (var bMap = new ScratchImage(inputImage.Metadata))
65 | {
66 | for (int x = 0; x < inputImage.Width; x++)
67 | {
68 | for (int y = 0; y < inputImage.Height; y++)
69 | {
70 | // Get Pixel
71 | var pixel = inputImage.GetPixel(0, 0, 0, x, y);
72 |
73 | rMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.X, pixel.X, pixel.X, 1.0f));
74 | gMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.Y, pixel.Y, pixel.Y, 1.0f));
75 | bMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.Z, pixel.Z, pixel.Z, 1.0f));
76 | }
77 | }
78 |
79 | if (ext == ".dds")
80 | {
81 | rMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
82 | gMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
83 | bMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
84 | }
85 |
86 | rMap.Save(outputPath + "_s" + ext);
87 | gMap.Save(outputPath + "_g" + ext);
88 | bMap.Save(outputPath + "_o" + ext);
89 | }
90 | }
91 | }
92 |
93 | ///
94 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
95 | ///
96 | /// File to process
97 | /// Config with settings
98 | /// True if we can, otherwise False
99 | public bool CanProcessFile(string file, FileProcessorConfig config)
100 | {
101 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
102 | return false;
103 |
104 | return false;
105 | }
106 |
107 | ///
108 | /// Returns a string that represents the current object.
109 | ///
110 | /// A string that represents the current object.
111 | public override string ToString()
112 | {
113 | return Name;
114 | }
115 | }
116 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/CoDNOGImageProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.IO;
20 | using System.Numerics;
21 | using PhilLibX.Imaging;
22 |
23 | namespace GameImageUtil
24 | {
25 | ///
26 | /// A class to handle processing CoD NOG Images (Infinite Warfare/Modern Warfare)
27 | /// They are stored as follows:
28 | /// Gloss Map
29 | /// Normal X (Hemi-Octahedron)
30 | /// Occlusion
31 | /// Normal Y (Hemi-Octahedron)
32 | /// References:
33 | /// https://www.activision.com/cdn/research/2017_DD_Rendering_of_COD_IW.pdf
34 | /// http://jcgt.org/published/0003/02/01/
35 | /// http://media.steampowered.com/apps/valve/2015/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf
36 | /// RenderDoc for Shader Debugging
37 | ///
38 | public class CoDNOGProcessor : IFileProcessor
39 | {
40 | ///
41 | /// Gets the ID of this Processor
42 | ///
43 | public string ID { get { return "CoDNOGProcessor"; } }
44 |
45 | ///
46 | /// Gets the Name of this Processor
47 | ///
48 | public string Name { get { return "CoD Normal/Gloss/Occlusion (Infinite Warfare/Modern Warfare)"; } }
49 |
50 | ///
51 | /// Whether or not to check the directory for "infinite_warfare"/"modern_warfare_4"
52 | ///
53 | public bool CheckDirectoryName { get { return false; } }
54 |
55 | ///
56 | /// Processes the provided image
57 | ///
58 | /// File to process
59 | /// Config with settings
60 | public void Process(string file, FileProcessorConfig config)
61 | {
62 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
63 | return;
64 |
65 | using (var inputImage = new ScratchImage(file))
66 | {
67 | var ext = config.GetValue("Extension", ".PNG");
68 | var dxgi = config.GetValue("DXGIFormat", 77);
69 | var outputPath = config.GetValue("OutputPath", "");
70 |
71 | if(string.IsNullOrWhiteSpace(outputPath))
72 | outputPath = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file).Split(new string[] { "_n&", "_n_" }, StringSplitOptions.None)[0]);
73 |
74 | // Force the image to a standard format
75 | inputImage.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
76 |
77 | using (var gMap = new ScratchImage(inputImage.Metadata))
78 | using (var oMap = new ScratchImage(inputImage.Metadata))
79 | using (var nMap = new ScratchImage(inputImage.Metadata))
80 | {
81 | for (int x = 0; x < inputImage.Width; x++)
82 | {
83 | for (int y = 0; y < inputImage.Height; y++)
84 | {
85 | // Get Pixel
86 | var pixel = inputImage.GetPixel(0, 0, 0, x, y);
87 |
88 | // Get Normal and rotate and scale the unit square back to the center diamond
89 | var normalVector = new Vector2(pixel.Y * 2.0f - 1.0f, pixel.W * 2.0f - 1.0f);
90 | var xy = new Vector2(normalVector.X + normalVector.Y, normalVector.X - normalVector.Y) * 0.5f;
91 | var xyz = Vector3.Normalize(new Vector3(xy, 1.0f - Math.Abs(xy.X) - Math.Abs(xy.Y)));
92 |
93 | // Set new pixels
94 | gMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.X, pixel.X, pixel.X, 1.0f));
95 | oMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.Z, pixel.Z, pixel.Z, 1.0f));
96 | nMap.SetPixel(0, 0, 0, x, y, new Vector4(xyz.X * 0.5f + 0.5f, xyz.Y * 0.5f + 0.5f, xyz.Z * 0.5f + 0.5f, 1.0f));
97 | }
98 | }
99 |
100 | // Convert to desired DXGI format for DDS
101 | if(ext == ".DDS")
102 | {
103 | gMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
104 | oMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
105 | nMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
106 | }
107 |
108 | gMap.Save(outputPath + "_g" + ext);
109 | oMap.Save(outputPath + "_o" + ext);
110 | nMap.Save(outputPath + "_n" + ext);
111 | }
112 | }
113 | }
114 |
115 | ///
116 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
117 | ///
118 | /// File to process
119 | /// Config with settings
120 | /// True if we can, otherwise False
121 | public bool CanProcessFile(string file, FileProcessorConfig config)
122 | {
123 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
124 | return false;
125 |
126 | // Check directory names
127 | if(CheckDirectoryName)
128 | if(!file.Contains("modern_warfare_4") && !file.Contains("infinite_warfare"))
129 | return false;
130 |
131 | // Check for Modern Warfare's String
132 | if(file.Contains("_n&") || file.Contains("_g~"))
133 | return true;
134 |
135 | // Check for Infinite Warfare's String
136 | if(file.Contains("packed_ng") || file.Contains("packed_nog"))
137 | return true;
138 |
139 | return false;
140 | }
141 |
142 | ///
143 | /// Returns a string that represents the current object.
144 | ///
145 | /// A string that represents the current object.
146 | public override string ToString()
147 | {
148 | return Name;
149 | }
150 | }
151 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/CoDSpecGlossProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.IO;
20 | using System.Numerics;
21 | using PhilLibX.Imaging;
22 |
23 | namespace GameImageUtil
24 | {
25 | ///
26 | /// A class to handle splitting RGB/A from Spec/Gloss CoD Images
27 | ///
28 | public class CoDSpecGlossProcessor : IFileProcessor
29 | {
30 | ///
31 | /// Gets the ID of this Processor
32 | ///
33 | public string ID { get { return "CoDSpecGlossProcessor"; } }
34 |
35 | ///
36 | /// Gets the Name of this Processor
37 | ///
38 | public string Name { get { return "CoD Spec/Gloss (RGB/A) (Multiple CoDs)"; } }
39 |
40 | ///
41 | /// Processes the provided image
42 | ///
43 | /// File to process
44 | /// Config with settings
45 | public void Process(string file, FileProcessorConfig config)
46 | {
47 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
48 | return;
49 |
50 | using (var inputImage = new ScratchImage(file))
51 | {
52 | var ext = config.GetValue("Extension", ".PNG");
53 | var dxgi = config.GetValue("DXGIFormat", 77);
54 | var outputPath = config.GetValue("OutputPath", "");
55 |
56 | if (string.IsNullOrWhiteSpace(outputPath))
57 | outputPath = Path.Combine(Path.GetDirectoryName(file), string.Join("_", Path.GetFileNameWithoutExtension(file).Split(new string[] { "~", "" }, StringSplitOptions.RemoveEmptyEntries)).Replace('~', '_').Replace('&', '_').Replace('$', '_').Replace('-', '_'));
58 |
59 | // Force the image to a standard format
60 | inputImage.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
61 |
62 | using (var rgbMap = new ScratchImage(inputImage.Metadata))
63 | using (var alphaMap = new ScratchImage(inputImage.Metadata))
64 | {
65 | for (int x = 0; x < inputImage.Width; x++)
66 | {
67 | for (int y = 0; y < inputImage.Height; y++)
68 | {
69 | // Get Pixel
70 | var pixel = inputImage.GetPixel(0, 0, 0, x, y);
71 |
72 | rgbMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.X, pixel.Y, pixel.Z, 1.0f));
73 | alphaMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.W, pixel.W, pixel.W, 1.0f));
74 | }
75 | }
76 |
77 | if (ext == ".dds")
78 | {
79 | rgbMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
80 | alphaMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
81 | }
82 |
83 | rgbMap.Save(outputPath + "_s" + ext);
84 | alphaMap.Save(outputPath + "_g" + ext);
85 | }
86 | }
87 | }
88 |
89 | ///
90 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
91 | ///
92 | /// File to process
93 | /// Config with settings
94 | /// True if we can, otherwise False
95 | public bool CanProcessFile(string file, FileProcessorConfig config)
96 | {
97 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
98 | return false;
99 |
100 | return false;
101 | }
102 |
103 | ///
104 | /// Returns a string that represents the current object.
105 | ///
106 | /// A string that represents the current object.
107 | public override string ToString()
108 | {
109 | return Name;
110 | }
111 | }
112 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/CoDSplitCSProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.IO;
20 | using System.Numerics;
21 | using PhilLibX;
22 | using PhilLibX.Imaging;
23 |
24 | namespace GameImageUtil
25 | {
26 | ///
27 | /// A class to handle processing CoD CS Images (World War II)
28 | /// They are stored as follows:
29 | /// Fused Diffuse/Specular Color
30 | /// Metalness Mask
31 | /// References:
32 | /// https://www.activision.com/cdn/research/2017_DD_Rendering_of_COD_IW.pdf
33 | /// RenderDoc for Shader Debugging
34 | ///
35 | public class CoDSplitCSProcessor : IFileProcessor
36 | {
37 | ///
38 | /// Gets the ID of this Processor
39 | ///
40 | public string ID { get { return "CoDSplitCSProcessor"; } }
41 |
42 | ///
43 | /// Gets the Name of this Processor
44 | ///
45 | public string Name { get { return "CoD Specular/Albedo (World War II)"; } }
46 |
47 | ///
48 | /// Processes the provided image
49 | ///
50 | /// File to process
51 | /// Config with settings
52 | public void Process(string file, FileProcessorConfig config)
53 | {
54 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
55 | return;
56 |
57 | var maskPath = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file) + "_s" + Path.GetExtension(file));
58 |
59 | if (!File.Exists(maskPath))
60 | throw new ArgumentException("Failed to locate mask image for CoDSplitCSProcessor", "maskPath");
61 |
62 | using (var inputImage = new ScratchImage(file))
63 | using (var maskImage = new ScratchImage(maskPath))
64 | {
65 | var ext = config.GetValue("Extension", ".PNG");
66 | var dxgi = config.GetValue("DXGIFormat", 77);
67 | var outputPath = config.GetValue("OutputPath", "");
68 |
69 | if (string.IsNullOrWhiteSpace(outputPath))
70 | outputPath = Path.Combine(Path.GetDirectoryName(file), string.Join("_", Path.GetFileNameWithoutExtension(file).Replace("~&-", "").Split(new string[] { "~" }, StringSplitOptions.None)).Replace('~', '_').Replace('&', '_').Replace('$', '_').Replace('-', '_'));
71 |
72 | // Force the image to a standard format
73 | inputImage.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
74 | maskImage.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
75 |
76 | // Force mask image size
77 | maskImage.Resize(inputImage.Width, inputImage.Height);
78 |
79 | const float insulatorSpecRange = 0.1f;
80 |
81 | using (var cMap = new ScratchImage(inputImage.Metadata))
82 | using (var sMap = new ScratchImage(inputImage.Metadata))
83 | {
84 | for (int x = 0; x < inputImage.Width; x++)
85 | {
86 | for (int y = 0; y < inputImage.Height; y++)
87 | {
88 | // Get Pixel
89 | var pixel = inputImage.GetPixel(0, 0, 0, x, y);
90 | var maskPixel = maskImage.GetPixel(0, 0, 0, x, y);
91 |
92 | // Compute Metal/Diffuse Mask Values
93 | var m = MathUtilities.Clamp(maskPixel.X - insulatorSpecRange, 1.0f, 0.0f) * (1.0f / (1.0f - insulatorSpecRange));
94 | var d = MathUtilities.Clamp(1.0f - m, 1.0f, 0.0f);
95 | var r = Math.Min(maskPixel.W, insulatorSpecRange);
96 |
97 | // Set pixels, clamped to 56/56/56
98 | cMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.X * d, pixel.Y * d, pixel.Z * d, pixel.W));
99 | sMap.SetPixel(0, 0, 0, x, y, new Vector4(Math.Max(r + m * pixel.X, 0.21f), Math.Max(r + m * pixel.Y, 0.21f), Math.Max(r + m * pixel.Z, 0.21f), 1.0f));
100 | }
101 | }
102 |
103 | // Convert to desired DXGI format for DDS
104 | if(ext == ".DDS")
105 | {
106 | cMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
107 | sMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
108 | }
109 |
110 | cMap.Save(outputPath + "_c" + ext);
111 | sMap.Save(outputPath + "_s" + ext);
112 | }
113 | }
114 | }
115 |
116 | ///
117 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
118 | ///
119 | /// File to process
120 | /// Config with settings
121 | /// True if we can, otherwise False
122 | public bool CanProcessFile(string file, FileProcessorConfig config)
123 | {
124 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
125 | return false;
126 |
127 | return false;
128 | }
129 |
130 | ///
131 | /// Returns a string that represents the current object.
132 | ///
133 | /// A string that represents the current object.
134 | public override string ToString()
135 | {
136 | return Name;
137 | }
138 | }
139 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/CoDWW2GreenImageProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.IO;
20 | using System.Numerics;
21 | using PhilLibX.Imaging;
22 |
23 | namespace GameImageUtil
24 | {
25 | ///
26 | /// A class to handle splitting R/G/B from WW2 Green Image
27 | ///
28 | public class CoDWW2GreenImageProcessor : IFileProcessor
29 | {
30 | ///
31 | /// Gets the ID of this Processor
32 | ///
33 | public string ID { get { return "CoDMW2RBlueImageProcessor"; } }
34 |
35 | ///
36 | /// Gets the Name of this Processor
37 | ///
38 | public string Name { get { return "CoD S/G/O (Green Image) (World War II)"; } }
39 |
40 | ///
41 | /// Processes the provided image
42 | ///
43 | /// File to process
44 | /// Config with settings
45 | public void Process(string file, FileProcessorConfig config)
46 | {
47 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
48 | return;
49 |
50 | using (var inputImage = new ScratchImage(file))
51 | {
52 | var ext = config.GetValue("Extension", ".PNG");
53 | var dxgi = config.GetValue("DXGIFormat", 77);
54 | var outputPath = config.GetValue("OutputPath", "");
55 |
56 | if (string.IsNullOrWhiteSpace(outputPath))
57 | outputPath = Path.Combine(Path.GetDirectoryName(file), string.Join("_", Path.GetFileNameWithoutExtension(file).Replace("~&-", "").Split(new string[] { "~" }, StringSplitOptions.None)).Replace('~', '_').Replace('&', '_').Replace('$', '_').Replace('-', '_'));
58 |
59 | // Force the image to a standard format
60 | inputImage.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
61 |
62 | using (var rMap = new ScratchImage(inputImage.Metadata))
63 | using (var gMap = new ScratchImage(inputImage.Metadata))
64 | using (var bMap = new ScratchImage(inputImage.Metadata))
65 | {
66 | for (int x = 0; x < inputImage.Width; x++)
67 | {
68 | for (int y = 0; y < inputImage.Height; y++)
69 | {
70 | // Get Pixel
71 | var pixel = inputImage.GetPixel(0, 0, 0, x, y);
72 |
73 | rMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.X, pixel.X, pixel.X, 1.0f));
74 | gMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.Y, pixel.Y, pixel.Y, 1.0f));
75 | bMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.Z, pixel.Z, pixel.Z, 1.0f));
76 | }
77 | }
78 |
79 | if (ext == ".dds")
80 | {
81 | rMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
82 | gMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
83 | bMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
84 | }
85 |
86 | rMap.Save(outputPath + "_s" + ext);
87 | gMap.Save(outputPath + "_o" + ext);
88 | bMap.Save(outputPath + "_g" + ext);
89 | }
90 | }
91 | }
92 |
93 | ///
94 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
95 | ///
96 | /// File to process
97 | /// Config with settings
98 | /// True if we can, otherwise False
99 | public bool CanProcessFile(string file, FileProcessorConfig config)
100 | {
101 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
102 | return false;
103 |
104 | return false;
105 | }
106 |
107 | ///
108 | /// Returns a string that represents the current object.
109 | ///
110 | /// A string that represents the current object.
111 | public override string ToString()
112 | {
113 | return Name;
114 | }
115 | }
116 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/CoDXYNormalMapProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.IO;
20 | using System.Numerics;
21 | using PhilLibX.Imaging;
22 |
23 | namespace GameImageUtil
24 | {
25 | ///
26 | /// A class to handle reconstructing Z component of a DXT5 XY normal map
27 | /// where the one component is stored in the A channel and another in G
28 | ///
29 | public class CoDXYNormalMapProcessor : IFileProcessor
30 | {
31 | ///
32 | /// Gets the ID of this Processor
33 | ///
34 | public string ID { get { return "CoDXYNormalMapProcessor"; } }
35 |
36 | ///
37 | /// Gets the Name of this Processor
38 | ///
39 | public string Name { get { return "CoD Greyscale XY Normal Map w/ Alpha (MW/WaW/MW2/MW3/BO1)"; } }
40 |
41 | ///
42 | /// Processes the provided image
43 | ///
44 | /// File to process
45 | /// Config with settings
46 | public void Process(string file, FileProcessorConfig config)
47 | {
48 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
49 | return;
50 |
51 | using (var image = new ScratchImage(file))
52 | {
53 | var ext = config.GetValue("Extension", ".PNG");
54 | var dxgi = config.GetValue("DXGIFormat", 77);
55 | var outputPath = config.GetValue("OutputPath", "");
56 |
57 | if (string.IsNullOrWhiteSpace(outputPath))
58 | outputPath = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file));
59 |
60 | // Force the image to a standard format
61 | image.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
62 |
63 | for (int x = 0; x < image.Width; x++)
64 | {
65 | for (int y = 0; y < image.Height; y++)
66 | {
67 | // Get Pixel
68 | var pixel = image.GetPixel(0, 0, 0, x, y);
69 |
70 | var nX = pixel.W * 2.0f - 1.0f;
71 | var nY = pixel.Y * 2.0f - 1.0f;
72 | var nZ = 1.0f - (nX * nX) - (nY * nY);
73 |
74 | image.SetPixel(0, 0, 0, x, y, new Vector4(nX * 0.5f + 0.5f, nY * 0.5f + 0.5f, nZ > 0.0f ? (float)Math.Sqrt(nZ) * 0.5f + 0.5f : 0.0f, 1.0f));
75 | }
76 | }
77 |
78 | if (ext == ".dds")
79 | image.ConvertImage((ScratchImage.DXGIFormat)dxgi);
80 |
81 | image.Save(outputPath + ext);
82 | }
83 | }
84 |
85 | ///
86 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
87 | ///
88 | /// File to process
89 | /// Config with settings
90 | /// True if we can, otherwise False
91 | public bool CanProcessFile(string file, FileProcessorConfig config)
92 | {
93 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
94 | return false;
95 |
96 | return false;
97 | }
98 |
99 | ///
100 | /// Returns a string that represents the current object.
101 | ///
102 | /// A string that represents the current object.
103 | public override string ToString()
104 | {
105 | return Name;
106 | }
107 | }
108 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/DirectConvertProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System.IO;
19 | using PhilLibX.Imaging;
20 |
21 | namespace GameImageUtil
22 | {
23 | ///
24 | /// A class to handle converting images
25 | ///
26 | public class DirectConvertProcessor : IFileProcessor
27 | {
28 | ///
29 | /// Gets the ID of this Processor
30 | ///
31 | public string ID { get { return "DirectConvertProcessor"; } }
32 |
33 | ///
34 | /// Gets the Name of this Processor
35 | ///
36 | public string Name { get { return "Direct Convert (Global)"; } }
37 |
38 | ///
39 | /// Processes the provided image
40 | ///
41 | /// File to process
42 | /// Config with settings
43 | public void Process(string file, FileProcessorConfig config)
44 | {
45 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
46 | return;
47 |
48 | using (var image = new ScratchImage(file))
49 | {
50 | var ext = config.GetValue("Extension", ".PNG");
51 | var dxgi = config.GetValue("DXGIFormat", 77);
52 | var outputPath = config.GetValue("OutputPath", "");
53 |
54 | if (string.IsNullOrWhiteSpace(outputPath))
55 | outputPath = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file));
56 |
57 | // Force the image to a standard format
58 | image.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
59 |
60 | if (ext == ".dds")
61 | image.ConvertImage((ScratchImage.DXGIFormat)dxgi);
62 |
63 | image.Save(outputPath + ext);
64 | }
65 | }
66 |
67 | ///
68 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
69 | ///
70 | /// File to process
71 | /// Config with settings
72 | /// True if we can, otherwise False
73 | public bool CanProcessFile(string file, FileProcessorConfig config)
74 | {
75 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
76 | return true;
77 |
78 | return false;
79 | }
80 |
81 | ///
82 | /// Returns a string that represents the current object.
83 | ///
84 | /// A string that represents the current object.
85 | public override string ToString()
86 | {
87 | return Name;
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/MergeRGBAProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.IO;
20 | using System.Numerics;
21 | using PhilLibX.Imaging;
22 |
23 | namespace GameImageUtil
24 | {
25 | ///
26 | /// A class to handle merging RGB and Alpha together
27 | ///
28 | public class MergeRGBAProcessor : IFileProcessor
29 | {
30 | ///
31 | /// Gets the ID of this Processor
32 | ///
33 | public string ID { get { return "MergeRGBAProcessor"; } }
34 |
35 | ///
36 | /// Gets the Name of this Processor
37 | ///
38 | public string Name { get { return "Merge RGB/Alpha (Global)"; } }
39 |
40 | ///
41 | /// Processes the provided image
42 | ///
43 | /// File to process
44 | /// Config with settings
45 | public void Process(string file, FileProcessorConfig config)
46 | {
47 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
48 | return;
49 |
50 | var alphaPath = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file) + "_a" + Path.GetExtension(file));
51 |
52 | if (!File.Exists(alphaPath))
53 | throw new ArgumentException("Failed to locate alpha image for MergeRGBAProcessor", "alphaPath");
54 |
55 | using (var inputImage = new ScratchImage(file))
56 | using (var alphaImage = new ScratchImage(alphaPath))
57 | {
58 | var ext = config.GetValue("Extension", ".PNG");
59 | var dxgi = config.GetValue("DXGIFormat", 77);
60 | var outputPath = config.GetValue("OutputPath", "");
61 |
62 | if (string.IsNullOrWhiteSpace(outputPath))
63 | outputPath = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file).Split(new string[] { "_n&", "_n_" }, StringSplitOptions.None)[0]);
64 |
65 | // Force the image to a standard format
66 | inputImage.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
67 | alphaImage.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
68 |
69 | // Force mask image size
70 | alphaImage.Resize(inputImage.Width, inputImage.Height);
71 |
72 | using (var result = new ScratchImage(inputImage.Metadata))
73 | {
74 | for (int x = 0; x < inputImage.Width; x++)
75 | {
76 | for (int y = 0; y < inputImage.Height; y++)
77 | {
78 | // Get Pixel
79 | var pixel = inputImage.GetPixel(0, 0, 0, x, y);
80 | var maskPixel = alphaImage.GetPixel(0, 0, 0, x, y);
81 |
82 | // Set pixels
83 | result.SetPixel(0, 0, 0, x, y, new Vector4(pixel.X, pixel.Y, pixel.Z, maskPixel.X));
84 | }
85 | }
86 |
87 | // Convert to desired DXGI format for DDS
88 | if (ext == ".DDS")
89 | result.ConvertImage((ScratchImage.DXGIFormat)dxgi);
90 |
91 | result.Save(outputPath + ext);
92 | }
93 | }
94 | }
95 |
96 | ///
97 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
98 | ///
99 | /// File to process
100 | /// Config with settings
101 | /// True if we can, otherwise False
102 | public bool CanProcessFile(string file, FileProcessorConfig config)
103 | {
104 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
105 | return false;
106 |
107 | return false;
108 | }
109 |
110 | ///
111 | /// Returns a string that represents the current object.
112 | ///
113 | /// A string that represents the current object.
114 | public override string ToString()
115 | {
116 | return Name;
117 | }
118 | }
119 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/SplitColorAlphaProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.IO;
20 | using System.Numerics;
21 | using PhilLibX.Imaging;
22 |
23 | namespace GameImageUtil
24 | {
25 | ///
26 | /// A class to handle splitting RGB/A
27 | ///
28 | public class SplitColorAlphaProcessor : IFileProcessor
29 | {
30 | ///
31 | /// Gets the ID of this Processor
32 | ///
33 | public string ID { get { return "SplitColorAlphaProcessor"; } }
34 |
35 | ///
36 | /// Gets the Name of this Processor
37 | ///
38 | public string Name { get { return "Split Color/Alpha (Global)"; } }
39 |
40 | ///
41 | /// Processes the provided image
42 | ///
43 | /// File to process
44 | /// Config with settings
45 | public void Process(string file, FileProcessorConfig config)
46 | {
47 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
48 | return;
49 |
50 | using (var inputImage = new ScratchImage(file))
51 | {
52 | var ext = config.GetValue("Extension", ".PNG");
53 | var dxgi = config.GetValue("DXGIFormat", 77);
54 | var outputPath = config.GetValue("OutputPath", "");
55 |
56 | if (string.IsNullOrWhiteSpace(outputPath))
57 | outputPath = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file));
58 |
59 | // Force the image to a standard format
60 | inputImage.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
61 |
62 | using (var rgbMap = new ScratchImage(inputImage.Metadata))
63 | using (var alphaMap = new ScratchImage(inputImage.Metadata))
64 | {
65 | for (int x = 0; x < inputImage.Width; x++)
66 | {
67 | for (int y = 0; y < inputImage.Height; y++)
68 | {
69 | // Get Pixel
70 | var pixel = inputImage.GetPixel(0, 0, 0, x, y);
71 |
72 | rgbMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.X, pixel.Y, pixel.Z, 1.0f));
73 | alphaMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.W, pixel.W, pixel.W, 1.0f));
74 | }
75 | }
76 |
77 | if (ext == ".dds")
78 | {
79 | rgbMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
80 | alphaMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
81 | }
82 |
83 | rgbMap.Save(outputPath + "_rgb" + ext);
84 | alphaMap.Save(outputPath + "_alpha" + ext);
85 | }
86 | }
87 | }
88 |
89 | ///
90 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
91 | ///
92 | /// File to process
93 | /// Config with settings
94 | /// True if we can, otherwise False
95 | public bool CanProcessFile(string file, FileProcessorConfig config)
96 | {
97 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
98 | return false;
99 |
100 | return false;
101 | }
102 |
103 | ///
104 | /// Returns a string that represents the current object.
105 | ///
106 | /// A string that represents the current object.
107 | public override string ToString()
108 | {
109 | return Name;
110 | }
111 | }
112 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/data/scripts/SplitRGBAProcessor.cs_script:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------------------
2 | // GameImageUtil - Tool to process game images
3 | // Copyright (C) 2020 Philip/Scobalula
4 | //
5 | // This program is free software: you can redistribute it and/or modify
6 | // it under the terms of the GNU General Public License as published by
7 | // the Free Software Foundation, either version 3 of the License, or
8 | // (at your option) any later version.
9 |
10 | // This program is distributed in the hope that it will be useful,
11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | // GNU General Public License for more details.
14 |
15 | // You should have received a copy of the GNU General Public License
16 | // along with this program. If not, see .
17 | // ------------------------------------------------------------------------
18 | using System;
19 | using System.IO;
20 | using System.Numerics;
21 | using PhilLibX.Imaging;
22 |
23 | namespace GameImageUtil
24 | {
25 | ///
26 | /// A class to handle splitting R/G/B/A
27 | ///
28 | public class SplitAllChannelsProcessor : IFileProcessor
29 | {
30 | ///
31 | /// Gets the ID of this Processor
32 | ///
33 | public string ID { get { return "SplitAllChannelsProcessor"; } }
34 |
35 | ///
36 | /// Gets the Name of this Processor
37 | ///
38 | public string Name { get { return "Split All Channels (Global)"; } }
39 |
40 | ///
41 | /// Processes the provided image
42 | ///
43 | /// File to process
44 | /// Config with settings
45 | public void Process(string file, FileProcessorConfig config)
46 | {
47 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
48 | return;
49 |
50 | using (var inputImage = new ScratchImage(file))
51 | {
52 | var ext = config.GetValue("Extension", ".PNG");
53 | var dxgi = config.GetValue("DXGIFormat", 77);
54 | var outputPath = config.GetValue("OutputPath", "");
55 |
56 | if (string.IsNullOrWhiteSpace(outputPath))
57 | outputPath = Path.Combine(Path.GetDirectoryName(file), Path.GetFileNameWithoutExtension(file));
58 |
59 | // Force the image to a standard format
60 | inputImage.ConvertImage(ScratchImage.DXGIFormat.R8G8B8A8UNORM);
61 |
62 | using (var rMap = new ScratchImage(inputImage.Metadata))
63 | using (var gMap = new ScratchImage(inputImage.Metadata))
64 | using (var bMap = new ScratchImage(inputImage.Metadata))
65 | using (var aMap = new ScratchImage(inputImage.Metadata))
66 | {
67 | for (int x = 0; x < inputImage.Width; x++)
68 | {
69 | for (int y = 0; y < inputImage.Height; y++)
70 | {
71 | // Get Pixel
72 | var pixel = inputImage.GetPixel(0, 0, 0, x, y);
73 |
74 | rMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.X, pixel.X, pixel.X, 1.0f));
75 | gMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.Y, pixel.Y, pixel.Y, 1.0f));
76 | bMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.Z, pixel.Z, pixel.Z, 1.0f));
77 | aMap.SetPixel(0, 0, 0, x, y, new Vector4(pixel.W, pixel.W, pixel.W, 1.0f));
78 | }
79 | }
80 |
81 | if (ext == ".dds")
82 | {
83 | rMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
84 | gMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
85 | bMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
86 | aMap.ConvertImage((ScratchImage.DXGIFormat)dxgi);
87 | }
88 |
89 | rMap.Save(outputPath + "_r" + ext);
90 | gMap.Save(outputPath + "_g" + ext);
91 | bMap.Save(outputPath + "_b" + ext);
92 | aMap.Save(outputPath + "_a" + ext);
93 | }
94 | }
95 | }
96 |
97 | ///
98 | /// Checks if we can process this file, this is used by the Automatic Processor and does not affect manually selected modes
99 | ///
100 | /// File to process
101 | /// Config with settings
102 | /// True if we can, otherwise False
103 | public bool CanProcessFile(string file, FileProcessorConfig config)
104 | {
105 | if(!config.ViewModel.Extensions.Contains(Path.GetExtension(file).ToUpper()))
106 | return false;
107 |
108 | return false;
109 | }
110 |
111 | ///
112 | /// Returns a string that represents the current object.
113 | ///
114 | /// A string that represents the current object.
115 | public override string ToString()
116 | {
117 | return Name;
118 | }
119 | }
120 | }
--------------------------------------------------------------------------------
/src/GameImageUtil/GameImageUtil/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------