PictSharp.Drawing 0.1.3

.NET Framework 4.6.1
dotnet add package PictSharp.Drawing --version 0.1.3
NuGet\Install-Package PictSharp.Drawing -Version 0.1.3
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="PictSharp.Drawing" Version="0.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PictSharp.Drawing --version 0.1.3
#r "nuget: PictSharp.Drawing, 0.1.3"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install PictSharp.Drawing as a Cake Addin
#addin nuget:?package=PictSharp.Drawing&version=0.1.3

// Install PictSharp.Drawing as a Cake Tool
#tool nuget:?package=PictSharp.Drawing&version=0.1.3

<h1 align="center"> <img src="https://raw.githubusercontent.com/pgodwin/PictSharp/master/pictsharp.png" alt="PictSharp" width="256"/> <br/> PictSharp </h1>

<div align="center">

build Nuget PictSharp.Core Nuget PictSharp.ImageSharpAdaptor Nuget PictSharp.Drawing GitHub </div>

PictSharp is a C# Library for encoding bitmap images to to Apple's legacy PICT Format.

Features

  • Implemented entirely in C# code. No native dependencies.
  • Supports .NET Framework 4.6.1+, .NET Core 3.1 and runtimes compatible with .NET Standard 2.0
  • Writes PICT 2.0 Images (so should work on a Mac II onwards with Color QuickDraw)
  • Supports 1bpp, 2bpp, 4bpp, 8bpp and 32bpp image encoding, with PackBits compression
  • Extensions available for ImageSharp and System.Drawing.Bitmap

What's not supported?

  • Vector, text, clipping, etc. This is purely for raster images.
  • 16-bit images aren't working (16-bit images use a variant of PackBits which works on WORD (16 bit) values).
  • Decoding any PICT images
  • Compression other than PackBits (ie JPEG)

Quick Start with ImageSharp

📦 Install the Package from nuget

Install-Package PictSharp.ImageSharpAdaptor

The following will convert an ImageSharp image into PICT

using PictSharp.ImageSharpAdaptor;
...
// Register the PICT Encoder with ImageSharp
var module = new PictConfigurationModule();
module.Configure(SixLabors.ImageSharp.Configuration.Default);

// Load an ImageSharpImage
using (var image = SixLabors.ImageSharp.Image.Load<Rgba32>("Lenna32.png"))
{
   // Save to PICT
   image.SaveAsPict("Lenna32.pict");
}

You can control the bit depth of the images by setting the encoder.

var encoder = new PictEncoder();
encoder.PictBpp = PictBpp.Bit8;
image.SaveAsPict("Lenna8bpp.pict", encoder);

System.Drawing.Bitmap support

For .NET Framework 4.6.1+ there is support for System.Drawing.Bitmap under Windows.

📦Grab the package:

Install-Package PictSharp.Drawing
using PictSharp.Drawing;
...

var image = new System.Drawing.Bitmap("source.png"); ;

using (var output = new FileStream("output.pict", FileMode.CreateNew))
   image.SaveAsPict(output);

What is PICT?

PICT is a legacy meta-file format created by Apple, which contains (basically) serialised QuickDraw commands which can be "replayed" to produce an image. It can contain both vector and bitmap components. It is somewhat similar in concept to Windows Metafile (WMF) format. The format itself is not clearly documented, with only limited documentation available from Apple, and few implementations available.

In 2021 the most common place you'll find PICT files is MacOS Clipboard data, and RTF documents (\macpict).

The format was extended with the release of QuickTime 2.0 to support QuickTime compressors, so can contain not just JPEG or PNG images, but also Video Codecs, like Cinepak, Quicktime Animation/Graphics, "Apple Video" (RDZA), etc.

Other Implementations

  • ImageMagik - very well knonwn library and commandline tool which supports a wide variety of formats. Includes a decoder and encoder for raster PICT images. Note that 1bpp images seem to be broken as of Jan 2022.
  • TwelveMonkeys ImageIO - JAVA library with support for a huge range of formats. PICT support is quite good and even supports some QuickDraw commands, QuickTime stills and more. I suspect it's decoding support is better than ImageMagik and even Photoshop
  • QuickTime - QuickTime has support for encoding and decoding images on Windows and MacOS. Exporting from QuickTime seems to produce "QuickTime Still" images rather than PICT images, so compatibility of exported images is not high.
  • Adobe Photoshop - Photoshop has some limited support for PICT, both decoding and encoding. I've found that CS2 at least will display an unsupport error on some formats (like 1bpp images).

Know of some more? Please let me know!

Credits

Other Resources

License

MIT License

Questions / Support

As always, supplied as-is without any warranties. If you find an issue, please raise it via Github. PRs welcomed.

Product Versions
.NET Framework net461 net462 net463 net47 net471 net472 net48
Compatible target framework(s)
Additional computed target framework(s)
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.1.3 156 1/5/2022
0.1.2 129 1/5/2022