Table of Contents

YuImage

YuImage is a collection of image codec libraries and classes: Delphi ports of libjpeg-turbo, libpng, libwebp, and Little CMS, all statically linked, no DLLs needed.

Overview

YuImage is a collection of image processing libraries, classes and functions for Delphi. In particular, it contains Delphi ports of the following C libraries, all with complete API, statically linked, and no DLLs needed:

libjpeg-turbo: Accelerated JPEG codec with SIMD instructions

libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2, AVX2, Neon) to accelerate baseline and progressive JPEG compression and decompression. It is generally 2-6 times faster than the JPEG implementation which ships with Delphi.

libjpeg-turbo implements both the traditional libjpeg API as well as the less powerful but more straightforward TurboJPEG API. The libjpeg API is interface and mathematically compatible with libjpeg v6b, with the following extensions:

TYuJpegImage is a TGraphic descendant image class which loads and draws JPEG images, automatically applies embedded ICC color profiles, and provides the decoded image as a TBitmap.

TBitmap_SaveAsJpeg() saves a TBitmap instance as a JPEG stream or file.

libpng / YuPng.pas: The official PNG reference library

libpng supports almost all features of the PNG image format, is extensible, and extensively tested.

TYuPngImage is an image class which descends from TGraphic. It loads and draws PNG encoded images with transparency and automatically applies embedded ICC color profiles, gamma correction, and chromaticities.

TBitmap_SaveAsPng() saves a TBitmap instance as a PNG stream or file.

libwebp / YuWebP.pas: The official WebP refernce library

WebP is a modern image format that provides superior lossless and lossy image compression. It can create smaller and richer images. WebP lossless images are 26% smaller in size compared to PNGs. WebP lossy images are 25-34% smaller than comparable JPEG images at equivalent perceived quality.

TYuWebPImage is a TGraphic descendent image class. It loads and draws WebP encoded images with alpha transparency and automatically applies embedded ICC profiles. TYuWebPImage renders animated WebP images.

TBitmap_SaveAsWebP() saves a TBitmap instance as a WebP stream or file.

Little CMS / YuLcms2.pas: A small-footprint color management engine

Little CMS implements fast transformations between color profiels based on the International Color Consortium (ICC) 4.4 specification and support for all kinds of V2 and V4 profiles.

Demo projects, including an Image Viewer with thumbnails preview, are included in the download.

Minimum TYuJpegImage, TYuPngImage, or TYuWebPImage Example

{ Add the YuJpegImage, YuPngImage, and YuWebPImage units once 
  to any uses clause to register TYuJpegImage as JPEG handler,
  TYuPngImage as PNG handler, and TYuWebPImage as WebP handler. }
uses
  Graphics,    // For TPicture.
  YuJpegImage, // Register TYuJpegImage.
  YuPngImage,  // Register TYuPngImage.
  YuWebPImage; // Register TYuWebPImage.
 
procedure LoadImages;
var
  pic: TPicture;
begin
  pic := TPicture.Create;
  try
    pic.LoadFromFile('test.jpg'); // Load a JPEG image.
    { Add code here to do something with the picture. }
  finally
    pic.Free;
  end;
 
  pic := TPicture.Create;
  try
    pic.LoadFromFile('test.png'); // Load a PNG image.
    { Add code here to do something with the picture. }
  finally
    pic.Free;
  end;
 
  pic := TPicture.Create;
  try
    pic.LoadFromFile('test.webp'); // Load a WebP image.
    { Add code here to do something with the picture. }
  finally
    pic.Free;
  end;
end;

Why TYuPngImage, yet another Delphi PNG image class?

Because TPngImage, Delphi's own PNG image class, if faulty. TYuPngImage fixes some annoying bugs and deficiencies of TPngImage, as demonstrated below.

The examples were painted by Delphi 11.2 Alexandria, the most recent Delphi at the time of this writing. The left and right images are drawn on a checker board pattern to show their transparent pixels. The center image points out pixel differences with a red color overlay.

3rd Party Problems Detected During YuImage Development

YuImage development uncovered a problem in Little CMS: