Available in the LEADTOOLS Imaging toolkit. |
GetFileInfo example for Visual J++
This example gets information about the specified file.
// Initialize variables
String strFileName = "c:\\lead\\images\\image2.cmp";
short sPage = 0;
// Update the variables
LEAD1.GetFileInfo( strFileName, sPage, 0 );
// Read the updated properties
short sFormat = LEAD1.getInfoFormat();
int nLeadWidth = (int) LEAD1.getInfoWidth();
int nLeadHeight = (int) LEAD1.getInfoHeight();
short sBPS = LEAD1.getInfoBits();
sPage = LEAD1.getInfoPage();
int nSizeD = LEAD1.getInfoSizeDisk();
int nSizeM = LEAD1.getInfoSizeMem();
String strCmp = LEAD1.getInfoCompress();
// Translate the meaning of the format constant
String strFormat = "";
switch( sFormat )
{
case LTOCXU.FileConstants.FILE_PCX :
strFormat = "ZSoft PCX";
break;
case LTOCXU.FileConstants.FILE_GIF :
strFormat ="CompuServe GIF";
break;
case LTOCXU.FileConstants.FILE_TGA :
strFormat ="TARGA";
break;
case LTOCXU.FileConstants.FILE_PNG :
strFormat ="Portable Network Graphics";
break;
case LTOCXU.FileConstants.FILE_PSD :
strFormat ="Adobe Photoshop 3.0";
break;
case LTOCXU.FileConstants.FILE_BMP :
strFormat ="Windows BMP";
break;
case LTOCXU.FileConstants.FILE_OS2 :
strFormat ="OS/2 BMP version 1.x";
break;
case LTOCXU.FileConstants.FILE_OS2_2 :
strFormat ="OS/2 BMP version 2.x";
break;
case LTOCXU.FileConstants.FILE_WMF :
strFormat ="Windows Meta File";
break;
case LTOCXU.FileConstants.FILE_EPS :
strFormat ="Encapsulated PostScript";
break;
.
.
.
case LTOCXU.FileConstants.FILE_MAC :
strFormat ="MacPaint";
break;
case LTOCXU.FileConstants.FILE_PCT :
strFormat ="Macintosh Pict";
break;
case LTOCXU.FileConstants.FILE_MSP :
strFormat ="Microsoft Paint";
break;
case LTOCXU.FileConstants.FILE_IMG :
strFormat ="GEM Image";
break;
case LTOCXU.FileConstants.FILE_PCD :
strFormat ="Kodak PhotoCD";
break;
case LTOCXU.FileConstants.FILE_EPSTIFF :
strFormat ="Encapsulated PostScript with an embedded TIFF file";
break;
default :
strFormat ="Unknown format";
}
// Create the message string
String strMsg = strFileName + "\nPage = " + sPage + " of " + LEAD1.getInfoTotalPages() + "\nFormat = " + strFormat;
strMsg += "\nWidth = " + nLeadWidth + "\nHeight = " + nLeadHeight;
strMsg += "\nSize in memory = " + nSizeM + "\nSize on disk = " + nSizeD;
strMsg += "\nBits per pixel = " + sBPS;
// Display the message box
MessageBox.show( strMsg, "File Info", MessageBox.OK );