L_DlgPNGWebTuner

#include "l_bitmap.h"

L_LTDLG_API L_INT L_DlgPNGWebTuner(hWndOwner, pDlgParams)

L_HWND hWndOwner;

/* owner of dialog */

LPPNGWEBTUNERDLGPARAMS pDlgParams;

/* pointer to a structure */

Displays the PNG Web Tuner dialog box, and gets the tuning options used by L_ColorResBitmap, L_FillBitmap, L_SaveBitmap and L_SetBitmapRgnColorRGBRange.

Parameter

Description

hWndOwner

Handle of the window, which owns the dialog.

pDlgParams

Pointer to a PNGWEBTUNERDLGPARAMS 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.

Comments

The PNG Web Tuner dialog.

Returns

SUCCESS_DLG_OK

The "OK" button was pressed, and the dialog exited successfully.

SUCCESS_DLG_CLOSE

The "Close" button was pressed, and the dialog exited successfully.

SUCCESS_DLG_CANCEL

The "Cancel" button was pressed, and the dialog exited successfully.

< 1

An error occurred. Refer to Return Codes.

Required DLLs and Libraries

LTDLGWEB
LTDLGKRN
LTDLGUTL
LTDLGCTRL
LTDLGCOM
LTDIS
LTIMG
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_SaveBitmap, L_DlgGIFWebTuner, L_DlgJPEGWebTuner

Topics:

Dialogs: HTML/Web

 

Using Imaging Common Dialog

Example

// Example 1:
 L_INT DlgPNGWebTunerFirstExample(HWND hWnd,pBITMAPHANDLE pBitmap)
{
   L_INT nRet;
   PNGWEBTUNERDLGPARAMS DlgParams ;

   memset ( &DlgParams, 0, sizeof ( PNGWEBTUNERDLGPARAMS ) ) ;

   DlgParams.uStructSize   = sizeof ( PNGWEBTUNERDLGPARAMS ) ;
   DlgParams.pBitmap       = pBitmap ;
   DlgParams.uDlgFlags     = DLG_PNGWEBTUNER_SHOW_EXPORT           |
                             DLG_PNGWEBTUNER_SHOW_INFORMATION      |
                             DLG_PNGWEBTUNER_SHOW_PREVIEW          |
                             DLG_PNGWEBTUNER_SHOW_TOOL_ZOOMLEVEL   |
                             DLG_PNGWEBTUNER_SHOW_TOOL_COLORPICKER |
                             DLG_PNGWEBTUNER_SHOW_TRANSPARENCY     |
                             DLG_PNGWEBTUNER_SHOW_ADDWINDOWCOLOR   ;

   nRet = L_DlgInit ( DLG_INIT_COLOR ) ;
   if(nRet != SUCCESS && nRet != ERROR_DLG_ALREADYINITIATED)
      return nRet;

   nRet = L_DlgPNGWebTuner ( hWnd, &DlgParams ) ;
   if(nRet < 1)
      return nRet;

   nRet = L_DlgFree ( ) ;
   if(nRet != SUCCESS)
      return nRet;
   return SUCCESS;
} ;

// Example 2:
static COLORREF AddTolerance(COLORREF   crColor,
                             L_INT      nTolerance)
{
   L_INT nRed ;
   L_INT nGreen ;
   L_INT nBlue ;

   nRed   = max ( min ( ( L_INT ) GetRValue ( crColor ) + nTolerance, 255 ), 0 ) ;
   nGreen = max ( min ( ( L_INT ) GetGValue ( crColor ) + nTolerance, 255 ), 0 ) ;
   nBlue  = max ( min ( ( L_INT ) GetBValue ( crColor ) + nTolerance, 255 ), 0 ) ;

   return RGB ( nRed, nGreen, nBlue ) ;
}

