Skip to content

Latest commit

 

History

History
73 lines (49 loc) · 3.69 KB

README.md

File metadata and controls

73 lines (49 loc) · 3.69 KB

CoreJ2K - A Managed and Portable JPEG2000 Codec

Copyright (c) 1999-2000 JJ2000 Partners;
Copyright (c) 2007-2012 Jason S. Clary; Copyright (c) 2013-2016 Anders Gustafsson, Cureos AB;
Copyright (c) 2024 Sjofn LLC.

Licensed and distributable under the terms of the BSD license

Summary

This is an adaptation of CSJ2K, which provides JPEG 2000 decoding and encoding functionality to .NET based platforms. CSJ2K is by itself a C# port of the Java package jj2000, version 5.1. This is a fork of CSJ2K for .NET Standard 2.1 making it possible to implement JPEG decoding and encoding on any platform.

Installation

Apart from building the relevant class libraries from source, pre-built packages for the supported platforms can also be obtained via NuGet.

Usage

The Library provides interfaces for image rendering, file I/O and logging.

Decoding

To decode a JPEG 2000 encoded image, call one of the following methods:

public class J2kImage
{
	public static PortableImage FromStream(Stream, ParameterList = null);
	public static PortableImage FromBytes(byte[], ParameterList = null);
	public static PortableImage FromFile(string, ParameterList = null);
}

The returned PortableImage offers a "cast" method As<T>() to obtain an image in the type relevant for the platform. When using the SKBitmapImageCreator on .NET, a cast to SKBitmap or SKPixmap would suffice:

var bitmap = decodedImage.As<SKBitmap>();

Encoding

To encode an image, the following overloads are available:

public class J2kImage
{
	public static byte[] ToBytes(object, ParameterList = null);
	public static byte[] ToBytes(BlkImgDataSrc, ParameterList = null);
}

The first overload takes an platform-specific image object. This is still works-in-progress, but an implementation is available for SKBitmap objects.

The second overload takes an CSJ2K specific object implementing the BlkImgDataSrc interface. When Portable Graymap (PGM), Portable Pixelmap (PPM) or JPEG2000 conformance testing format (PGX) objects are available as Streams, it is possible to create BlkImgDataSrc objects using either of the following methods:

J2kImage.CreateEncodableSource(Stream);
J2kImage.CreateEncodableSource(IList<Stream>);

For PGM and PPM images, you would normally use the single Stream overload, whereas for PGX images, you may enter one Stream object per color component.

Links

CoreJ2K NuGet-Release CoreJ2K.Skia NuGet-Release
NuGet Downloads
Commits per month
Build status
Codacy Badge
ZEC BTC