Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.23
LEADTOOLS Common Dialog C DLL Help

L_DlgHistogram

Show in webframe

#include "l_bitmap.h"

L_LTDLG_API L_INT L_DlgHistogram(hWndOwner, pDlgParams)

L_HWND hWndOwner;

/* owner of dialog */

LPHISTOGRAMDLGPARAMS pDlgParams;

/* pointer to a HISTOGRAMDLGPARAMS structure */

Displays the Histogram dialog box.

Parameter

Description

hWndOwner

Handle of the window which owns the dialog.

pDlgParams

Pointer to a HISTOGRAMDLGPARAMS structure to be updated with the values entered by the user, through the dialog. Set members of this structure, before calling this function, to set the dialogs initial values.

Returns

SUCCESS_DLG_CLOSE

The dialog exits successfully after pressing the "Close" button.

< 1

An error occurred. Refer to Return Codes.

Comments

The Histogram dialog.

Required DLLs and Libraries

LTDLGIMG
LTDLGKRN
LTDLGUTL
LTDLGCTRL
LTDLGCOM
LTDIS
LTIMGUTL
LTIMGCLR
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

See Also

Functions:

L_DlgInit, L_GetBitmapHistogram

Topics:

Dialogs: Color Manipulation

 

Using Imaging Common Dialog

Example

// Example 1
// Example to illustrate using a bitmap to show histogram charts
 L_INT DlgHistogramFirstExample(HWND hWnd,pBITMAPHANDLE pBitmap)
{
   L_INT nRet;
   HISTOGRAMDLGPARAMS DlgParam ;

   memset ( &DlgParam, 0, sizeof ( HISTOGRAMDLGPARAMS ) ) ; 

   DlgParam.uStructSize       = sizeof ( HISTOGRAMDLGPARAMS ) ;
   DlgParam.pBitmap           = pBitmap ;
   DlgParam.crBlueChannelPen  = RGB ( 0, 0, 255 ) ;
   DlgParam.crGreenChannelPen = RGB ( 0, 255, 0 ) ;
   DlgParam.crRedChannelPen   = RGB ( 255, 0, 0 ) ;
   DlgParam.crMasterPen       = RGB ( 0, 0, 0 ) ;
   DlgParam.uDlgFlags         = DLG_HISTOGRAM_SHOW_VIEWSTYLE |
                                DLG_HISTOGRAM_USERPENCOLORS ;
   nRet = L_DlgInit ( DLG_INIT_COLOR ) ;
   if(nRet != SUCCESS && nRet != ERROR_DLG_ALREADYINITIATED)
      return nRet;
   nRet = L_DlgHistogram ( hWnd, &DlgParam ) ;
   if(nRet < 1)
      return nRet;
   nRet = L_DlgFree () ;
   if(nRet != SUCCESS)
      return nRet;
   return SUCCESS;
}

