L_StartResize

#include "l_bitmap.h"

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

Sets up information for the L_Resize function.

Parameters

L_INT nOldWidth

Specifies the original width of the image.

L_INT nOldHeight

Specifies the original height of the image.

L_INT nNewWidth

Specifies the new width for the image.

L_INT nNewHeight

Specifies the new height for the image.

L_VOID** 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

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

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 (MAKE_IMAGE_PATH(TEXT("ImageProcessingDemo\\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; 
} 

Help Version 21.0.2021.7.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.