ImageEn, unit iexHelperFunctions

GetImageDetails


Declaration

function GetImageDetails(const Filename: string;
                         out Width: Integer;
                         out Height: Integer;
                         out BitsPerPixel: Integer
                         ): Boolean; overload;
function GetImageDetails(const Filename: string): TPoint; overload;



Description

Return the size and color depth of an image. Result is false if a load error occurs.
The second overload only returns only the width and height (which will be -1,-1 if a load error is encountered).

Note:
Color depth is TImageEnIO.Params.BitsPerSample * TImageEnIO.Params.SamplesPerPixel.
You must add the iexHelperFunctions unit to your uses clause

See also: BitsPerPixelToStr


Example

if GetImageDetails('D:\MyImage.jpeg', iWidth, iHeight, iBitsPerPixel) then
begin
  lblWidth.Caption := IntToStr(iWidth);
  lblHeight.Caption := IntToStr(iHeight);
  lblColorDepth.Caption := BitsPerPixelToStr(iBitsPerPixel);
end;