Last change
on this file since 1134 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:
978 bytes
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 |
|
---|
4 | namespace Oni.Imaging
|
---|
5 | {
|
---|
6 | internal static class DdsReader
|
---|
7 | {
|
---|
8 | public static List<Surface> Read(string filePath, bool noMipMaps)
|
---|
9 | {
|
---|
10 | var surfaces = new List<Surface>();
|
---|
11 |
|
---|
12 | using (var reader = new BinaryReader(filePath))
|
---|
13 | {
|
---|
14 | var header = DdsHeader.Read(reader);
|
---|
15 | var format = header.GetSurfaceFormat();
|
---|
16 |
|
---|
17 | for (int i = 0; i < header.MipmapCount; i++)
|
---|
18 | {
|
---|
19 | int width = Math.Max(header.Width >> i, 1);
|
---|
20 | int height = Math.Max(header.Height >> i, 1);
|
---|
21 |
|
---|
22 | if (format == SurfaceFormat.DXT1)
|
---|
23 | {
|
---|
24 | width = Math.Max(width, 4);
|
---|
25 | height = Math.Max(height, 4);
|
---|
26 | }
|
---|
27 |
|
---|
28 | var surface = new Surface(width, height, format);
|
---|
29 | reader.Read(surface.Data, 0, surface.Data.Length);
|
---|
30 | surfaces.Add(surface);
|
---|
31 |
|
---|
32 | if (noMipMaps)
|
---|
33 | break;
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | return surfaces;
|
---|
38 | }
|
---|
39 | }
|
---|
40 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.