Quick Start: Imaging Toolkit for Delphi for Developers
Introduction
The Imaging Toolkit for Delphi is a powerful set of components and libraries that simplify image processing, display, and manipulation within Delphi applications. This quick-start guide walks through installation, basic usage, common tasks, and tips to get you productive quickly.
Prerequisites
- Delphi (RAD Studio) 10.x or compatible version
- Imaging Toolkit package files (BPL/DPROJ or source)
- Basic familiarity with Delphi components and VCL/FMX
Installation
- Close Delphi.
- Copy the toolkit source or binaries to a project folder (e.g., C:\Delphi\ImagingToolkit).
- In Delphi, open Tools > Options > Environment Options and ensure Library paths include the toolkit source path.
- Install runtime/design packages:
- Component > Install Packages > Add… and select the toolkit BPL (or open package project and compile/install).
- Restart Delphi to load components on the tool palette.
Creating a New Project
- File > New > VCL Forms Application (or FMX for cross-platform).
- Save project and unit.
Adding Toolkit Components
- From the Tool Palette, locate the Imaging Toolkit tab.
- Drop components onto the form:
- ImageViewer / TImageDisplay — display images with zoom/pan support.
- ImageProcessor / TImageFilter — apply filters and transformations.
- ImageLoader — load from files, streams, or URLs.
- ImageExporter — save to common formats (PNG, JPEG, TIFF).
Loading and Displaying an Image
- Place an ImageViewer and a Button on the form.
- Double-click the Button and add code:
pascal
procedure TForm1.Button1Click(Sender: TObject); begin ImageLoader1.FileName := ‘C:\Images\sample.jpg’; ImageLoader1.LoadImage; ImageViewer1.Image := ImageLoader1.Image; ImageViewer1.FitToWindow; end;
Basic Image Operations
- Resize:
pascal
ImageProcessor1.Resize(ImageViewer1.Image, 800, 600, rfLanczos);
- Crop:
pascal
ImageProcessor1.Crop(ImageViewer1.Image, Rect(50,50,350,300));
- Rotate:
pascal
ImageProcessor1.Rotate(ImageViewer1.Image, 90);
- Convert format and save:
pascal
ImageExporter1.Image := ImageViewer1.Image; ImageExporter1.Format := efPNG; ImageExporter1.SaveToFile(‘C:\Images\output.png’);
Applying Filters
- Add an ImageFilter component.
- Apply a built-in filter:
pascal
ImageFilter1.Filter := ifGaussianBlur; ImageFilter1.Radius := 2.5; ImageFilter1.ApplyTo(ImageViewer1.Image);
- Chain filters by calling ApplyTo sequentially or using a filter pipeline if provided.
Working with Streams and Memory Images
- Load from stream:
pascal
var fs: TFileStream; begin fs := TFileStream.Create(‘C:\Images\sample.jpg’, fmOpenRead); try ImageLoader1.LoadFromStream(fs); ImageViewer1.Image := ImageLoader1.Image; finally fs.Free; end; end;
- Access pixel data for custom processing:
pascal
var px: PRGBTriple; x,y: Integer; begin for y := 0 to ImageViewer1.Image.Height - 1 do begin px := ImageViewer1.Image.ScanLine[y]; for x := 0 to ImageViewer1.Image.Width - 1 do begin // modify px^.rgbtRed/Green/Blue Inc(px); end; end; end;
Performance Tips
- Use appropriate pixel formats (⁄32-bit preferred).
- Avoid frequent UI updates—use BeginUpdate/EndUpdate when available.
- Process images in background threads for large operations.
- Reuse buffers and streams to minimize allocations.
Cross-Platform Notes (FMX)
- Use FMX-specific viewer and loader components.
- Pay attention to pixel format conversions between GPU-backed bitmaps and CPU bitmaps.
- Test on target platforms for differences in file I/O and performance.
Troubleshooting
- Component not visible: ensure package installed and palette filters enabled.
- Slow rendering: enable hardware acceleration if supported or reduce image size.
- Unsupported format: use ImageLoader to convert or rely on external codecs.
Next Steps
- Explore advanced features: color management, ICC profiles, batch processing, OCR integration.
- Build a small utility: batch converter or image inspector to apply what you learned.
- Read the toolkit documentation for component-specific properties and events.
Summary
This quick-start covered installation, basic image loading, common operations (resize, crop, rotate), filters, stream handling, performance tips, and next steps. With these basics you can rapidly prototype image-centric Delphi applications.
Leave a Reply
You must be logged in to post a comment.