// Example 2
// Example to illustrate using histogram tables to show histogram charts
L_VOID GetBitmapHistogram(pBITMAPHANDLE pBitmap,
                          L_UINT        uChannel,
                          L_UINT        uCount,
                          L_UINT64**    lppHistogram
)
{
   // allocate histogram array
   if ( ISGRAY( pBitmap ) )
   {
      switch ( pBitmap->BitsPerPixel )
      {
      case 1:
      case 4:
      case 8 :
         {
            uCount = 256 ;
         }
         break ;

      case 12:
         {
            uCount = 4096 ;// maximum

            // is there any way to decrease buffer size?
            if ( !L_IsSupportLocked( L_SUPPORT_MEDICAL ) )
            {
               L_INT LowBit, HighBit ;

#if defined (LEADTOOLS_V16_OR_LATER)
               if ( SUCCESS == L_GetMinMaxBits( pBitmap, &LowBit, &HighBit, 0 ) )
#else
               if ( SUCCESS == L_GetMinMaxBits( pBitmap, &LowBit, &HighBit ) )
#endif
               {
                  uCount = (DWORD)1 << ( HighBit - LowBit + 1 ) ;
               }
            }
            else
            {
               return ;
            }
         }

         break ;

      case 16:
         {
            uCount = 65536 ;

            // is there any way to decrease buffer size?
            if ( !L_IsSupportLocked( L_SUPPORT_MEDICAL ) )
            {
               L_INT LowBit, HighBit ;

#if defined (LEADTOOLS_V16_OR_LATER)
               if ( SUCCESS == L_GetMinMaxBits( pBitmap, &LowBit, &HighBit, 0 ) )
#else
               if ( SUCCESS == L_GetMinMaxBits( pBitmap, &LowBit, &HighBit ) )
#endif
               {
                  uCount = (DWORD)1 << ( HighBit - LowBit + 1 ) ;
               }
            }
            else
            {
               return ;
            }
         }
         break ;

      default:
         return ;
      }
   }
   else
   {
      switch ( pBitmap->BitsPerPixel )
      {
      case 1:
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
      case 7:
      case 8:
      case 16:
      case 24:
      case 32:
         {
            uCount = 256 ;
         }
         break ;

      case 48:
      case 64:
         {
            uCount = 65536 ;
         }
         break ;

      default:
         return ;
      }
   }

   *lppHistogram = (L_UINT64 *)malloc ( uCount * sizeof ( L_UINT64 ) ) ;

   // read histogram
   L_GetBitmapHistogram( pBitmap, *lppHistogram, uCount, uChannel ) ;
}

 L_INT DlgHistogramSecondExample(HWND hWnd, pBITMAPHANDLE pBitmap)
{
   L_INT nRet;
   HISTOGRAMDLGPARAMS DlgParam ;
   L_UINT64* pTempPtr = NULL;

   memset ( &DlgParam, 0, sizeof ( HISTOGRAMDLGPARAMS ) ) ;
   DlgParam.uStructSize = sizeof ( HISTOGRAMDLGPARAMS ) ;

   pTempPtr = DlgParam.puMasterHistogram;
   GetBitmapHistogram(pBitmap,
                      CHANNEL_MASTER,
                      DlgParam.uMasterHistogramLen,
                      &pTempPtr) ;

   pTempPtr = DlgParam.puRedHistogram ;
   GetBitmapHistogram(pBitmap,
                      CHANNEL_RED,
                      DlgParam.uRedHistogramLen,
                      &pTempPtr) ;

   pTempPtr = DlgParam.puGreenHistogram;
   GetBitmapHistogram(pBitmap,
                      CHANNEL_GREEN,
                      DlgParam.uGreenHistogramLen,
                      &pTempPtr) ;

   pTempPtr = DlgParam.puBlueHistogram;
   GetBitmapHistogram(pBitmap,
                      CHANNEL_BLUE,
                      DlgParam.uBlueHistogramLen,
                      &pTempPtr) ;

   DlgParam.pBitmap           = pBitmap ;
   DlgParam.crBlueChannelPen  = RGB ( 0, 0, 255 ) ;
   DlgParam.crGreenChannelPen = RGB ( 0, 255, 0 ) ;
   DlgParam.crRedChannelPen   = RGB ( 255, 0, 0 ) ;
   DlgParam.crMasterPen       = RGB ( 0, 0, 0 ) ;
   DlgParam.uDlgFlags         = DLG_HISTOGRAM_SHOW_VIEWSTYLE |
                                DLG_HISTOGRAM_USERPENCOLORS  ;

   nRet = L_DlgInit ( DLG_INIT_COLOR ) ;
   if(nRet != SUCCESS && nRet != ERROR_DLG_ALREADYINITIATED)
      return nRet;
   nRet = L_DlgHistogram ( hWnd, &DlgParam ) ;
   if(nRet < 1)
      return nRet;
   nRet = L_DlgFree () ;
   if(nRet != SUCCESS)
      return nRet;

   free ( DlgParam.puMasterHistogram ) ;
   free ( DlgParam.puRedHistogram ) ;
   free ( DlgParam.puGreenHistogram ) ;
   free ( DlgParam.puBlueHistogram ) ;
   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.