L_DlgGIFWebTuner

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_DlgGIFWebTuner(hWndOwner, pDlgParams)

HWND hWndOwner;

/* owner of dialog */

LPGIFWEBTUNERDLGPARAMS pDlgParams;

/* pointer to a structure */

Displays the GIF Web Tuner dialog box, and gets 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 GIFWEBTUNERDLGPARAMS 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 dialog’s initial values.

Comments

The GIF Web Tuner dialog can be seen below:

image\GIFWebTuner.gif

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_DlgPNGWebTuner, L_DlgJPEGWebTuner

Topics:

Dialogs: HTML/Web

 

Using Imaging Common Dialog

Example

Example1:

L_VOID ShowDialog ( HWND hWnd, pBITMAPHANDLE pBitmap ) 
{
   GIFWEBTUNERDLGPARAMS DlgParams ;

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

   DlgParams.uStructSize      = sizeof ( GIFWEBTUNERDLGPARAMS ) ;
   DlgParams.pBitmap    = pBitmap ;
   DlgParams.uDlgFlags  = DLG_GIFWEBTUNER_SHOW_EXPORT|
                          DLG_GIFWEBTUNER_SHOW_INFORMATION | 
                          DLG_GIFWEBTUNER_SHOW_PREVIEW | 
                          DLG_GIFWEBTUNER_SHOW_TOOL_ZOOMLEVEL | 
                          DLG_GIFWEBTUNER_SHOW_TOOL_COLORPICKER | 
                          DLG_GIFWEBTUNER_SHOW_TRANSPARENCY | 
                          DLG_GIFWEBTUNER_SHOW_OPTIONS |
                          DLG_GIFWEBTUNER_SHOW_ADDWINDOWCOLOR ;

   L_DlgInit ( DLG_INIT_COLOR ) ;

   L_DlgGIFWebTuner ( hWnd, &DlgParams ) ;

   L_DlgFree ( ) ;
} ;

Example2:

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 ) ;
}

L_VOID ExportBitmap 

   L_TCHAR L_FAR* szFileName, 
   pBITMAPHANDLE pBitmap, 
   LPGIFWEBTUNERDLGPARAMS 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 ( ( 24 != pParam->nBitsPerPixel ) || ( 0 != pParam->nPalType ) )
      {
         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

      SAVEFILEOPTION SaveOptions ;

      memset ( &SaveOptions, 0, sizeof ( SAVEFILEOPTION ) ) ;

      if ( pParam->bInterlaced )
      {
         SaveOptions.Flags = ESO_INTERLACED ;
      }

      L_SaveBitmap( szFileName,
                     pBitmap, 
                     FILE_GIF, 
                     pParam->nBitsPerPixel, 
                     0, 
                     &SaveOptions ) ;

   }// SAVE TO DISK
}

L_VOID ShowDialog ( HWND hWnd, pBITMAPHANDLE pBitmap )
{
   L_INT nRet ;
   GIFWEBTUNERDLGPARAMS DlgParams ;

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

   DlgParams.uStructSize     = sizeof ( GIFWEBTUNERDLGPARAMS ) ;
   DlgParams.pBitmap   = pBitmap ;
   DlgParams.uDlgFlags = DLG_GIFWEBTUNER_SHOW_INFORMATION | 
                         DLG_GIFWEBTUNER_SHOW_PREVIEW | 
                         DLG_GIFWEBTUNER_SHOW_TOOL_ZOOMLEVEL | 
                         DLG_GIFWEBTUNER_SHOW_TOOL_COLORPICKER | 
                         DLG_GIFWEBTUNER_SHOW_TRANSPARENCY | 
                         DLG_GIFWEBTUNER_SHOW_OPTIONS |
                         DLG_GIFWEBTUNER_SHOW_ADDWINDOWCOLOR ;

   L_DlgInit ( DLG_INIT_COLOR ) ;

   nRet = L_DlgGIFWebTuner ( hWnd, &DlgParams ) ;

   L_DlgFree ( ) ;

   if ( SUCCESS_DLG_OK == nRet )
   {
      ExportBitmap ( TEXT("tuned.gif"), pBitmap, &DlgParams ) ;
   }
}