LBitmapBase::LoadResize

#include "ltwrappr.h"

virtual L_INT LBitmapBase::LoadResize(pszFile, nDestWidth, nDestHeight, nDestBits, uFlags, nOrder, pLoadOptions, pFileInfo)

virtual L_INT LBitmapBase::LoadResize(nDestWidth, nDestHeight, nDestBits, uFlags, nOrder, pLoadOptions, pFileInfo)

L_TCHAR * pszFile;

/* name of the file to load */

L_INT nDestWidth;

/* new width of the image */

L_INT nDestHeight;

/* new height of the image */

L_INT nDestBits;

/* resulting bitmap pixel depth */

L_UINT32 uFlags;

/* flags */

L_INT nOrder;

/* color order for 16-, 24-, 32-, 48, and 64-bit bitmaps */

pLOADFILEOPTION pLoadOptions;

/* pointer to optional extended load options */

pFILEINFO pFileInfo;

/* pointer to a structure */

Loads an image file into the class object's bitmap, resizing the bitmap as it loads, to the desired width, height, and bits per pixel. The file can be in any supported image file format and bits per pixel, whether compressed or uncompressed.

Parameter

Description

pszFile

Character string containing the name of the file to load.

nDestWidth

New width of the image.

nDestHeight

New height of the image.

nDestBits

Resulting bitmap pixel depth. The following are valid values:

 

Value

Meaning

 

0

Keep the original file's pixel depth (Do not convert).

 

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

uFlags

Flag that indicates the type of resizing to use. Possible values are:

 

Value

Meaning

 

SIZE_NORMAL

[0x0] Normal resizing.

 

SIZE_RESAMPLE

[0x2] Linear interpolation resizing.

 

SIZE_BICUBIC

[0x4] Bicubic interpolation resizing.

nOrder

Color order for 16-, 24-, 32-, 48-, and 64-bit bitmaps. If the resultant bitmap is less than 16 bits per pixel, this will have no effect since palletized images have no order. The following are valid values:

 

Value

Meaning

 

ORDER_RGB

[0] Red, green, and blue color order in memory

 

ORDER_BGR

[1] Blue, green, and red color order in memory

 

ORDER_GRAY

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

 

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.

pLoadOptions

Pointer to a LOADFILEOPTION structure that contains optional extended load options. Pass NULL to use the default load options.

pFileInfo

Pointer to a FILEINFO structure. This structure may contain file information used in loading an image, or it may be updated with information about the file being loaded.

 

If nothing is known about the file, pass NULL for this parameter, or declare a variable of type FILEINFO and set the FILEINFO.Flags to 0, then pass the address of the FILEINFO structure in this parameter. In this case, if the address of a FILEINFO structure is passed, the FILEINFO structure will be updated with the results of LFile::GetInfo.

 

If only the file type is known, set pFileInfo.Format to the file type and set pFileInfo.Flags to FILEINFO_FORMATVALID. This can also be done if LFile::GetInfo has been called previously, but values that affect the size of the image loaded have been changed (for example, by calling LFileSettings::SetPCDResolution or LFileSettings::SetWMFResolution). In this case the FILEINFO structure pointed to by pFileInfo will be updated with the results of LFile::GetInfo.

 

If LFile::GetInfo has been called prior to calling this function, and no changes have been made to the contents of the structure filled by LFile::GetInfo, then the address of the filled FILEINFO structure can be passed for this parameter. In this case, the FILEINFO.Flags member should be set to FILEINFO_INFOVALID. The LFile::GetInfo function will set the FILEINFO.Flags to FILEINFO_INFOVALID. In this case the load will be faster since this function does not have to query the file filters for the file type.

 

Note: Local variables are not initialized (since they are placed on the stack). So if you have a FILEINFO structure as a local variable, the value of its Flags parameter is undefined, possibly having FILEINFO_INFOVALID or FILEINFO_FORMATVALID set. That is why it is important to initialize FILEINFO.Flags before passing the address of the FILEINFO structure to the function.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function resizes a file as it loads, to the desired width, height, and bits per pixel. Note that the original file is not completely loaded into memory. This function is ideal for sampling large images (i.e. generating a thumbnail) without the memory overhead of loading the large file itself.

For supported formats, refer to Files To Be Included With Your Application.

Required DLLs and Libraries

LTFIL

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

Platforms

Win32, x64.

See Also

Functions:

LBitmapBase::Save, LBitmapBase::SetFileName, LFileSettings::GetLoadResolution, LFileSettings::GetPCDResolution, LFileSettings::GetWMFResolution, LFileSettings::SetLoadResolution, LFileSettings::SetPCDResolution, LFileSettings::SetWMFResolution, LBitmapWindow::CreatePanWnd, LFileSettings::GetViewMode2D, LFileSettings::GetViewport2D, LFileSettings::SetViewMode2D, LFileSettings::SetViewport2D, LFileSettings::GetWMFResolution, LFileSettings::SetWMFResolution

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

 

Files and File Formats

Example

The following samples load and resize an image to 400 pixels high.

The width of the bitmap is determined by the aspect ratio.

Bicubic interpolation is used in the resize.

The bitmap is loaded at the original bits per pixel.

// This is an example for the first version of the function

L_INT LBitmapBase__LoadResizeFirstExample(LBitmapBase & Bitmap, L_TCHAR * pszFile)
{
   
   return Bitmap.LoadResize(pszFile , 0, 400, 0, SIZE_BICUBIC, 
                            ORDER_BGR, NULL, NULL);
}
// This is an example for the second version of the function
L_INT LBitmapBase__LoadResizeSecondExample(LBitmapBase & Bitmap, L_TCHAR * pszFile)
{
   Bitmap.SetFileName (pszFile);
   return Bitmap.LoadResize(0, 400, 0, SIZE_BICUBIC, ORDER_BGR,                      
                            NULL, NULL);
}