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