L_FileInfoMemory

#include "l_bitmap.h"

L_LTFIL_API L_INT L_FileInfoMemory(pBuffer, pFileInfo, uStructSize, nBufferSize, uFlags, pLoadOptions)

Loads information about the file located in memory into a FILEINFO structure.

Parameters

L_UCHAR* pBuffer

Pointer to the location in memory of the image file.

pFILEINFO pFileInfo

Pointer to the LEAD FILEINFO structure to be filled with data from the image file.

Note: You should never pass an uninitialized FILEINFO structure to L_FileInfo.

L_UINT uStructSize

Size in bytes, of the structure pointed to by pFileInfo, for versioning. Use sizeof(FILEINFO).

L_SSIZE_T nBufferSize

The size in bytes of the file referenced by pBuffer.

L_UINT uFlags

Flag indicating whether to update the TotalPages field in the FILEINFO structure. Possible values are:

Value Meaning
FILEINFO_TOTALPAGES [0x0001] Update the pFileInfo->TotalPages field with the total number of pages in the file.
0 Do not update the pFileInfo->TotalPages field.

pLOADFILEOPTION pLoadOptions

Pointer to optional extended load options. Pass NULL to use the default load options.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

To use this function, do the following:

  1. Declare a variable with the datatype of FILEINFO.

  2. Load the file into memory and assign variables for the file's location in memory and for the file size.

  3. If you are getting information about a multi-page file (which can contain more than one image), use the LOADFILEOPTION structure to specify the page number. The information that you get will be for the image on the specified page.

  4. Initialize the FILEINFO structure to zero values.

  5. Call the L_FileInfoMemory function, passing the pointer to the file in memory, the address of the FILEINFO variable, the size of the FILEINFO structure, and the file size as parameters.

  6. Get the image information from the fields described in FILEINFO structure.

The parallelogram values retrieved by L_FileInfoMemory may not be always correct because it depends on the memory file saved data. The function does not load file objects but reads the file dimensions which may be not saved within the memory file.

For a summary of file information functions, refer to Getting and Setting File Information.

Some file formats do not contain a well-defined file signature. This is especially true for document file formats (TXT, PST, etc). LEADTOOLS can still detect the file format using the filename extension (ex. ".PST"). However, when loading files from memory the filename extension is not available. To provide this function with a filename extension, set pFileInfo.Name to the image file's name with extension and pFileInfo.Flags to FILEINFO_NAMEVALID when loading from memory.

Notes:

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

For a list of functions that utilize the LOADFILEOPTION or SAVEFILEOPTION structures, refer to Functions Utilizing the LOADFILEOPTION or SAVEFILEOPTION structures.

Example

For complete sample code, refer to the MEMORY example. This example loads a temporary bitmap, saves it as a file in memory, then gets information about the memory-resident file.

L_INT FileInfoMemoryExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE TmpBitmap;       /* Bitmap handle for the initial image      */ 
   HGLOBAL hFileInMemory=NULL;   /* Memory handle                            */ 
   L_SIZE_T uMemSize;            /* Size of the data in memory               */ 
   L_TCHAR *pData;               /* Pointer to the data in memory            */ 
   FILEINFO FileInfo;            /* LEAD File Information structure.         */ 
   L_TCHAR szMessage[1024];      /* Buffer to hold information for display.  */ 
 
   /* Load a bitmap at its own bits per pixel  */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\Image3.cmp")), &TmpBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Save the image as a CMP file in memory */ 
   nRet = L_SaveBitmapMemory(&hFileInMemory, &TmpBitmap, FILE_CMP, 24, QS, &uMemSize, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Free the temporary bitmap */ 
   if(TmpBitmap.Flags.Allocated) 
      L_FreeBitmap(&TmpBitmap); 
 
   /* Get the pointer to the memory-resident file */ 
   pData = (L_TCHAR  *) GlobalLock (hFileInMemory); 
 
   /* Get information about the file in memory  */ 
   memset(&FileInfo, 0, sizeof(FILEINFO)); 
   FileInfo.uStructSize = sizeof(FileInfo); 
   nRet = L_FileInfoMemory ((L_UCHAR *)pData, &FileInfo, sizeof(FILEINFO), uMemSize, 0, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   /* Unlock the memory */ 
   GlobalUnlock (hFileInMemory); 
 
   /* Format the message string with data from the FILEINFO structure */ 
   wsprintf(szMessage, TEXT("Format:   %d\n\n") 
                  TEXT("Width:   %d\n\n") 
                  TEXT("Height:   %d\n\n") 
                  TEXT("BitsPerPixel:   %d\n\n") 
                  TEXT("Size of File:   %ld\n\n") 
                  TEXT("Size of Bitmap:   %ld\n\n") 
                  TEXT("Compression:   %s"), 
                  FileInfo.Format, 
                  FileInfo.Width, 
                  FileInfo.Height, 
                  FileInfo.BitsPerPixel, 
                  (long)FileInfo.SizeDisk, 
                  (long)FileInfo.SizeMem, 
                  (L_TCHAR  *)FileInfo.Compression ); 
 
   /* Display the message string */ 
   MessageBox( NULL, szMessage, TEXT("File Information"), MB_OK ); 
 
   /* Clean up the test environment */ 
   GlobalFree (hFileInMemory); 
   return SUCCESS; 
} 

Help Version 20.0.2019.9.22
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help