GetFileInfo example for Delphi
This example gets information about the specified file.
var
// Declare local variables
cMsg, cmp, cFmt, fname: String;
pg, fmt: Integer;
LeadWidth, LeadHeight:Single;
bps, xres, yres, sizd, sizm: Integer;
RasterIO: LEADRasterIO;
begin
// Initialize variables
RasterIO:= CreateComObject (CLASS_LEADRasterIO) as LEADRasterIO;
fname := 'c:\temp\test.tif';
pg := 0;
xres:= RasterIO.InfoXRes;
yres:= RasterIO.InfoYRes;
// Update the variables
RasterIO.GetFileInfo (LEADRasterView1.Raster, fname, pg, FILEINFO_TOTALPAGES);
// Read the updated properties
fmt := RasterIO.InfoFormat;
LeadWidth := RasterIO.InfoWidth;
LeadHeight := RasterIO.InfoHeight;
bps := RasterIO.InfoBits;
pg := RasterIO.InfoPage;
sizd := RasterIO.InfoSizeDisk;
sizm := RasterIO.InfoSizeMem;
cmp := RasterIO.InfoCompress;
// Translate the meaning of the format constant
Case fmt of
FILE_PCX:
cFmt := 'ZSoft PCX';
FILE_GIF:
cFmt := 'CompuServe GIF';
FILE_TGA:
cFmt := 'TARGA';
FILE_PNG:
cFmt := 'Portable Network Graphics';
FILE_PSD:
cFmt := 'Adobe Photoshop 3.0';
FILE_BMP:
cFmt := 'Windows BMP';
FILE_OS2:
cFmt := 'OS/2 BMP version 1.x';
FILE_OS2_2:
cFmt := 'OS/2 BMP version 2.x';
FILE_WMF:
cFmt := 'Windows Meta File';
FILE_EPS:
cFmt := 'Encapsulated PostScript';
FILE_MAC:
cFmt := 'MacPaint';
FILE_PCT:
cFmt := 'Macintosh Pict';
FILE_MSP:
cFmt := 'Microsoft Paint';
FILE_IMG:
cFmt := 'GEM Image';
FILE_PCD:
cFmt := 'Kodak PhotoCD';
FILE_EPSTIFF:
cFmt := 'Encapsulated PostScript with an embedded TIFF file'
else
cFmt := 'Unknown format'
end;
// Create the message string
cMsg := fname + Chr(13) + 'Page := ' + IntToStr(pg) + ' of ' + IntToStr(RasterIO.InfoTotalPages) + Chr(13) + 'Format := ' + cFmt + Chr(13);
cMsg := cMsg + 'Width := ' + IntToStr(Trunc(LeadWidth)) + Chr(13) + 'Height := ' + IntToStr(Trunc(LeadHeight)) + Chr(13);
cMsg := cMsg + 'Size in memory := ' + IntToStr(sizm) + Chr(13) + 'Size on disk := ' + IntToStr(sizd) + Chr(13);
cMsg := cMsg + 'Bits per pixel := ' + IntToStr(bps) + Chr(13);
cMsg := cMsg + 'X resolution := ' + IntToStr(xres) + Chr(13) + 'Y resolution := ' + IntToStr(yres);
//Display the message box
MessageBox (Handle, PChar(cMsg), 'File Info', MB_OK);
end;