Created
August 12, 2014 10:56
-
-
Save elliotwoods/83767a5bc9db3b2c51be to your computer and use it in GitHub Desktop.
old dds implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void MainLoop_OnPresent(object sender, EventArgs e) | |
{ | |
if (FInWrite[0] && FInstance.Ready) | |
{ | |
try | |
{ | |
var data = FInstance.ReadBack(FInStorageFormat[0]); | |
if (data == null || data.Length < 16) | |
{ | |
throw (new Exception("No data available")); | |
} | |
var file = new FileStream(FInFilename[0], FileMode.Create); | |
var writer = new BinaryWriter(file); | |
writer.Write((UInt32)0x20534444); | |
writer.Write((UInt32)124); | |
writer.Write((UInt32)(0x1 | 0x2 | 0x4 | 0x1000)); | |
writer.Write((UInt32)FInstance.Height); | |
writer.Write((UInt32)FInstance.Width); | |
writer.Write((UInt32)Math.Max(1, ((FInstance.Width + 3) / 4) * 4)); | |
writer.Write((UInt32)0); | |
writer.Write((UInt32)0); | |
for (int i = 0; i < 11; i++) | |
{ | |
writer.Write((UInt32)0); | |
} | |
writer.Write(32); | |
writer.Write((UInt32)(0x1 | 0x4)); | |
writer.Write((UInt32)('D' << 24 | 'X' << 16 | 'T' << 8 | '1')); | |
writer.Write((UInt32)(0)); | |
writer.Write((UInt32)(0x00ff0000)); | |
writer.Write((UInt32)(0x0000ff00)); | |
writer.Write((UInt32)(0x000000ff)); | |
writer.Write((UInt32)(0xff000000)); | |
writer.Write((UInt32)(0x1000)); | |
writer.Write((UInt32)(0)); | |
writer.Write((UInt32)(0)); | |
writer.Write((UInt32)(0)); | |
writer.Write((UInt32)(0)); | |
writer.Write(data); | |
writer.Close(); | |
file.Close(); | |
FOutStatus[0] = "OK"; | |
} | |
catch(Exception ex) | |
{ | |
FOutStatus[0] = ex.Message; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment