-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModelWriter.cs
More file actions
41 lines (34 loc) · 945 Bytes
/
ModelWriter.cs
File metadata and controls
41 lines (34 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
namespace tmdl_utility;
public partial class ModelUtility
{
public class ModelWriter : BinaryWriter
{
public ModelWriter(FileStream stream) : base(stream)
{
}
public ModelWriter(MemoryStream stream) : base(stream)
{
}
public void WriteString(string s)
{
Write(System.Text.Encoding.UTF8.GetBytes(s));
}
public void WriteNonSigString(string s)
{
Write(s.Length);
WriteString(s);
}
}
public static byte[] ConvertBgraToRgba(byte[] bytes)
{
if (bytes == null)
throw new Exception("Data block returned null. Make sure the parameters and image properties are correct!");
for (int i = 0; i < bytes.Length; i += 4)
{
var temp = bytes[i];
bytes[i] = bytes[i + 2];
bytes[i + 2] = temp;
}
return bytes;
}
}