Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.24
LEADTOOLS Raster imaging C++ Class library help

LBitmap::IntelligentDownScale

Show in webframe

#include "ltwrappr.h"

L_INT LBitmap::IntelligentDownScale(plMaskBitmap, crRemoveObjectColor, crPreserveObjectColor, nNewWidth, nNewHeight, nDownScalingOrder, uFlags = 0)

L_INT LBitmap::IntelligentDownScale(phMaskBitmap, crRemoveObjectColor, crPreserveObjectColor, nNewWidth, nNewHeight, nDownScalingOrder, uFlags = 0)

LBitmapBase * plMaskBitmap;

/* pointer to LBitmapBase class object */

pBITMAPHANDLE phMaskBitmap;

/* 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 nNewHeight;

/* new height */

L_INT nDownScalingOrder;

/* downscaling behavior */

L_UINT32 uFlags;

/* reserved for future */

Reduces the image size while preserves important features automatically. Also, it can remove or preserve certain objects chosen by the user without affecting the natural look of the image. This feature is available in version 16 or higher.

Parameter

Description

plMaskBitmap

Pointer to LBitmapBase class object that references the mask bitmap. Mask bitmap is the same as the class object's bitmap but with a color on certain areas that need to be removed or preserved during the downscaling operation. Pass NULL if there is no mask bitmap. You will need to pass a bitmap with the same size of the class object's bitmap; otherwise, the function will return ERROR_INV_PARAMETER.

phMaskBitmap

Pointer to the mask bitmap handle that references the mask bitmap. Mask bitmap is the same as the class object's bitmap but with a color on certain areas that need to be deleted or preserved during the downscaling operation. NULL is passed if there is no mask bitmap. You will need to pass a bitmap with the same size of the class object's bitmap; otherwise, the function will return ERROR_INV_PARAMETER.

crRemoveObjectColor

COLORREF value that specifies the color of the area in the mask to be removed. It is preferred to be different than the colors used in the class object's bitmap. Pass INTELLIGENTRESCALE_NOREMOVECOLOR if you dont want to pass any color value.

crPreserveObjectColor

COLORREF value that specifies the color of the area in the mask to be preserved. It is preferred to be different than remove area color and colors in the class object's bitmap. Pass INTELLIGENTRESCALE_NOREMOVECOLOR if you dont want to pass any color value.

nNewWidth

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

nNewHeight

New height in pixels. Possible values are range from 1 to (height of the image -1).

nDownScalingOrder

Value that indicate which way the downscaling will start processing. Possible values are:

 

Value

Meaning

 

INTELLIGENTRESCALE_VERTHORZ

Downscale the image width first, then the height.

 

INTELLIGENTRESCALE_HORZVERT

Downscale the image height first, then the width.

uFlags

Reserved for future use. Must be zero

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Dark areas are at times affected during downscaling, since they are considered "unimportant."

To prevent dark objects from being affected during downscaling, negate the image, apply downscale, and then negate the image again to get the colors of the original image. Alternatively, apply a mask on dark objects.

Intelligent downscale has limitations on images that are too condensed or where the content layout prevents the downscaling to perform correctly without harming important parts.

Downscaling that is using a mask is done only on the width dimension. To downscale using a mask on the height dimension, rotate the image, downscale the width dimension, and then rotate again.

The mask color of the "remove" area must be different than colors in the image. If multiple "remove" objects are masked, all must have the same mask color.

The mask color of the "preserve" area must be different than colors in the image, and different from the remove area color. If multiple "preserve" objects are masked, then all must have the same mask color.

To make the amount of downscaling equal to the size of remove area, set the new width equal to the image width. This does NOT apply to preserve area and does NOT apply to the intelligent up scaling.

Sometimes, setting the new dimension does not totally delete the remove area. In this case, pass a new width to the original image that is less than the width of the (failed) downscaled image. For instance, if the downscaled image width is 300 pixels, but still has a few lines remaining of the remove area after downscaling, reset the width to 290 pixels and redo the downscale.

If a mask has a preserve area but no remove area, you must specify nNewWidth.

For best results, draw the mask from top to bottom of the image, passing over the remove area. Make the mask wide enough to force downscaling to be performed 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:

LBitmapBase::Size, LBitmapBase::SizeInterpolate, LBitmap::IntelligentUpScale

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 LBitmap__IntelligentDownScalExample()
{
   L_INT nRet;
   LBitmap LeadBitmap;
   nRet =LeadBitmap.Load(MAKE_IMAGE_PATH(TEXT("SAMPLE3.CMP")), 0,ORDER_BGR);
   if(nRet !=SUCCESS)
      return nRet;
   nRet =LeadBitmap.IntelligentDownScale((pBITMAPHANDLE)NULL, (COLORREF)INTELLIGENTRESCALE_NOREMOVECOLOR, (COLORREF)INTELLIGENTRESCALE_NOPRESERVECOLOR, 500, 450,INTELLIGENTRESCALE_VERTHORZ, 0);
   if(nRet !=SUCCESS)
      return nRet;
   return SUCCESS;
}
#endif
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.