LDialogWeb::DoModalGIFWebTuner

#include "ltwrappr.h"

virtual L_INT LDialogWeb::DoModalGIFWebTuner (hWndOwner)

HWND hWndOwner;

/* handle of the window which owns the dialog*/

Displays the GIF Web tuner dialog box, and gets tuning options used by LBitmapBase::ColorRes, LBitmapBase::Fill, LBitmapBase::Save, LBitmapRgn::SetRgnColorRGBRange.

Parameter

Description

hWndOwner

Handle of the window which owns the 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.

Comments

LDialogWeb::SetGIFWebTunerParams must be called before using this function to sets the initial values for the dialog. You can get the updated GIFWEBTUNERDLGPARAMS with the values entered by the user through the dialog by using LDialogWeb::GetGIFWebTunerParams.

The GIF Web Tuner dialog.

Required DLLs and Libraries

LTDLGWEB
LTDLGKRN
LTDLGUTL
LTDLGCTRL
LTDLGCOM
LTFIL
LTDIS
LTIMG

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:

LDialogBase::Initialize, LDialogFile::DoModalSave, LDialogWeb::DoModalGIFWebTuner, LDialogWeb::DoModalJPEGWebTuner, LBase::EnableCallBack, LDialogBase::EnablePreview, LDialogBase::EnableAutoProcess, LDialogBase::EnableToolbar, LDialogBase::Free, LDialogWeb::GetGIFWebTunerParams, LDialogWeb::SetGIFWebTunerParams, Class Members

Topics:

Using Imaging Common Dialog

Example

