SAIL image decoding library available

Under the MIT license published SAIL cross-platform image decoding library. SAIL is a C re-branding of codecs from a long-deprecated image viewer KSquirrel, but with a high-level abstract API and numerous improvements. Target Audience: Image viewers, game development, loading images into memory for other purposes. The library is under development, but is already usable. Binary and source code compatibility is not guaranteed at this stage of development.

Features:

  • A simple, compact and fast library written in C with no third-party dependencies (except for codecs);
  • Simple, clear and at the same time powerful API for all needs;
  • Bindings to C++;
  • Image formats are supported by dynamically loaded codecs;
  • Reading (and writing) images from a file, memory, or even your own data source;
  • Determining the type of image by file extension, or by magic number;
  • Currently supported formats: APNG (read, on Windows only), JPEG (read, write) PNG (read, write).
    Work on adding new formats is underway. KSquirrel-libs somehow supported about 60 formats, the most popular formats are the first in the queue;

  • Read operations can always return RGB and RGBA pixels;
  • Some codecs can output pixels in an even larger list of formats;
  • Most codecs can also output source (SOURCE) pixels. This is useful, for example, for those who want to get complete information from CMYK or YCCK images;
  • Reading and writing ICC profiles;
  • Examples in C, Qt, SDL;
  • Supported platforms:
    Windows (installer), macOS (brew) and Linux (Debian).

What SAIL does not provide:

  • Image editing;
  • Functions for converting color spaces other than those provided by underlying codecs (libjpeg, etc.);
  • Color management functions (applying ICC profiles, etc.)

The simplest decoding example in C:

struct sail_context *context;

SAIL_TRY(sail_init(&context));

struct sail_image *image;
unsigned char *image_pixels;

SAIL_TRY(sail_read(path,
context
& image,
(void **)&image_pixels));

/*
* Process the resulting pixels here.
* To do this, use image->width, image->height, image->bytes_per_line,
* and image->pixel_format.
*/

/* Clean up */
free(image_pixels);
sail_destroy_image(image);

Brief description of API levels:

  • Newbie: "I just want to upload this JPEG"
  • Advanced: "I want to load this animated GIF from memory"
  • Deep Sea Diver: "I want to load this animated GIF from memory and have full control over the selected codecs and the format of the returned pixels"
  • Tech diver: "I want everything above and my own data source"

Direct competitors from the same area:

  • free image
  • DevIL
  • SDL_Image
  • WIC
  • imlib2
  • Boost.GIL
  • gdk-pixbuf

Differences from other libraries:

  • Human API with expected entities - images, palettes, etc.
  • Most codecs can render not only RGB/RGBA pixels.
  • Most codecs can return original pixels without conversion to RGB.
  • You can write codecs in any language, as well as add/remove them without recompiling the entire project.
  • Saving information about the original image.
  • "Probing" - obtaining information about the image without decoding the pixel data.
  • Size and speed.

Source: opennet.ru

Add a comment