Available in the LEADTOOLS Imaging toolkit. |
GetFileInfo example for Visual Basic
This example gets information about the specified file.
' Declare local variables
Dim fname, pg, fmt, LeadWidth, LeadHeight, bps, xres, yres, sizd, sizm, cmp, cFmt, cMsg, answer
' Initialize variables
fname = "c:\lead\images\image2.cmp"
pg = 0
' Update the variables
Lead1.GetFileInfo fname, pg, FILEINFO_TOTALPAGES
' Read the updated properties
fmt = Lead1.InfoFormat
LeadWidth = Lead1.InfoWidth
LeadHeight = Lead1.InfoHeight
bps = Lead1.InfoBits
pg = Lead1.InfoPage
sizd = Lead1.InfoSizeDisk
sizm = Lead1.InfoSizeMem
cmp = Lead1.InfoCompress
' Translate the meaning of the format constant
Select Case fmt
Case FILE_PCX
cFmt = "ZSoft PCX"
Case FILE_GIF
cFmt = "CompuServe GIF"
Case FILE_TGA
cFmt = "TARGA"
Case FILE_PNG
cFmt = "Portable Network Graphics"
Case FILE_PSD
cFmt = "Adobe Photoshop 3.0"
Case FILE_BMP
cFmt = "Windows BMP"
Case FILE_OS2
cFmt = "OS/2 BMP version 1.x"
Case FILE_OS2_2
cFmt = "OS/2 BMP version 2.x"
Case FILE_WMF
cFmt = "Windows Meta File"
Case FILE_EPS
cFmt = "Encapsulated PostScript"
.
.
.
Case FILE_MAC
cFmt = "MacPaint"
Case FILE_PCT
cFmt = "Macintosh Pict"
Case FILE_MSP
cFmt = "Microsoft Paint"
Case FILE_IMG
cFmt = "GEM Image"
Case FILE_PCD
cFmt = "Kodak PhotoCD"
Case FILE_EPSTIFF
cFmt = "Encapsulated PostScript with an embedded TIFF file"
Case Else
cFmt = "Unknown format"
End Select
' Create the message string
cMsg = fname + Chr(13) + "Page = " + Str(pg) + " of " + CStr(LEAD1.InfoTotalPages) + Chr(13) + "Format = " + cFmt + Chr(13)
cMsg = cMsg + "Width = " + Str(LeadWidth) + Chr(13) + "Height = " + Str(LeadHeight) + Chr(13)
cMsg = cMsg + "Size in memory = " + Str(sizm) + Chr(13) + "Size on disk = " + Str(sizd) + Chr(13)
cMsg = cMsg + "Bits per pixel = " + Str(bps) + Chr(13)
cMsg = cMsg + "X resolution = " + Str(xres) + Chr(13) + "Y resolution = " + Str(yres)
' Display the message box
MsgBox cMsg, 0, "File Info"