 |
 |
|
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
^
|
|
|
 |
|
|
 |
 |
::
|
|
|
Universal Image Loader
Universal Image Loader is a little library to load images to TBitmap and TBitmap32. Uses Free Image Library (FreeImage.dll), LibRAW (libraw.dll) and the WIC system for loading and saving of picture files.
Features:
- Load all the supported picture file formats supported by the loaders
- Load and resize pictures in one go with high quality resamplers
- Load from file, TStream or memory location
- 32 bit transparent pictures and bit depths above 32 bits are fully supported
- The functions are thread-safe
- VCL TBitmap and Graphics32 TBitmap32 versions of the functions
- Delphi and C++ header file included for the DLL version
- Supported platforms: Win32 and Win64 (and experimental WinARM64)
Note: In Lazarus/FPC WIC functionality is not available.
Requirements
Delphi 12 Athens optionally with Graphics32.
Lazarus/FPC.
C++. The C++ header files for the DLL version were generated by ChatGPT and it is not tested.
To have a header for the DLL version for any language ask an AI and provide 'UniversalImageLoaderLibraryDefs.pas' and ask for a conversion to the particular langauge.
Universal Image Loader in shareware and commercial software?
The component comes with full source code and can be evaluated freely. If you like it and decide to use it in a freeware, shareware or commercial (or any other money making - advertising, in app. selling, etc.) product one of the licenses is needed.
Supported file formats
Pictures:
- JPG images (*.jpg, *.jpeg)
- JPEG2000 images (*.jp2, *.j2k, *.jpc)
- TIFF images (*.tif, *.tiff) (You need a license to use the LZW compressed format)
- GFI fax images (*.fax)
- SGI images (*.bw, *.rgb, *.rgba, *.sgi)
- Autodesk images files (*.cel, *.pic) old style only
- Truevision images (*.tga, *.vst, *.icb, *.vda, *.win)
- ZSoft Paintbrush images (*.pcx, *.pcc)
- Word 5.x screen capture files (*.scr)
- Kodak Photo-CD images (*.pcd)
- Portable pixel/gray map images (*.ppm, *.pgm, *.pbm)
- Dr. Halo images (*.cut, *.pal)
- CompuServe images (*.gif)
- SGI Wavefront images (*.rla, *.rpf)
- Standard Windows bitmap images (*.bmp, *.rle, *.dib),
- Photoshop images (*.psd, *.pdd)
- Paintshop Pro images (*.psp)
- Portable network graphic images (*.png)
- Amiga (*.iff, *.lbm)
- DirectDraw Surface (*.dds)
- Raw Fax format CCITT G3 (*.g3)
- High Dynamic Range (*.hdr)
- JPEG Network Graphics (*.jng)
- Commodore 64 Koala format (*.koa)
- Multiple Network Graphics (*.mng)
- Sun Rasterfile (*.ras)
- Truevision Targa files (*.tga, *.targa)
- Wireless Bitmap (*.wbmp)
- X11 Bitmap Format (*.xbm)
- X11 Pixmap Format (*.xpm)
RAW camera photo files:
- Hasselblad Raw (*.3fr)
- Sony Raw (*.arw, *.srf, *.sr2)
- Casio Raw (*.bay)
- Capture One Raw (*.cap, *.cs1)
- Canon Raw (*.crw, *.cr2, *.cr3)
- Kodak Raw (*.dcr, *.dcs, *.drf, *.k25, *.kdc)
- Camera Raw (*.dng)
- Epson Raw (*.erf)
- Phase One Raw (*.iiq)
- Mamiya Raw (*.mef)
- Leaf Raw (*.mos)
- Minolta Raw (*.mrw)
- Nikon Raw (*.nef, *.nrw)
- Olympus Raw (*.orf)
- Pentax Raw (*.pef, *.ptx)
- Fujifilm Raw (*.raf)
- Panasonic Raw (*.raw, *.rwl, *.rw2)
- Samsung Raw (*.srw)
- Sigma Raw (*.x3f)
WIC loader supports all file formats when a particular WIC loader file format is available.
Installation
If Graphics32 is not already installed, it's recommended to install it - although it's not needed to install it to compile, it's enough to have the Graphics32 units on the search path. But Graphics32 is a great component you might want to decide to use it.
Latest version of Graphics32 can be downloaded from: https://github.com/graphics32/graphics32
Add to uses list 'UniversalImageLoader' and to the search path the folder where 'UniversalImageLoader.pas' is.
Using the component with Graphics32
To enable Graphics32 support add to the project's conditional defines: 'LIBRAWUSEGR32' and 'USEGR32'.
Using FreeImageLoader.pas unit
Add to the uses list 'FreeImageLoader' to access all the advanced Free Image Library loader functions.
TUILLoadParameters
TUILLoadParameters = record
Loaders: TUILLoaders;
Width: Integer;
Height: Integer;
KeepAspectRatio: Boolean;
DontResizeSmaller: Boolean;
Resampler: FREE_IMAGE_FILTER;
GR32Resampler: TUILGR32Resampler;
GR32ResamplerBackgroundColor: Cardinal; //* ARGB
JPEGReducedMaxWidth: Integer;
RAWUseCWB: Boolean;
RAWHalfSize: Boolean;
end;
Loaders: Loaders to try when loading the image ('uilLibRAW', 'uilFIL', 'uilWIC' tried in this order). Default value is all loaders.
Width, Height: Resize the image after loading, value of '0' means no resize. Default values are both '0'.
KeepAspectRatio: Maintain aspect ratio when resizing the image. Set to 'False' if a concrete dimensions are needed. Default value is 'True'.
DontResizeSmaller: If the requested resize results larger image than the original don not resize. Set to 'False' if concrete dimensions are needed. Default value is 'True'.
Resampler: Free Image Library resampler filter to use when resizing the bitmap. This value is used when the loading is performed by Free Image Library and when using the VCL TBitmap methods for LibRAW and WIC in case a resize is required. The available filters are specified in 'FreeImage.pas'. Default value is 'FILTER_LANCZOS3'.
GR32Resampler: Graphics32 resampler filter to use when resizing the bitmap. This value is used when working with TBitmap32 bitmaps and the loading is performed by LibRAW or WIC and when using the Graphics32 TBitmap32 methods in case a resize is required. The available filters are specified in 'UniversalImageLoader.pas'. Default value is 'GR32_RASAMPLER_LANCZOS'.
GR32ResamplerBackgroundColor: If the TBitmap32 to be resized is transparent the background is cleared with this ARGB value. Affects also how semi-transparent pixels appear, set this value to the actual background color where the bitmap will appear. Eg. for white '$00FFFFFF'. Default value is transparent black '$00000000'.
JPEGReducedMaxWidth: When loading a JPEG picture it is possible to decode 2x, 4x, 8x smaller than the original. This results a major speed-up when only a thumbnail is needed. Eg. set the value to '160'. Default value is '0'.
RAWUseCWB: Set LibRAW to decode the RAW camera photo file with camera white balance correction. If the value is 'False' no correction is applyed. In most cases this value should be always 'True'. Default value is 'True'.
RAWHalfSize: Set LibRAW to decode the RAW camera photo file at half size (4x less pixels required, eg. a 1000 x 1000 picture results a 500 x 500 pixel bitmap). This results a major speed-up (around 4x) when only a thumbnail is needed for example. Default value is 'False'.
Note: In Lazarus/FPC the record is not initialized to the default values, it is needed to explicitly set the values (or call InitializeTUILLoadParameters()) before passing it to the functions.
WinARM64 support
There is an experimental (not tested at all) WinARM64EC build of the 'UniversalImageLoaderLibrary.dll' and 'libraw.dll' (WinARM64/WinARM64EC) in the package, please let me know if you get any progress with it.
Could not achieve a 'FreeImage.dll' WinARM64 build though (I am a Delphi user so don't have much experience with C++/VS). If you manage to create a working configuration please contact me and I will include the WinARM64 stuff in the official package.
Note that theoretically including the Win64 DLLs by the WinARM64EC build should work fine.
|
|
|
|
|
|