PictSharp.ImageSharpAdaptor 0.1.3

dotnet add package PictSharp.ImageSharpAdaptor --version 0.1.3                
NuGet\Install-Package PictSharp.ImageSharpAdaptor -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.ImageSharpAdaptor" Version="0.1.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PictSharp.ImageSharpAdaptor --version 0.1.3                
#r "nuget: PictSharp.ImageSharpAdaptor, 0.1.3"                
#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 PictSharp.ImageSharpAdaptor as a Cake Addin
#addin nuget:?package=PictSharp.ImageSharpAdaptor&version=0.1.3

// Install PictSharp.ImageSharpAdaptor as a Cake Tool
#tool nuget:?package=PictSharp.ImageSharpAdaptor&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 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.1.3 285 1/5/2022
0.1.2 256 1/5/2022
0.1.0 232 1/4/2022