Alternative to System.Drawing in Pipeline Tool

In a ContentProcessor (Pipeline Tool, MonoGame v. 3.8) I want to create a texture and save it as a png. Since System.Drawing is not cross-platform and I am getting an error when building resources “Could not load file or assembly System.Drawing.Common, Version=4.0.0.1” is there an alternative? Can’t use Texture2D because there is no GraphicsDevice available in ContentProcessor.

var bm = new System.Drawing.Bitmap( packedSprites.Width, packedSprites.Height );
for( var x = 0; x < packedSprites.Width; x++ )
{
	for( var y = 0; y < packedSprites.Height; y++ )
	{
		var col = packedSprites.GetPixel( x, y );
		var color = System.Drawing.Color.FromArgb( col.A, col.R, col.G, col.B );
		bm.SetPixel( x, y, color );
	}
}

var atlasFilename = tileset.name + "-atlas.png";
bm.Save( Path.Combine( tileset.mapFolder, atlasFilename ), System.Drawing.Imaging.ImageFormat.Png );

ImageSharp is probably your best bet for cross platform image processing.

https://www.nuget.org/packages/SixLabors.ImageSharp/

Now I get this error “Could not load file or assembly SixLabors.ImageSharp, Version=1.0.0.0”, but if I add the path to the ImageSharp .dll from nugets in mgcb references then it works. It seems now with .Net Core where you are required to use nugets instead of assemblies then you have to add the dlls of your nugets manually in mgcb.

In What’s new 3.8, they say this, but I have no idea what they mean by disabling PrivateAssets. In my pipeline csproj file I have PrivateAssets All for some of my packages, but not for ImageSharp. I tried creating one and setting to None, but it didn’t work.

“We now recommend using MonoGame.Framework.DesktopGL and MonoGame.Framework.Content.Pipeline and disable the PrivateAssets to avoid copying any dependent assemblies.”

You can do it this way maybe, but it should be enough to make sure that your build mgcb extensions project is built so that they have all the needed .dlls. See this thread Pipeline Extension cant reslove external assambly. · Issue #7368 · MonoGame/MonoGame · GitHub