QuickStart

The TImage32 class is key.

The TImage32 object contains a single image, and all image operations act upon this object.

  uses Image32;
  ...
  img := TImage32.Create;
  //DO STUFF
  img.Free;
      



Image storage, formats & file access.

The Image32 Library provides file access to BMP, PNG & JPG storage via the Image32_BMP, Image32_PNG & Image32_JPG modules respectively.

  uses Image32, Image32_PNG;
  ...
  img := TImage32.Create;
  img.LoadFromFile('beetle.png');
  //DO STUFF
  img.SaveToFile('beetle_modified.png');
  img.Free;
      



Image processing

The Image32 library has an extensive list of classes and functions that manipulate images including: hue, luminance & saturation adjustment; box blur & Gaussian blur; erase color; blend merging images; crop; emboss; flip & rotation; scaling; sharpen; skew; transformations; and special effects

  uses Image32, Image32_PNG, Image32_Extra;
  ...
  img := TImage32.Create;
  img.LoadFromFile('beetle.png');
  EraseColor(img, clAqua32);
  img.SaveToFile('beetle.png');
  img.Free;
      



  uses Image32, Image32_Extra, Image32_PNG;
  ...
  img := TImage32.Create;
  img.LoadFromFile('fruit.png');
  Sharpen(img, 3, 30);
  img.SaveToFile('fruit_sharpened.png');
  img.Free;
      



  uses Image32, Image32_PNG, Image32_Transform;
  ...
  img := TImage32.Create;
  img.LoadFromFile('clouds.png');
  dst := Rectangle(img.Bounds); 
  dst[0].Y := 20;
  dst[3].Y := img.Height-20; 
  ProjectiveTransform(img, dst);
  img.SaveToFile('clouds_proj.png');
      



Polygon rendering

Image32 provides a large number of drawing tools.
The Image32_Draw module provides functions for line, dashed line & polygon drawing, and includes several renderers that produce: solid color; tiled image; and linear & radial gradient renders.
The Image32_Vector module also provides numerous functions for vector drawing, including: Rectangle; RoundRect; Ellipse; Pie & Arc; Spline & Bezier; Star; etc.

      uses Image32, Image32_PNG,
        Image32_vector, Image32_Draw, Image32_Clipper;
      ...
      var
        img: TImage32;
        path: TArrayOfPointD;
        paths: TArrayOfArrayOfPointD;
        radGradRend: TRadialGradientRenderer;
      begin
        img.SetSize(256,256);
        rec := img.Bounds;
        Windows.InflateRect(rec, -50,-50);

        //draw a gradient filled star
        path := Star(PointD(128, 128), 50, 100, 7);
        radGradRend := TRadialGradientRenderer.Create;
        radGradRend.SetParameters(rec, clFuchsia32, clYellow32);
        DrawPolygon(img, path, frNonZero, radGradRend);
        radGradRend.Free;
        DrawLine(img, path, 1, clBlack32, esClosed);
        //draw a dashed outline of the star
        paths := InflatePolygon(path, 7, jsRound);
        DrawDashedLine(img, paths,
          [4,4], 0, 1, clBlack32, esClosed);

        img.SaveToFile('star.png');
        img.Free;
      end;
      



      uses Image32, Image32_PNG, Image32_Text, 
        Image32_Draw, Image32_Extra;
      ...
      var
        img: TImage32;
        endPt: TPointD;
        paths: TArrayOfArrayOfPointD;
        lf: TLogFont;
      begin
        lf := DefaultLogfont;
        lf.lfFaceName := 'Impact';
        lf.lfHeight := -96;

        img := TImage32.Create(400,150);
        paths := GetTextOutline(20, 130, 
          'Image32', GetFontInfo(lf), taLeft, endPt);
        DrawShadow(img, paths, frNonZero, 3);        
        DrawPolygon(img, paths, frNonZero, $FF00DD00);
        Draw3D(img, paths, frNonZero, 3,4);
        DrawLine(img, paths, 1, clBlack32, esClosed);

        img.SaveToFile('image32_text.png');
        img.Free;
      end;
      



What! No VCL.Graphics?

This was a deliberate design decision so it'd be relatively easy to translate the Image32 library into another language, and for a different operation system. But having said that, VCL.Graphics is still used in the Image32_PNG and Image32_JPG modules.


So how can I display images in Delphi forms?

All drawing in Windows is performed using Device Contexts (DCs) and Delphi's VCL.Graphics encapsulates DCs in TCanvas objects, with the actual DC being the TCanvas.Handle. So, using TImage32's CopyToDC method, its image can be displayed in any TControl with a TCanvas property; and that includes TForm, TPanel and TImage components.

  uses Image32;
  ...
  img := TImage32.Create;
  //DO STUFF WITH img
  
  //assuming a standard TImage (Image1) component has been 
  //dropped somewhere onto a form in the Delphi IDE.   
  Image1.Picture.Bitmap.SetSize(img.Width, img.Height);
  //if 'img' is semi-transparent, prepare the target background
  Image1.Picture.Bitmap.Canvas.Brush.Color := clBtnFace;
  Image1.Picture.Bitmap.Canvas.FillRect(Image1.ClientRect);
  //now copy 'img' to Image1
  img.CopyToDc(Image1.Picture.Bitmap.Canvas.Handle);
  img.Free;
      

Alternatively, use the accompanying BitmapPanels module that converts TPanel components into powerful image viewers.

See Also

Home, BitmapPanels, TImage32, Image32_Draw, DrawDashedLine, DrawLine, DrawPolygon, Image32_Vector