Skip to content

Commit

Permalink
bake
Browse files Browse the repository at this point in the history
  • Loading branch information
SupinePandora43 committed Nov 29, 2020
1 parent 359b389 commit 753ae9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions GmodUltralight/shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,16 @@ void finishcallback(IntPtr data, View caller, ulong frameId, bool isMainFrame, s
string nameForSave = lua.GetString(2);
Directory.CreateDirectory("./garrysmod/materials/ultralight");
view.GetSurface().GetBitmap().WritePng($"./garrysmod/materials/ultralight/{nameForSave}.png");
Bitmap bitmap = view.GetSurface().GetBitmap();
bitmap.SwapRedBlueChannels();
try
{
bitmap.WritePng($"./garrysmod/materials/ultralight/{nameForSave}.png");
}
finally
{
bitmap.SwapRedBlueChannels();
}
lua.PushSpecial(SPECIAL_TABLES.SPECIAL_GLOB);
lua.GetField(-1, "resource");
lua.GetField(-1, "AddSingleFile");
Expand Down
3 changes: 3 additions & 0 deletions GmodUltralight/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ csprint(tostring(r))
csprint(tostring(g))
csprint(tostring(b))

csprint("Bake")
view:Bake();

csprint("Dispose")
--view:Dispose()
view = null
Expand Down

0 comments on commit 753ae9e

Please sign in to comment.