GetFileInfo example for C++ Builder
This example gets information about the specified file.
//Declare local variables
AnsiString cMsg, cmp, cFmt, fname;
int pg, fmt;
float LeadWidth, LeadHeight;
int bps, xres, yres, sizd, sizm;
LEADRasterIO* pRasterIO= NULL;
// Initialize variables
CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL, IID_ILEADRasterIO, (void**)&pRasterIO);
fname = "c:\\temp\\test.tif";
pg = 0;
xres= pRasterIO->InfoXRes;
yres= pRasterIO->InfoYRes;
// Update the variables
pRasterIO->GetFileInfo (LEADRasterView1->Raster, AnsiToOLESTR(fname.c_str()), pg, FILEINFO_TOTALPAGES);
// Read the updated properties
fmt = pRasterIO->InfoFormat;
LeadWidth = pRasterIO->InfoWidth;
LeadHeight = pRasterIO->InfoHeight;
bps = pRasterIO->InfoBits;
pg = pRasterIO->InfoPage;
sizd = pRasterIO->InfoSizeDisk;
sizm = pRasterIO->InfoSizeMem;
cmp = pRasterIO->InfoCompress;
// Translate the meaning of the format constant
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_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";
}
// Create the message string
cMsg = fname + "\nPage = " + IntToStr(pg) + " of " + IntToStr((int)pRasterIO->InfoTotalPages) + "\nFormat = " + cFmt + "\n";
cMsg = cMsg + "Width = " + IntToStr((int)LeadWidth) + "\nHeight = " + IntToStr((int)LeadHeight) + "\n";
cMsg = cMsg + "Size in memory = " + IntToStr(sizm) + "\nSize on disk = " + IntToStr(sizd) + "\n";
cMsg = cMsg + "Bits per pixel = " + IntToStr(bps) + "\n";
cMsg = cMsg + "X resolution = " + IntToStr(xres) + "\nY resolution = " + IntToStr(yres);
pRasterIO-> Release( );
//Display the message box
MessageBox (Handle, cMsg.c_str(), "File Info", MB_OK);