b2-xpm-sharp 0.0.1

dotnet add package b2-xpm-sharp --version 0.0.1                
NuGet\Install-Package b2-xpm-sharp -Version 0.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="b2-xpm-sharp" Version="0.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add b2-xpm-sharp --version 0.0.1                
#r "nuget: b2-xpm-sharp, 0.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install b2-xpm-sharp as a Cake Addin
#addin nuget:?package=b2-xpm-sharp&version=0.0.1

// Install b2-xpm-sharp as a Cake Tool
#tool nuget:?package=b2-xpm-sharp&version=0.0.1                

This library loads XPM v3 files into XPixMap objects for reading purposes (writing XPM files might be added later). Currently there are three ways to load a XPM file:

  • Call XPixMap.FromContent(string content) which takes the content of a XPM file.
  • Call XPixMap.FromFile(string path) which takes the path to your XPM file.
  • Call XPixMap.FromStream(Stream stream) which takes a readable stream, setting its position to zero. (Be sure to dispose the stream after calling the method.)

The XPixMap then can be used to get meaningful info about the XPM, like Width, Height, Hotspot (if present) and the pixel matrix by calling GetColors() returning a Color[,].
Additionally, the Extensions method GetBitmap() can be used to convert the XPM to a System.Drawing.Common.Bitmap object.

var xpm = XPixMap.FromFile(@"C:\path\to\image.xpm");
var bmp = xpm.GetBitmap();
//Edit the image
bmp.SetPixel(0, 0, Color.Black);
bmp.SetPixel(0, 1, Color.White);
//Save it
bmp.Save(@"C:\path\to\image.png", System.Drawing.Imaging.ImageFormat.Png);

There is also a DrawOn() extension method which allows you to draw the XPM on a surface. (For example, a windows form handle)

using var stream = openFileDialog.OpenFile();
var xpm = XPixMap.FromStream(stream);
xpm.DrawOn(Handle);

image


The library is on .netstandard so it's usable on .net and .net Framework. However I have not tested it on linux and it might not work as expected.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.1 151 1/22/2024