L_StartResize

#include "l_bitmap.h"

L_LTKRN_API L_INT L_StartResize(nOldWidth, nOldHeight, nNewWidth, nNewHeight, ppResizeData)

L_INT nOldWidth;

/* original width of the image */

L_INT nOldHeight;

/* original height of the image */

L_INT nNewWidth;

/* new width for the image */

L_INT nNewHeight;

/* new height for the image */

L_VOID** ppResizeData;

/* address of a pointer for resize data */

Sets up information for the L_Resize function.

Parameter

Description

nOldWidth

Specifies the original width of the image.

nOldHeight

Specifies the original height of the image.

nNewWidth

Specifies the new width for the image.

nNewHeight

Specifies the new height for the image.

ppResizeData

Address of a pointer for a resize data packet. This specifies the area to be filled in with data for the L_Resize function. L_StartResize allocates the memory, and L_StopResize frees it. Note that you will pass the address of a pointer variable.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Required DLLs and Libraries

LTKRN

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

Windows 2000 / XP/Vista, Windows CE.

See Also

Functions:

L_ResizeBitmap, L_SizeBitmap, L_Resize, L_StopResize, L_DlgResize, L_SizeBitmapInterpolate

Topics:

Raster Image Functions: Doing Geometric Transformations

 

Resizing Considerations

Example

For complete sample code, refer to the RESIZE example. This example resizes each line in one bitmap and writes it to another bitmap.

 L_INT StartResizeExample(pBITMAPHANDLE pLeadBitmap)
{
   L_INT nRet;
   L_VOID*        pResizeData;
   L_INT          CopyWidth, CopyHeight;
   L_UCHAR*       pBuf;       /* Buffer to hold the input row */
   HGLOBAL        hBuf;       /* Handle to the input buffer */
   BITMAPHANDLE   TmpBitmap;  /* Bitmap containing input data */
   L_INT          DestRow;    /* Row counter for the output */
   L_INT          i, n;       /* Loop counters */

   /* Load the input bitmap, at 24 bits per pixel */
   nRet = L_LoadBitmap (TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\IMAGE3.CMP"), &TmpBitmap, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL);
   if(nRet != SUCCESS)
      return nRet;
   /* Allocate the buffer the size of one line of 24-bit input data */
   hBuf = GlobalAlloc(GMEM_MOVEABLE, TmpBitmap.Width * 3);
   pBuf = (L_UCHAR*)GlobalLock( hBuf );
   /* Create the new bitmap */
   if(pLeadBitmap->Flags.Allocated)
      L_FreeBitmap(pLeadBitmap);
   nRet = L_CreateBitmap(pLeadBitmap,
                        sizeof(BITMAPHANDLE),
                        TYPE_CONV,
                        TmpBitmap.Width / 2,
                        TmpBitmap.Height / 2,
                        24,
                        TmpBitmap.Order,
                        NULL,
                        TmpBitmap.ViewPerspective, NULL, 0);
   if(nRet != SUCCESS)
      return nRet;

   /* Initialize the resize process */
   nRet = L_StartResize (TmpBitmap.Width,
                        TmpBitmap.Height,
                        TmpBitmap.Width / 2,
                        TmpBitmap.Height / 2,
                        &pResizeData);
   if(nRet != SUCCESS)
      return nRet;

   /* Initialize the destination row number */
   DestRow = 0;
   /* Use L_Resize to process each row in the bitmap */
   L_AccessBitmap(pLeadBitmap);
   L_AccessBitmap(&TmpBitmap);
   for(i=0; i < TmpBitmap.Height; i++)
   {
      nRet = (L_INT)L_GetBitmapRow(&TmpBitmap, pBuf, i, TmpBitmap.BytesPerLine);
      if(nRet < 1)
         return nRet;
      nRet = L_Resize (pBuf, i, TmpBitmap.BitsPerPixel, &CopyWidth, &CopyHeight, pResizeData);
      if(nRet != SUCCESS)
      {
         if(nRet != 0)// 0 means line was not needed for the resize
            return nRet;
      }
      /* Output as many or as few rows as nRet = L_Resize supplies */
      for(n=0; n < CopyHeight; n++)
      {
         nRet =(L_INT )L_PutBitmapRow(pLeadBitmap, pBuf, DestRow, CopyWidth * 3);
         if(nRet < 1)
            return nRet;
         DestRow++;
      }
   }
   L_ReleaseBitmap(&TmpBitmap);
   L_ReleaseBitmap(pLeadBitmap);
   L_FreeBitmap(&TmpBitmap);
   /* End the resize process */
   nRet = L_StopResize (pResizeData);
   if(nRet != SUCCESS)
      return nRet;
   /* Free memory that we no longer need */
   GlobalFree(hBuf);
   return SUCCESS;
}