Last change
on this file since 1190 was 1114, checked in by iritscen, 5 years ago |
Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.
|
File size:
1.5 KB
|
Rev | Line | |
---|
[1114] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using Oni.Imaging;
|
---|
| 4 |
|
---|
| 5 | namespace Oni.Motoko
|
---|
| 6 | {
|
---|
| 7 | internal class TextureExporter : Exporter
|
---|
| 8 | {
|
---|
| 9 | protected string fileType;
|
---|
| 10 |
|
---|
| 11 | public TextureExporter(InstanceFileManager fileManager, string outputDirPath, string fileType)
|
---|
| 12 | : base(fileManager, outputDirPath)
|
---|
| 13 | {
|
---|
| 14 | this.fileType = fileType;
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | protected override List<InstanceDescriptor> GetSupportedDescriptors(InstanceFile file)
|
---|
| 18 | {
|
---|
| 19 | return file.GetNamedDescriptors(TemplateTag.TXMP);
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | protected override void ExportInstance(InstanceDescriptor descriptor)
|
---|
| 23 | {
|
---|
| 24 | var texture = TextureDatReader.Read(descriptor);
|
---|
| 25 | var filePath = CreateFileName(descriptor, "." + fileType);
|
---|
| 26 |
|
---|
| 27 | switch (fileType)
|
---|
| 28 | {
|
---|
| 29 | case "tga":
|
---|
| 30 | TgaWriter.Write(texture.Surfaces[0], filePath);
|
---|
| 31 | break;
|
---|
| 32 |
|
---|
| 33 | case "dds":
|
---|
| 34 | DdsWriter.Write(texture.Surfaces, filePath);
|
---|
| 35 | break;
|
---|
| 36 |
|
---|
| 37 | case "png":
|
---|
| 38 | case "jpg":
|
---|
| 39 | case "bmp":
|
---|
| 40 | case "tif":
|
---|
| 41 | #if !NETCORE
|
---|
| 42 | SysWriter.Write(texture.Surfaces[0], filePath);
|
---|
| 43 | #endif
|
---|
| 44 | break;
|
---|
| 45 |
|
---|
| 46 | default:
|
---|
| 47 | throw new NotSupportedException(string.Format("Extracting textures as '{0}' is not supported", fileType));
|
---|
| 48 | }
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
| 51 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.