L_IntelligentUpScaleBitmap

#include "l_bitmap.h"

L_LTIMGSFX_API L_INT L_IntelligentUpScaleBitmap (pBitmap, pMaskBitmap, crRemoveObjectColor, crPreserveObjectColor, nNewWidth, nWidthUpScalingFactor, nNewHeight, nHeightUpScalingFactor, nUpScalingOrder, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

pBITMAPHANDLE pMaskBitmap;

/* pointer to the mask bitmap handle */

COLORREF crRemoveObjectColor;

/* color of removed area */

COLORREF crPreserveObjectColor;

/* color of preserved area */

L_INT nNewWidth;

/* new width */

L_INT nWidthUpScalingFactor;

/* number of stages for width up scaling */

L_INT nNewHeight;

/* new height */

L_INT nHeightUpScalingFactor;

/* number of stages for height up scaling */

L_INT nUpScalingOrder;

/* upscaling behavior */

L_UINT32 uFlags;

/* reserved for future */

Increases the size of the image while preserving important features automatically. Also, it preserves selected objects without affecting the natural look of the image.

This feature is available in version 16 or higher.

Parameter

Description

pBitmap

Pointer to the bitmap handle that references the bitmap on which to apply the effect.

pMaskBitmap

Pointer to the bitmap handle that references the mask bitmap. The mask bitmap is the same as the original bitmap but with a color mask on certain areas that need to be preserved during the upscaling operation. Pass NULL if there is no mask bitmap. Pass a bitmap the same size as pBitmap to prevent the function returning ERROR_INV_PARAMETER.

crRemoveObjectColor

COLORREF value that specifies the color of the area in the mask bitmap to be removed. It is best to use a color different than colors in the image. Pass INTELLIGENTRESCALE_NOREMOVECOLOR if you do not want to pass any color value.

crPreserveObjectColor

COLORREF value that specifies the color of the area in the mask bitmap to be preserved. It is best to use a different color than the color specified in crRemoveObjectColor or the original color used in the image in pBitmap. Pass INTELLIGENTRESCALE_NOREMOVECOLOR if you do not want to pass any color value.

nNewWidth

New width in pixels. Possible values are range from (width of the image +1) to (2* width of the image) -1.

nWidthUpScalingFactor

Divides the Width up scaling process into stages until the new width is achieved. This gives better results in some cases. Possible values are:

 

Value

 

If mask bitmap is used:

 

INTELLIGENTRESCALE_NOUPSCALINGFACTOR

 

Otherwise:

 

1
.
.
INTELLIGENTRESCALE_DEFAULTUPSCALINGFACTOR
.
.
20

nNewHeight

New height in pixel. Possible values are range from (height of the image +1) to (2* height of the image) -1.

nHeightUpScalingFactor

Divide the Height up scaling process into stages until the new height is achieved. This gives better results in some cases. Possible values are:

 

Value

 

If mask bitmap is used:

 

INTELLIGENTRESCALE_NOUPSCALINGFACTOR

 

Otherwise:

 

1
.
.
INTELLIGENTRESCALE_DEFAULTUPSCALINGFACTOR
.
.
20

nUpScalingOrder

Upscaling behavior. Possible values are:

 

Value

Meaning

INTELLIGENTRESCALE_VERTHORZ

Upscale the image width first, then the height.

INTELLIGENTRESCALE_HORZVERT

Upscale the image height first, then the width.

uFlags

Reserved for future. Must be zero.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Intelligent upscaling rescales the areas deemed unimportant in the image.

Upscaling using a mask is done only on the width dimension. To upscale using a mask on the height dimension, rotate the image, upscale on the width dimension, and then rotate again.

There are no upscaling steps when a mask is used. During upscale, a masked "remove area" indicates that an area is not important. Therefore, the upscale effect is concentrated in this area.

The color of the remove area must be different than colors in the pBitmap.

The color of the preserve area must be different than the colors in the pBitmap and different from the remove area color.

If multiple remove objects exist, then all of them must use the same remove color. Same thing applies to the preserve color area.

It is usually most effective to draw the mask over the remove area from the top to the bottom of the image, passing through the remove area. Make the mask wide enough to force the up scaling to concentrate more only in the remove area.

This function does not support 12 and 16-bit grayscale and 48 and 64-bit color images. If the image is 12 and 16-bit grayscale and 48 and 64-bit color, the function will not return an error.

This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.

This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.

Required DLLs and Libraries

LTIMGSFX

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:

L_SizeBitmap, L_SizeBitmapInterpolate, L_IntelligentUpScaleBitmap

Topics:

Raster Image Functions: Intelligent Rescale

 

Introduction: Intelligent Rescale

 

Using the Intelligent Rescale Demo

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName


#if defined (LEADTOOLS_V16_OR_LATER)
L_INT IntelligentUpScaleExample(L_VOID)
{
   L_INT nRet;
   BITMAPHANDLE LeadBitmap;   // Bitmap handle to hold the loaded image.

   nRet=L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("SAMPLE3.CMP")), &LeadBitmap,sizeof(BITMAPHANDLE), 0, ORDER_RGB, NULL, NULL);
   if(nRet !=SUCCESS)
      return nRet;

   nRet= L_IntelligentUpScaleBitmap(&LeadBitmap, NULL, (COLORREF)INTELLIGENTRESCALE_NOREMOVECOLOR, (COLORREF)INTELLIGENTRESCALE_NOPRESERVECOLOR,
      900, 4, LeadBitmap.Height, 4, INTELLIGENTRESCALE_VERTHORZ, 0);

   if(nRet !=SUCCESS)
      return nRet;

   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL);

   if(nRet !=SUCCESS)
      return nRet;

   return SUCCESS;
}
#endif // LEADTOOLS_V16_OR_LATER