Io/zerospace converter #1

Merged
JonathanMcCaffrey merged 137 commits from io/zerospace-converter into master 2026-09-29 18:21:24 +00:00
Showing only changes of commit 8011b36955 - Show all commits
@@ -0,0 +1,39 @@
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Storage;
namespace ZeroSpace.MapEditor.Services;
/// <summary>
/// Loads the in-game galaxy map screenshot as the canvas background.
/// The PNG lives in Resources/Raw and is deployed as a MauiAsset.
/// </summary>
public static class MapBackground
{
private const string AssetName = "galaxymap.png";
public static async Task<IImage?> LoadAsync()
{
try
{
await using var packageStream = await FileSystem.OpenAppPackageFileAsync(AssetName);
// Copy into memory and leave the buffer undisposed: some platform
// image implementations read from the stream lazily.
var buffer = new MemoryStream();
await packageStream.CopyToAsync(buffer);
buffer.Position = 0;
#if WINDOWS
return new Microsoft.Maui.Graphics.Platform.PlatformImage(buffer);
#elif MACCATALYST
return new Microsoft.Maui.Graphics.Platform.PlatformImage(buffer);
#else
return null;
#endif
}
catch
{
// No map image available (missing asset, unsupported platform):
// the editor works fine without the background.
return null;
}
}
}