// Example 1
L_INT LDialogWeb_DoModalGIFWebTunerExample_1(LBitmap * pBitmap, HWND hWnd) 
{
   L_INT nRet = 0; 
   LDialogWeb DlgWeb; 
   GIFWEBTUNERDLGPARAMS DlgParams; 
   DlgWeb.SetBitmap (pBitmap); 
   memset ( &DlgParams, 0, sizeof ( GIFWEBTUNERDLGPARAMS ) ) ; 
   nRet = LDialogWeb::Initialize (0); 
   if(nRet != SUCCESS)
      return nRet;
   DlgParams.uStructSize   = sizeof ( GIFWEBTUNERDLGPARAMS ) ; 
   DlgParams.pBitmap       = pBitmap->GetHandle(); 
   DlgParams.uDlgFlags     = DLG_GIFWEBTUNER_SHOW_EXPORT|
                             DLG_GIFWEBTUNER_SHOW_INFORMATION | 
                             DLG_GIFWEBTUNER_SHOW_TOOL_COLORPICKER | 
                             DLG_GIFWEBTUNER_SHOW_TRANSPARENCY | 
                             DLG_GIFWEBTUNER_SHOW_OPTIONS |
                             DLG_GIFWEBTUNER_SHOW_ADDWINDOWCOLOR ; 
   nRet = DlgWeb.SetGIFWebTunerParams(&DlgParams) ; 
   if(nRet != SUCCESS)
      return nRet;
   nRet = DlgWeb.DoModalGIFWebTuner(hWnd); 
   if(nRet < 1)
      return nRet;
   // Gets the updated values for the structure
   nRet = DlgWeb.GetGIFWebTunerParams(&DlgParams, sizeof(DlgParams)) ; 
   if(nRet != SUCCESS)
      return nRet;
   nRet = LDialogWeb::Free ();
   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 ) ; 
}
L_INT ExportBitmap (L_TCHAR * szFileName, LBitmapBase *pLBitmap, LPGIFWEBTUNERDLGPARAMS pParam ) 
{
   L_INT nRet;
   {// TRANSPERANCY
      if ( pParam->bTransparent ) 
      {
         COLORREF crTransparentStart ; 
         COLORREF crTransparentEnd ; 
         crTransparentStart = AddTolerance ( pParam->crTransparent, 
                                             - pParam->nTransparencyTolerance ) ; 
         crTransparentEnd   = AddTolerance ( pParam->crTransparent, 
                                             pParam->nTransparencyTolerance ) ; 
         // reset
         nRet = pLBitmap->Region()->Free ();
         if(nRet != SUCCESS)
            return nRet;
         // set attributes
         pLBitmap->EnablePlayBackTransparency(TRUE); 
         pLBitmap->SetPlayBackTransparentColor (pParam->crTransparent); 
         // replace colors
         if ( pParam->nTransparencyTolerance >= 0 ) 
         {
            pLBitmap->Region()->SetRgnCombineMode (L_RGN_SET); 
            nRet = pLBitmap->Region()->SetRgnColorRGBRange (crTransparentStart, crTransparentEnd) ; 
            if(nRet != SUCCESS)
               return nRet;
            if ( pLBitmap->HasRgn () ) 
            {
               nRet = pLBitmap->Fill (pParam->crTransparent); 
               if(nRet != SUCCESS)
                  return nRet;
            }
            nRet = pLBitmap->Region()->Free ();
            if(nRet != SUCCESS)
               return nRet;
         }
      }
   }// 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 ; 
         nRet = pLBitmap->ColorRes (pParam->nBitsPerPixel, 
                                    uFlags, 
                                    NULL, 
                                    NULL, 
                                    pParam->nNumOfColors) ; 
         if(nRet != SUCCESS)
            return nRet;
      }
   }// COLOR RESOLUTION
   {// SAVE TO DISK
      SAVEFILEOPTION SaveOptions ; 
      memset ( &SaveOptions, 0, sizeof ( SAVEFILEOPTION ) ) ; 
      if ( pParam->bInterlaced ) 
      {
         SaveOptions.Flags = ESO_INTERLACED ; 
      }
      nRet = pLBitmap->Save(szFileName, 
                            FILE_GIF, 
                            pParam->nBitsPerPixel, 
                            0, 0, 
                            &SaveOptions ) ; 
      if(nRet != SUCCESS)
         return nRet;
   }// SAVE TO DISK
   return SUCCESS;
}
L_INT LDialogWeb_DoModalGIFWebTunerExample_2(LBitmap * pBitmap, HWND hWnd) 
{
   L_INT nRet = 0; 
   LDialogWeb DlgWeb; 
   GIFWEBTUNERDLGPARAMS DlgParams; 
   DlgWeb.SetBitmap (pBitmap); 
   memset ( &DlgParams, 0, sizeof (GIFWEBTUNERDLGPARAMS) ) ; 
   nRet = LDialogWeb::Initialize (0); 
   if(nRet != SUCCESS)
      return nRet;
   DlgParams.uStructSize   = sizeof (GIFWEBTUNERDLGPARAMS) ; 
   DlgParams.uDlgFlags     = DLG_GIFWEBTUNER_SHOW_INFORMATION | 
                             DLG_GIFWEBTUNER_SHOW_TOOL_COLORPICKER | 
                             DLG_GIFWEBTUNER_SHOW_TRANSPARENCY | 
                             DLG_GIFWEBTUNER_SHOW_OPTIONS |
                             DLG_GIFWEBTUNER_SHOW_ADDWINDOWCOLOR ; 
   DlgWeb.EnablePreview(TRUE); 
   DlgWeb.EnableToolbar(TRUE); 
   DlgWeb.EnableCallBack (FALSE); 
   nRet = DlgWeb.SetGIFWebTunerParams (&DlgParams) ; 
   if(nRet != SUCCESS)
      return nRet;
   nRet = DlgWeb.DoModalGIFWebTuner(hWnd); 
   if(nRet < 1)
      return nRet;
   // Gets the updated values for the structure
   nRet = DlgWeb.GetGIFWebTunerParams(&DlgParams, sizeof(DlgParams)) ; 
   if(nRet != SUCCESS)
      return nRet;
   if ( SUCCESS_DLG_OK == nRet ) 
   {
      nRet = ExportBitmap ( TEXT("tuned.gif"), pBitmap, &DlgParams ) ; 
      if(nRet != SUCCESS)
         return nRet;
   }
   nRet = LDialogWeb::Free ();
   if(nRet != SUCCESS)
      return nRet;
   return SUCCESS;
}