-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add logo to WASM host app.
- Loading branch information
Showing
17 changed files
with
80 additions
and
11 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Binary file not shown.
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
42 changes: 42 additions & 0 deletions
42
src/apps/Highbyte.DotNet6502.App.SilkNetNative/SilkNetImageLoader.cs
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,42 @@ | ||
using System.Reflection; | ||
using Silk.NET.Core; | ||
|
||
namespace Highbyte.DotNet6502.App.SilkNetNative; | ||
public class SilkNetImageLoader | ||
{ | ||
public static RawImage ReadFileAsRawImage(string path, bool isEmbeddedResource = false) | ||
{ | ||
byte[] fileBytes; | ||
if (isEmbeddedResource) | ||
{ | ||
Assembly assembly = Assembly.GetExecutingAssembly(); | ||
using (Stream? resourceStream = assembly.GetManifestResourceStream(path)) | ||
{ | ||
if (resourceStream == null) | ||
throw new Exception($"Cannot open stream to resource {path} in current assembly."); | ||
using (MemoryStream ms = new MemoryStream()) | ||
{ | ||
resourceStream.CopyTo(ms); | ||
fileBytes = ms.ToArray(); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
fileBytes = File.ReadAllBytes(path); | ||
} | ||
|
||
var bitmap = SKBitmap.Decode(fileBytes); | ||
byte[] bytes = new byte[bitmap.Pixels.Length * 4]; | ||
int index = 0; | ||
foreach (var pixel in bitmap.Pixels) | ||
{ | ||
bytes[index++] = pixel.Red; | ||
bytes[index++] = pixel.Green; | ||
bytes[index++] = pixel.Blue; | ||
bytes[index++] = pixel.Alpha; | ||
} | ||
var rawImage = new RawImage(bitmap.Width, bitmap.Height, new Memory<byte>(bytes)); | ||
return rawImage; | ||
} | ||
} |
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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.