Available in the LEADTOOLS Imaging toolkit. |
GetFileInfo example for C++ 4.0 and later
This example gets information about the specified file.
// Initialize variables
CString fname = "c:\\lead\\images\\image2.cmp";
// Update the variables
m_Lead1.GetFileInfo(fname, 0, FILEINFO_TOTALPAGES);
// Read the updated properties
int fmt = m_Lead1.GetInfoFormat();
float width = m_Lead1.GetInfoWidth();
float height = m_Lead1.GetInfoHeight();
int bps = m_Lead1.GetInfoBits();
int xres = m_Lead1.GetBitmapXRes();
int yres = m_Lead1.GetBitmapYRes();
int pg = m_Lead1.GetInfoPage();
long sizd = m_Lead1.GetInfoSizeDisk();
long sizm = m_Lead1.GetInfoSizeMem();
CString cmp = m_Lead1.GetInfoCompress();
// Translate the meaning of the format constant
CString cFmt;
switch (fmt)
{
case FILE_PCX:
cFmt = "ZSoft PCX";
break;
case FILE_GIF:
cFmt = "CompuServe GIF";
break;
case FILE_TGA:
cFmt = "TARGA";
break;
case FILE_PNG:
cFmt = "Portable Network Graphics";
break;
case FILE_PSD:
cFmt = "Adobe Photoshop 3.0";
break;
case FILE_BMP:
cFmt = "Windows BMP";
break;
case FILE_OS2:
cFmt = "OS/2 BMP version 1.x";
break;
case FILE_OS2_2:
cFmt = "OS/2 BMP version 2.x";
break;
case FILE_WMF:
cFmt = "Windows Meta File";
break;
case FILE_EPS:
cFmt = "Encapsulated PostScript";
break;
case FILE_TIF:
cFmt = "Tagged Image File Format (TIFF, TIFLZW, or CCITT file)";
break;
case FILE_TIF_JPEG:
cFmt = "Tagged Image File with JPEG compression";
break;
case FILE_FAX_G3_1D:
cFmt = "Raw FAX, compressed using CCITT group 3, 1 dimension";
break;
case FILE_FAX_G3_2D:
cFmt = "Raw FAX, compressed using CCITT group 3, 2 dimensions";
break;
case FILE_FAX_G4:
cFmt = "Raw FAX, compressed using CCITT group 4";
break;
case FILE_WFX_G3_1D:
cFmt = "WinFax, compressed using CCITT group 3, 1 dimension";
break;
case FILE_WFX_G4:
cFmt = "WinFax, compressed using CCITT group 4";
break;
case FILE_ICA_G3_1D:
cFmt = "IOCA, compressed using CCITT group 3, 1 dimension";
break;
case FILE_ICA_G3_2D:
cFmt = "IOCA, compressed using CCITT group 3, 2 dimensions";
break;
case FILE_ICA_G4:
cFmt = "IOCA, compressed using CCITT group 4";
break;
case FILE_CMP:
cFmt = "LEAD proprietary compression format";
break;
case FILE_CMP_NOLOSS:
cFmt = "LEAD lossless compression format";
break;
case FILE_JPEG:
cFmt = "JPEG File Interchange Format";
break;
case FILE_WPG:
cFmt = "WordPerfect";
break;
case FILE_RAS:
cFmt = "Sun Raster";
break;
case FILE_CALS:
cFmt = "CALS Raster";
break;
case FILE_MAC:
cFmt = "MacPaint";
break;
case FILE_PCT:
cFmt = "Macintosh Pict";
break;
case FILE_MSP:
cFmt = "Microsoft Paint";
break;
case FILE_IMG:
cFmt = "GEM Image";
break;
case FILE_PCD:
cFmt = "Kodak PhotoCD";
break;
case FILE_EPSTIFF:
cFmt = "Encapsulated PostScript with an embedded TIFF file";
break;
default:
cFmt = "Unknown format";
break;
}
// Create the message string
char szMsg[512];
wsprintf(szMsg, "%s\n"
"Page = %u of %u\n"
"Format = %s\n"
"Width = %u\n"
"Height = %u\n"
"BitsPerPixel = %u\n"
"X resolution = %u\n"
"Y resolution = %u\n",
LPCSTR(fname), (UINT) pg, (UINT)m_Lead1.GetInfoTotalPages(), LPCSTR(cFmt),
(UINT) width, (UINT) height, (UINT) bps,
(UINT) xres, (UINT) yres);
MessageBox(szMsg, "File Info");