Available in the LEADTOOLS Imaging toolkit. |
GetArrayInfo example for Visual Basic
' This example
' 1. creates a file in memory
' 2. Calls GetInfoMemory
' 3. Displays information about the file in memory
Private Sub Command6_Click()
Dim strFormat As String
Dim nWidth As Integer
Dim nHeight As Integer
Dim nBpp As Integer
Dim nPage As Integer
Dim nSizeDisk As Long
Dim nSizeMem As Long
Dim strCompress As String
Dim nFormat As Integer
Dim strMsg As String
Dim nTotalPages As Integer
Dim xRes As Integer
Dim yRes As Integer
Dim MyVar As Variant
Dim lSize As Long
' Create the memory file
LEAD1.Load "d:\work\images\gabe.bmp", 0, 0, 1
MyVar = LEAD1.SaveArray(FILE_BMP, 4, 0)
LEAD1.Bitmap = 0
' Get information about the file
lSize = UBound(MyVar) - LBound(MyVar) + 1
LEAD1.GetArrayInfo MyVar, 1, lSize, FILEINFO_TOTALPAGES
' Read the updated properties
nFormat = LEAD1.InfoFormat
nWidth = LEAD1.InfoWidth
nHeight = LEAD1.InfoHeight
nBpp = LEAD1.InfoBits
nPage = LEAD1.InfoPage
nSizeDisk = LEAD1.InfoSizeDisk
nSizeMem = LEAD1.InfoSizeMem
strCompress = LEAD1.InfoCompress
xRes = LEAD1.InfoXRes
yRes = LEAD1.InfoYRes
nTotalPages = LEAD1.InfoTotalPages
' Translate the meaning of the format constant
Select Case nFormat
Case FILE_PCX
strFormat = "ZSoft PCX"
Case FILE_GIF
strFormat = "CompuServe GIF"
Case FILE_TGA
strFormat = "TARGA"
Case FILE_PNG
strFormat = "Portable Network Graphics"
Case FILE_PSD
strFormat = "Adobe Photoshop 3.0"
Case FILE_BMP
strFormat = "Windows BMP"
Case FILE_OS2
strFormat = "OS/2 BMP version 1.x"
Case FILE_OS2_2
strFormat = "OS/2 BMP version 2.x"
Case FILE_WMF
strFormat = "Windows Meta File"
Case FILE_EPS
strFormat = "Encapsulated PostScript"
Case FILE_PCT
strFormat = "Macintosh Pict"
Case FILE_MSP
strFormat = "Microsoft Paint"
Case FILE_IMG
strFormat = "GEM Image"
Case FILE_PCD
strFormat = "Kodak PhotoCD"
Case FILE_EPSTIFF
strFormat = "Encapsulated PostScript with an embedded TIFF file"
Case Else
strFormat = "Unknown format"
End Select
' Create the message string
strMsg = "Page = " + Str(nPage) + " of " + CStr(nTotalPages) + vbCrLf + "Format = " + strFormat + vbCrLf
strMsg = strMsg + "Width = " + Str(nWidth) + vbCrLf + "Height = " + Str(nHeight) + vbCrLf
strMsg = strMsg + "Size in memory = " + Str(nSizeMem) + vbCrLf + "Size on disk = " + Str(nSizeDisk) + vbCrLf
strMsg = strMsg + "Bits per pixel = " + Str(nBpp) + vbCrLf
strMsg = strMsg + "X resolution = " + Str(xRes) + vbCrLf + "Y resolution = " + Str(yRes)
' Display the message box
MsgBox strMsg, 0, "File Info"
End Sub