static L_VOID ExportBitmap(L_TCHAR*                 szFileName,
                           pBITMAPHANDLE            pBitmap,
                           LPPNGWEBTUNERDLGPARAMS   pParam)
{
   {// TRANSPERANCY
      if ( pParam->bTransparent ) 
      {
         COLORREF crTransparentStart ;
         COLORREF crTransparentEnd ;

         crTransparentStart = AddTolerance ( pParam->crTransparent, 
                                             - pParam->nTransparencyTolerance ) ;

         crTransparentEnd   = AddTolerance ( pParam->crTransparent, 
                                             pParam->nTransparencyTolerance ) ;
         // reset
         L_FreeBitmapRgn ( pBitmap ) ;

         // set attributes
         pBitmap->Flags.Transparency = TRUE ;
         pBitmap->Transparency       = pParam->crTransparent ;

         // replace colors
         if ( pParam->nTransparencyTolerance >= 0 )
         {
            L_SetBitmapRgnColorRGBRange ( pBitmap, 
                                          crTransparentStart, 
                                          crTransparentEnd, 
                                          L_RGN_SET ) ;

            if ( L_BitmapHasRgn ( pBitmap ) )
            {
               L_FillBitmap ( pBitmap, pParam->crTransparent ) ;
            }

            L_FreeBitmapRgn ( pBitmap ) ;
         }
      }

   }// TRANSPERANCY

   {// COLOR RESOLUTION

      L_UINT32 uFlags ;

      if ( pParam->nBitsPerPixel < 24 )
      {
         uFlags  = ( ( pParam->bAddWindowsColors ) && ( CRF_OPTIMIZEDPALETTE == pParam->nPalType ) ) ? CRF_IDENTITYPALETTE : 0 ;
         uFlags |= pParam->nDitherType ;
         uFlags |= pParam->nPalType ;

         L_ColorResBitmap ( pBitmap, 
                            pBitmap,
                            sizeof(BITMAPHANDLE),
                            pParam->nBitsPerPixel, 
                            uFlags, 
                            NULL, 
                            NULL, 
                            pParam->nNumOfColors, 
                            NULL, 
                            NULL ) ;

      }

   }// COLOR RESOLUTION

   {// SAVE TO DISK

   L_SaveBitmap ( szFileName,
                  pBitmap,
                  FILE_PNG, 
                  pParam->nBitsPerPixel, 
                  0, 
                  NULL ) ;

   }// SAVE TO DISK
}

 L_INT DlgPNGWebTunerSecondExample(HWND hWnd,pBITMAPHANDLE pBitmap)
{

   L_INT                nRet ;
   PNGWEBTUNERDLGPARAMS DlgParams ;

   memset ( &DlgParams, 0, sizeof ( PNGWEBTUNERDLGPARAMS ) ) ;

   DlgParams.uStructSize   = sizeof ( PNGWEBTUNERDLGPARAMS ) ;
   DlgParams.pBitmap       = pBitmap ;
   DlgParams.uDlgFlags     = DLG_PNGWEBTUNER_SHOW_INFORMATION      |
                             DLG_PNGWEBTUNER_SHOW_PREVIEW          |
                             DLG_PNGWEBTUNER_SHOW_TOOL_ZOOMLEVEL   |
                             DLG_PNGWEBTUNER_SHOW_TOOL_COLORPICKER |
                             DLG_PNGWEBTUNER_SHOW_TRANSPARENCY     |
                             DLG_PNGWEBTUNER_SHOW_ADDWINDOWCOLOR   ;

   nRet = L_DlgInit ( DLG_INIT_COLOR ) ;
   if(nRet != SUCCESS && nRet != ERROR_DLG_ALREADYINITIATED)
      return nRet;
   nRet = L_DlgPNGWebTuner ( hWnd, &DlgParams ) ;
   L_DlgFree () ;

   if ( SUCCESS_DLG_OK == nRet )
   {
      ExportBitmap ( TEXT("tuned.png"), pBitmap, &DlgParams ) ;
   }
   else
      if( nRet < 1 )
         return nRet;
   return SUCCESS; 
}