LMemoryFile::LoadMemory

#include "ltwrappr.h"

virtual L_INT LMemoryFile::LoadMemory(LMemoryBuffer, nBitsPerPixel=0, nOrder=ORDER_BGRORGRAY, uFlags=LOADFILE_ALLOCATE|LOADFILE_STORE, pLoadFileOption=NULL)

LBuffer& LMemoryBuffer;

/* an LBuffer object */

L_INT nBitsPerPixel;

/* resulting bitmap pixel depth */

L_INT nOrder;

/* color order */

L_UINT uFlags;

/* flags that indicate the behavior of the function */

pLOADFILEOPTION pLoadFileOption;

/* pointer to optional extended load options */

Loads any supported file from memory.

Parameter

Description

LMemoryBuffer

A LEAD buffer into which the file in memory will be loaded.

nBitsPerPixel

Resulting bitmap pixel depth. Possible values are:

 

Value

Meaning

 

0

Keep the original file's pixel depth (Do not convert). A special note about loading 12 and 16-bit grayscale images.

 

1 to 8

The specified bits per pixel in the resultant bitmap

 

12

12 bits per pixel in the resultant bitmap.

 

16

16 bits per pixel in the resultant bitmap

 

24

24 bits per pixel in the resultant bitmap

 

32

32 bits per pixel in the resultant bitmap

 

48

48 bits per pixel in the resultant bitmap

 

64

64 bits per pixel in the resultant bitmap

nOrder

The desired color order.  Possible values are:

 

Value

Meaning

 

ORDER_RGB

[0] Red-green-blue order.

 

ORDER_BGR

[1] Blue-green-red order.

 

ORDER_GRAY

[2] 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are only supported in Document/Medical toolkits.

 

0

The data is 8 bits per pixel or less.

 

ORDER_RGBORGRAY

[3] Load the image as red, green, blue OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in the Document/Medical toolkits only.

 

ORDER_BGRORGRAY

[4] Load the image as blue, green, red OR as a 12 or 16-bit grayscale image. 12 and 16-bit grayscale images are supported in the Document/Medical toolkits only.

uFlags

Binary flags that determine the behavior of LMemoryFile::LoadMemory. You can specify one or more of the following values:

 

Value

Meaning

 

LOADFILE_ALLOCATE

[0x0001] The function allocates memory for the specified bitmap.

 

LOADFILE_STORE

[0x0002] The function loads data into the specified bitmap. (This takes place in addition to the actions of your callback function.)

 

LOADFILE_FIXEDPALETTE

[0x0004] This flag will force a palletized image to be dithered to a fixed palette.

 

LOADFILE_NOINTERLACE

[0x0008] The function passes image data in the order that is displayed, regardless of how it is stored in the file. (Set this flag if your program does not handle interlaced file formats.)

 

LOADFILE_ALLPAGES

[0x0010] The function loads all pages of a multipage file. Use this flag only if you are creating a bitmap list using the LPlayBack::Append function.

 

LOADFILE_COMPRESSED

[0x0040] (Document/Medical only) If possible, load the file as a 1-bit RLE-compressed image. For more information, refer to Speeding Up 1-Bit Documents.

pLoadFileOption

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

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function supports the LMemoryFile::LoadMemoryCallBack virtual function.

Support for 12 and 16-bit grayscale images is only available in the Document/Medical toolkits.

Before calling this function, you may need to get or set file information, such as the page number of a multipage file. Refer to Getting and Setting File Information.

Note: This function does not support Kodak PhotoCD (PCD), Kodak FlashPix (FPX), or Microsoft FAX (AWD) files.

Note: More options are available in the LOADFILEOPTION structure.

The LMemoryBuffer parameter is passed by reference, and is a required parameter.

This function cannot be used in combination with the Redirect input / output functions.

Note: For information on loading and saving large TIFF files faster, refer to Loading and Saving Large TIFF Files.

Required DLLs and Libraries

LTFIL
File format DLLs

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

Class Members, LBitmapBase::GetLoadStatus, LFile::LoadCMYKArray, LFile::SaveCMYKArray, LPaint::PaintDCCMYKArray, LFileSettings::GetLoadResolution, LFileSettings::GetPCDResolution, LFileSettings::GetWMFResolution, LFileSettings::SetLoadResolution, LFileSettings::SetPCDResolution, LFileSettings::SetWMFResolution, LFileSettings::GetViewMode2D, LFileSettings::GetViewPort2D, LFileSettings::SetViewMode2D, LFileSettings::SetViewPort2D, LFileSettings::GetWMFResolutionExt, LFileSettings::SetWMFResolutionExt

Topics:

Raster Image Functions: Loading Files

 

Raster Image Functions: Redirecting Input and Output

 

Raster Image Functions: Input and Output

 

Loading and Saving Images

 

Using a PanWindow

Example

// define user LMemoryFile class to override its CallBacks
class LUserMemoryFile : public LMemoryFile
{
   public:
      LUserMemoryFile() ;
      virtual ~LUserMemoryFile() ;
      virtual L_INT LoadMemoryCallBack(pFILEINFO pFileInfo,
       LBitmapBase L_FAR* pLBitmap,
       LBuffer L_FAR* pLBuffer,
       L_UINT uFlags,
       L_INT nRow,
       L_INT nLines);
};

LUserMemoryFile::LUserMemoryFile()
{
}

LUserMemoryFile::~LUserMemoryFile()
{
}

L_INT LUserMemoryFile::LoadMemoryCallBack(pFILEINFO pFileInfo,
   LBitmapBase L_FAR* pLBitmap,
   LBuffer L_FAR* pLBuffer,
   L_UINT uFlags,
   L_INT nRow,
   L_INT nLines)
{
   return SUCCESS ;
}

L_INT TestLoadMemFunction(LBitmapBase& LeadBitmap)
{
   LUserMemoryFile userLeadMemFile ;
   LBuffer LeadMemBuffer ;
   FILEINFO FileInfo;

   if (userLeadMemFile.IsValid() == FALSE)
      userLeadMemFile.SetBitmap(&LeadBitmap) ;

   userLeadMemFile.EnableCallBack(TRUE) ;

   userLeadMemFile.SaveBitmap(&LeadMemBuffer,FILE_LEAD,24,QS, NULL) ;

   userLeadMemFile.GetInfo (LeadMemBuffer,&FileInfo, sizeof(FILEINFO), NULL) ;

   LeadBitmap.Free();

   LeadBitmap.Initialize(FileInfo.Width, FileInfo.Height, FileInfo.BitsPerPixel) ;

   userLeadMemFile.LoadMemory( LeadMemBuffer, 0, ORDER_BGR, LOADFILE_ALLOCATE | LOADFILE_STORE, NULL) ;

   return SUCCESS ;
}