-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command line options to change yaw and pitch angle of thumbnail. …
…Also add animated GIF option.
- Loading branch information
Showing
12 changed files
with
213 additions
and
47 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using NGif.Components; | ||
using SkiaSharp; | ||
using System.IO; | ||
using Voxels.SkiaSharp; | ||
|
||
namespace Voxels.CommandLine { | ||
internal static class Animation { | ||
public static byte[] RenderGif(VoxelData voxelData, RenderSettings renderSettings, int frames, float duration) { | ||
var delay = (int)(duration / frames * 1000); | ||
|
||
var encoder = new AnimatedGifEncoder(); | ||
var memory = new MemoryStream(); | ||
encoder.Start(memory); | ||
encoder.SetDelay(delay); | ||
//-1:no repeat,0:always repeat | ||
encoder.SetRepeat(0); | ||
encoder.SetTransparent(SKColors.Black); | ||
|
||
var startAngle = renderSettings.rotationY; | ||
var stepAngle = 360 / frames; | ||
for (var i=0; i < frames; i++) { | ||
renderSettings.rotationY = startAngle - stepAngle * i; // Rotate clockwise | ||
|
||
var bytes = Renderer.RenderPng(voxelData, renderSettings); | ||
var image = SKImage.FromBitmap(SKBitmap.Decode(bytes)); | ||
encoder.AddFrame(image); | ||
} | ||
renderSettings.rotationY = startAngle; | ||
|
||
encoder.Finish(); | ||
|
||
return memory.ToArray(); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/> | ||
</startup> | ||
</configuration> | ||
</configuration> |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="McMaster.Extensions.CommandLineUtils" version="4.0.2" targetFramework="net48" /> | ||
<package id="SkiaSharp" version="1.59.1" targetFramework="net48" /> | ||
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net48" /> | ||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" /> | ||
</packages> |
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
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
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
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
Oops, something went wrong.