
Delphi庫,用於簡化圖像加載/保存,轉換和轉換。可以加載/保存PNG,JPG,JXL,WebP,AVIF,TIFF,GIF和BMP。可以從不同的資源獲取圖像:文件,流,HTTP,Imagelist,關聯的Windows圖標,可執行文件圖標等...旋轉,翻轉,灰度和許多其他轉換。 GDI+,Graphics32,OpenCV,Vampyre和Libvips發動機可用。
請在Github“星”這個項目!它無需花費,但有助於參考代碼。 
如果您覺得這個項目有用,請考慮捐款。
*新:Delphi 12雅典支持
*新:添加了Libvips引擎
*新:基於接口
*新:吸血鬼lib引擎添加了
*新:添加了新功能
*新:重構類
*新:Delphinus支持
您可以選擇一個或多個可用的引擎ImageFX支持。將一個或多個以下單元添加到您的用途條款:
quick.imagefx.gdi:使用gdi+引擎。無需外部庫,但是很慢。
需要的庫:
quick.imagefx.gr32:使用Graphics32引擎旋轉,轉換,調整大小等
需要的庫:
quick.imagefx.opencv: OpenCV引擎。使用Thrid Party Delphi Warper作為Intel Open Vision Library。它非常快速且功能強大。在您的項目dir中需要OPENCV外部DLL。
需要的庫:
quick.imagefx.vampyre:吸血鬼成像庫引擎。使用Thrid Party Delphi Warper作為吸血鬼成像本地圖書館。快速並支持許多圖像格式。
需要的庫:
quick.imagefx.vips: libvips成像庫引擎。使用thrid Party Delphi Warper進行Libvips庫。超快速,並支持許多圖像格式,例如WebP,Avif,JXL等。
需要的庫:
創建:創建ImageFX的實例以加載/操縱圖像。
var
ImageFX : IImageFX;
begin
ImageFX := TImageFXGDI // You can create as TImageFXGDI, TImageFXGR32, TImageFXOpenCV or TImageFXVampyre to use different graphic engines
ImageFX.LoadFromFile( ' .test.jpg ' );
ImageFX.Rotate90;
ImageFX.SaveAsPNG( ' .Test.png ' );
end ;加載/保存:可以加載/保存PNG,JPG,GIF和BMP,並從文件,流,http,Imagelist,關聯的Windows Icon,可執行文件圖標等不同資源中獲取圖像...
// Load image from files like jpg, gif, png and bmp
ImageFX.LoadFromFile( ' .file.jpg ' );
// Load/Save image from/to a memorystream, filestream, etc...
ImageFX.LoadFromStream(MyStream);
ImageFX.SaveToStream(MyStream,ifJPG);
// Load image from an icon class
ImageFX.LoadFromIcon(MyIcon);
// Load image from an icon file
ImageFX.LoadFromFileIcon( ' .file.ico ' );
// Get image associated in windows with this type of extension
ImageFX.LoadFromFileExtension( ' .file.xls ' ,True);
// Load from exe resource
ImageFX.LoadFromResource( ' Main.ico ' );
// Get image from a http link
ImageFX.LoadFromHTTP( ' http://www.mysite.com/file.jpg ' ,ReturnHTTPCode,True);
// Load/Save from string
ImageFX.LoadFromString(MyImageString);
ImageFX.SaveToString(MyImageString);圖像信息:獲取圖像的分辨率,縱橫比。
ImageFX.GetResolution(x,y)
ImageFX.AspectRatioStr // aspect ratio (4:3,16:9)
ImageFX.IsGray圖像大小:
// Resize image to fit max bounds of 500x300 and fills rest of target size with a border black color
ImageFX.ResizeOptions.BorderColor := clBlack;
ImageFX.Resize( 500 , 300 , rmFitToBounds, [rfCenter], rmLinear);
// Same image resize alternative/advanced mode
ImageFX.ResizeOptions.ResamplerMode := rmLinear;
ImageFX.ResizeOptions.ResizeMode := rmFitToBounds;
ImageFX.ResizeOptions.Center := True;
ImageFX.ResizeOptions.FillBorders := True;
ImageFX.ResizeOptions.BorderColor := clBlack;
ImageFX.Resize( 500 , 300 );調整:
nomagnify:如果不正確地調整圖像大小,則如果最小的是新尺寸。
RESIZEMODE:調整算法大小以計算所需的最終大小:
重新採用:調整要應用的算法大小:
中心:中心圖像
FillBorders:如果較小,則在目標矩形中填充縮放圖像的邊界。
邊界顏色:填充邊界的顏色。
變換:應用旋轉,翻轉,掃描線效果,明亮的效果以及其他變換。
// Rotate image 90 degrees
ImageFX.Rotate90;
// Rotate image 45 degrees
ImageFX.RotateAngle( 45 );
// Convert to grayscale
ImageFX.GrayScale;
// Flip image horizontally
ImageFX.FlipX;
// Increase bright by 50%
ImageFX.Lighten( 50 );
// Change color of a pixel
PixInfo.R := Random( 255 ); // R
PixInfo.G := Random( 255 ); // G
PixInfo.B := Random( 120 ); // B
PixInfo.A := 200 ; // Alpha
imageFX.Pixel[x,y] := PixInfo;
// Draw an overlay image over current image with 50% transparency
ImageFX.DrawCentered(pngimage, 0.5 );格式轉換:可以在圖像格式之間轉換。
ImageFX.LoadFromFile( ' .myfile.jpg ' );
ImageFX.SaveAsPNG( ' .myfile.png ' );幾乎所有功能都返回自我類別,因此您可以鏈接許多這樣的動作和效果:
// Rotate 90 degrees and flip horizontally, convert to grayscale and save to a png file.
ImageFX.Rotate90.FlipX.GrayScale.SaveToPNG( ' .myfile.png ' );
// Load from file, rotate180, resize to 100x100 and assign to a TImage.
MyImage.Picture.Asssign(ImageFX.LoadFromFile( ' .myfile.jpg ' ).Rotate180.Resize( 100 , 100 ).AsBitmap);您想學習Delphi還是提高技能? Learndelphi.org