PxSharp 0.2.0
dotnet add package PxSharp --version 0.2.0
NuGet\Install-Package PxSharp -Version 0.2.0
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="PxSharp" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PxSharp" Version="0.2.0" />
<PackageReference Include="PxSharp" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PxSharp --version 0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PxSharp, 0.2.0"
#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.
#:package PxSharp@0.2.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PxSharp&version=0.2.0
#tool nuget:?package=PxSharp&version=0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
PxSharp
Lightweight library for rendering pixel art in .NET console applications.
Features
- Load 24-bit and 32-bit BMP images
- Render using half-block characters (▀▄) for compact output that preserves the original aspect ratio
- True color with automatic 256-color fallback
Installation
dotnet add package PxSharp
Quick Start
using PxSharp;
var image = PxImage.Load("logo.bmp");
// Simple: dump to console
image.WriteAnsi(Console.Out);
// Composed: image alongside text
image.Print(0); Console.WriteLine(" MyApp v1.0");
image.Print(1); Console.WriteLine(" MIT License");
API
// Loading
var img = PxImage.Load("file.bmp"); // from file path
var img = PxImage.Load(stream); // from Stream (for embedded resources)
// Dimensions
img.PixelWidth // source width in pixels
img.PixelHeight // source height in pixels
img.CharWidth // output width in characters
img.CharHeight // output height in characters (pixels / 2)
// Output
img.Print(row) // print a row to stdout (no newline)
img.PrintLine(row) // print a row to stdout (with newline)
img.WriteAnsi(tw) // write all rows to TextWriter
img.GetAnsiLine(i) // get row as ANSI string
img.GetAnsiLines() // get all rows as string[]
Color Mode
Auto-detects terminal capability. Override globally:
PxSharpSettings.ColorMode = ColorMode.TrueColor; // force 24-bit
PxSharpSettings.ColorMode = ColorMode.Palette256; // force 256-color
Transparency
Use a color key for transparency (like GIF). Pixels matching the key are transparent. Default is magenta (#FF00FF):
PxSharpSettings.TransparentColor = (255, 0, 255); // magenta (default)
PxSharpSettings.TransparentColor = (255, 0, 0); // red
Embedding Images
Embed BMP files as assembly resources for distribution:
<ItemGroup>
<EmbeddedResource Include="logo.bmp" />
</ItemGroup>
using System.Reflection;
var asm = Assembly.GetExecutingAssembly();
using var stream = asm.GetManifestResourceStream("MyApp.logo.bmp");
var logo = PxImage.Load(stream);
Resource name format is {Namespace}.{Filename}.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.