L_SetSaveResolution

#include "l_bitmap.h"

L_LTFIL_API L_INT L_SetSaveResolution(uCount, pResolutions)

L_UINT uCount;

/* number of resolutions to be saved in a file */

pDIMENSION pResolutions;

/* pointer to the array which holds the resolutions to be saved */

Sets resolutions for the next save operation.

Parameter

Description

uCount

Specifies the number of resolutions to be saved in a file. Or, specify 0 to save only the actual size of the image as a single dimension in the file.

pResolutions

Pointer to the array of DIMENSION structures which hold the resolutions to be saved.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Currently, this function only works with the JBIG format.

A JBIG, FlashPix or PhotoCD file can contain more than one copy of the same image, each at a different physical resolution (width and height in pixels).

For JBIG files, uCount refers to the number of resolution layers to be saved in the file. The maximum number of resolutions that can be saved is 29.

For a JBIG file, the values of different resolutions are implied because the dimensions of each resolution layer are half the dimensions of the one directly above it.

pResolutions[0] is used to determine the highest resolution layer which will be saved in a file. You can fill pResolutions[0] with an actual width and height, or you can fill either the width or height with a valid value, and specify 0 for the other dimension to allow LEADTOOLS to calculate that dimension based on the image's aspect ratio during the next save operation. Note that for JBIG, all the values set in pResolutions are stored, but only pResolutions[0] is used during an actual file save process.

Ex.

uCount = 3
pResolution[0].nWidth = 800
pResolution[0].nHeight = 0

If you then save an image that is 1600 x 1200, the resolutions that are stored in the file would be:

800 x 600

400 x 300

200 x 150

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.

Platforms

Win32, x64, Mobile.

See Also

Functions:

L_GetSaveResolution, L_ReadLoadResolutions, L_SetLoadResolution, L_GetLoadResolution
For Vector files: L_2DGetViewMode, L_2DSetViewMode, L_2DGetViewPort, L_2DSetViewPort

Topics:

Raster Image Functions: Saving Files

 

Raster Image Functions: Getting and Setting File Information

 

Implementing JBIG Features

Example

This example saves the same image in three different resolutions and in three different files.

 L_INT SetSaveResolutionExample(L_TCHAR     * pszFilename,pBITMAPHANDLE pLeadBitmap)
{
   L_INT nRet;
   DIMENSION Resolutions; /* Dimension structure */
   L_TCHAR szName[256];   /* File Name sting     */
  
   /* Default case,save only one resolution layer. */
   nRet = L_SetSaveResolution (0, &Resolutions);
   if(nRet != SUCCESS)
      return nRet;
   wsprintf(szName, TEXT("%s_1"),pszFilename);
   nRet = L_SaveBitmap(szName,pLeadBitmap,FILE_JBIG,1,0, NULL);
   if(nRet != SUCCESS)
      return nRet;

   /* Save 2 resolution layers,the highest resolution layer holds the image at full dimensions because
      Resolutions.nWidth is equal to the FULL WIDTH of the original image */
   Resolutions.nWidth= BITMAPWIDTH(pLeadBitmap);
   Resolutions.nHeight=0;
   wsprintf(szName, TEXT("%s_2"),pszFilename);
   nRet = L_SetSaveResolution (2, &Resolutions);
   if(nRet != SUCCESS)
      return nRet;
   nRet = L_SaveBitmap(szName,pLeadBitmap,FILE_JBIG,1,0, NULL);
   if(nRet != SUCCESS)
      return nRet;

   /* Save 3  resolution layers,the highest resolution layer holds the image at half
      the full image dimensions becuase Resolutions.nHeight is equal to HALF THE FULL HEIGHT of the original image. */
   Resolutions.nWidth= 0;
   Resolutions.nHeight=BITMAPHEIGHT(pLeadBitmap)/2;
   wsprintf(szName, TEXT("%s_3"),pszFilename);
   nRet = L_SetSaveResolution (3, &Resolutions);
   if(nRet != SUCCESS)
      return nRet;
   nRet = L_SaveBitmap(szName,pLeadBitmap,FILE_JBIG,1,0, NULL);
   if(nRet != SUCCESS)
      return nRet;
   return SUCCESS;
}