Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.11.1
LEADTOOLS Raster Imaging C DLL Help

L_SetStatusCallBack

Show in webframe

#include "l_bitmap.h"

L_LTKRN_API L_VOID L_SetStatusCallBack(pfnCallback, pUserData, pfnOldCallback, ppOldUserData)

STATUSCALLBACK pfnCallback;

/* pointer to your callback function */

L_VOID* pUserData;

/* pointer to more parameters for the callback */

STATUSCALLBACK* pfnOldCallback;

/* pointer to old callback function */

L_VOID** ppOldUserData;

/* pointer to more parameters for the old callback */

Sets the new status callback function and gets the old status callback.

Parameter

Description

pfnCallback

Pointer to your callback function. The callback function must adhere to the function syntax specified in STATUSCALLBACK Function.

 

This callback function must return SUCCESS if the operation was successfully done, or any error if the function call was a failure. If the callback function returns a failure, the current function will terminate and return the same error that the callback returned.

pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

 

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID  *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.

 

If the additional parameters are not needed, you can pass NULL in this parameter.

pfnOldCallback

Pointer to a variable which will be updated with the old status callback function

ppOldUserData

Pointer to a variable which will be updated with the user data for the old status callback function

Returns

None.

Comments

The status callback is returned through a parameter. You used to have to call L_GetStatusCallBack to get the user data prior to calling L_SetStatusCallback. Now you can get the old callback and set the new callback in one function call.

You can use this function to specify a callback for any of the following functions:

L_AddBitmapNoise
L_AverageFilterBitmap

L_BinaryFilterBitmap

L_ChangeBitmapContrast

L_ChangeBitmapHue

L_ChangeBitmapIntensity

L_ChangeBitmapSaturation

L_ClearBitmap

L_ColorMergeBitmap

L_ColorSeparateBitmap

L_CombineBitmap

L_DeskewBitmap

L_DespeckleBitmap

L_EmbossBitmap

L_FillBitmap

L_FlipBitmap

L_GammaCorrectBitmap

L_GetBitmapHistogram

L_GrayScaleBitmap

L_HalfToneBitmap

L_HistoEqualizeBitmap

L_IntensityDetectBitmap

L_InvertBitmap

L_MedianFilterBitmap

L_MMConvertFromBitmapList(Video Module only)
L_MMSaveFile(Video Module only)
L_MosaicBitmap

L_PaintDCEffect

L_PosterizeBitmap

L_PrintBitmap

L_RemapBitmapIntensity

L_ResizeBitmap

L_ReverseBitmap

L_RotateBitmap

L_SharpenBitmap

L_ShearBitmap

L_SizeBitmap

L_SpatialFilterBitmap

L_StretchBitmapIntensity

L_UnderlayBitmap

Both the old status callback function and the user data required for the old status callback function are updated in the pfnOldCallbaclk and ppOldUserData parameters, respectively.

1.

Call the L_SetStatusCallBack function, assigning its return value to a STATUSCALLBACK variable, and passing the pointer to your callback as the new value.

2.

Call the function that uses the callback (for example L_AverageFilterBitmap).

3.

Call the L_SetStatusCallBack function again, restoring the original value by passing the variable that you saved in Step 1.

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

Win32, x64, Linux.

See Also

Functions:

STATUSCALLBACK, L_GetStatusCallBack

Topics:

Using Callback Functions

Example

/* This is the STATUSCALLBACK function, which stops the process if the user has pressed the interrupt key. */
L_BOOL KillProgress;

L_INT EXT_CALLBACK StatusCallBack (L_INT nPercent, L_VOID *pUserData)
{
   HWND hWnd=NULL;
   L_TCHAR achMsg[80]; /* message string */
   MSG msg;

   hWnd = (HWND)pUserData;

   /* Let the application detect other events - good for cancel */
   while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
   {
      TranslateMessage (&msg);
      DispatchMessage (&msg);
   }

   /* Check the global variable and return an error if necessary */
   if (KillProgress)
   {
      wsprintf (achMsg, TEXT("Interrupted by the user with %d percent finished"),nPercent);
      MessageBox (hWnd, achMsg, TEXT("Notice"), MB_OK);
      return (ERROR_USER_ABORT);
   }

   wsprintf(achMsg, TEXT("Percentage: %d\n"), nPercent);
   OutputDebugString(achMsg);

   return SUCCESS;
}

/* This function uses L_SetStatusCallBack to implement the STATUSCALLBACK
function when applying a median filter. */
L_INT SetStatusCallbackExample(BITMAPHANDLE *pBitmap)
{
   STATUSCALLBACK lpfnOldStatusCB;  /* Pointer to the previous STATUSCALLBACK function */
   L_INT nRet=SUCCESS;
   L_VOID * pOldData; /* Pointer to the user data for the previous status callback function */
   /* Set the STATUSCALLBACK function, saving the pointer to the previous one */
   L_SetStatusCallBack(StatusCallBack, NULL, &lpfnOldStatusCB, &pOldData );
   /* Apply an intentionally slow median filter with a neighborhood of 7x7 pixels */
   KillProgress = FALSE;

#if defined (LEADTOOLS_V16_OR_LATER)
   nRet = L_MedianFilterBitmap(pBitmap, 7, 0);
#else
   nRet = L_MedianFilterBitmap(pBitmap, 7 );
#endif
   /* Restore the previous STATUSCALLBACK function */
   L_SetStatusCallBack (lpfnOldStatusCB, pOldData, NULL, NULL);
   return nRet;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.