LDialogWeb::DoModalPNGWebTuner

#include "ltwrappr.h"

virtual L_INT LDialogWeb::DoModalPNGWebTuner(hWndOwner)

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

Parameters

HWND hWndOwner

Handle of the window which owns the dialog.

Returns

Value Meaning
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::SetPNGWebTunerParams must be called before using this function to set the initial values for the dialog. You can get the updated PNGWEBTUNERDLGPARAMS with the values entered by the user through the dialog by using LDialogWeb::GetPNGWebTunerParams.

The PNG Web Tuner dialog.

Required DLLs and Libraries

See Also

Functions

Topics

Example

// Example 1 
L_INT LDialogWeb_DoModalPNGWebTunerExample_1(LBitmap * pBitmap, HWND hWnd) 
{ 
   L_INT nRet; 
 
   LDialogWeb DlgWeb;  
 
   PNGWEBTUNERDLGPARAMS  DlgParams;  
 
   DlgWeb.SetBitmap(pBitmap);  
 
   memset ( &DlgParams, 0, sizeof ( PNGWEBTUNERDLGPARAMS ) ) ;  
 
   nRet = LDialogWeb::Initialize (0);  
   if(nRet != SUCCESS) 
      return nRet; 
 
   DlgParams.uStructSize      = sizeof ( PNGWEBTUNERDLGPARAMS ) ;  
   DlgParams.uDlgFlags  = DLG_PNGWEBTUNER_SHOW_EXPORT| 
                          DLG_PNGWEBTUNER_SHOW_INFORMATION |  
                          DLG_PNGWEBTUNER_SHOW_TOOL_COLORPICKER |  
                          DLG_PNGWEBTUNER_SHOW_TRANSPARENCY |  
                          DLG_PNGWEBTUNER_SHOW_ADDWINDOWCOLOR ;  
 
   DlgWeb.EnableCallBack (FALSE);  
   DlgWeb.EnablePreview (TRUE);  
   DlgWeb.EnableAutoProcess(TRUE);  
   DlgWeb.EnableToolbar (TRUE);  
 
   nRet = DlgWeb.SetPNGWebTunerParams(&DlgParams) ;  
   if(nRet != SUCCESS) 
      return nRet; 
 
   nRet = DlgWeb.DoModalPNGWebTuner(hWnd);  
   if(nRet < 1) 
      return nRet; 
 
   // Gets the updated values for the structure 
   nRet = DlgWeb.GetPNGWebTunerParams (&DlgParams, sizeof(DlgParams)) ;  
   if(nRet != SUCCESS) 
      return nRet; 
 
   nRet = LDialogImageEffect::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, LPPNGWEBTUNERDLGPARAMS pParam )  
{ 
   L_INT nRet; 
   {// TRANSPERANCY 
      if ( pParam->bTransparent )  
      { 
         COLORREF crTransparentStart ;  
         COLORREF crTransparentEnd ;  
 
         //LBitmapRgn Region(pLBitmap);  
         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->Region()->BitmapHasRgn ( ) ) 
            { 
               pLBitmap->Fill ( pParam->crTransparent ) ; 
            } 
 
            nRet = pLBitmap->Region()->Free ( ) ; 
            if(nRet != SUCCESS) 
               return nRet; 
         } 
      } 
 
   }// 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 ;  
 
         nRet = pLBitmap->ColorRes (pParam->nBitsPerPixel,  
                                     uFlags,  
                                     NULL,  
                                     NULL,  
                                     pParam->nNumOfColors) ;  
         if(nRet != SUCCESS) 
            return nRet; 
      } 
 
   }// COLOR RESOLUTION 
 
   {// SAVE TO DISK 
   nRet = pLBitmap->Save(szFileName,  
                         FILE_PNG,  
                         pParam->nBitsPerPixel,  
                         0,  
                         NULL ) ;  
   if(nRet != SUCCESS) 
      return nRet; 
   }// SAVE TO DISK 
 
   return SUCCESS; 
} 
 
L_INT LDialogWeb_DoModalPNGWebTunerExample_2(LBitmap * pBitmap, HWND hWnd)  
{ 
   L_INT nRet = 0;  
   LDialogWeb DlgWeb;  
   PNGWEBTUNERDLGPARAMS DlgParams;  
 
   DlgWeb.SetBitmap (pBitmap);  
   memset ( &DlgParams, 0, sizeof ( PNGWEBTUNERDLGPARAMS ) ) ;  
 
   LDialogWeb::Initialize (0);  
   DlgParams.uStructSize      = sizeof ( PNGWEBTUNERDLGPARAMS ) ;  
   DlgParams.uDlgFlags  = DLG_PNGWEBTUNER_SHOW_INFORMATION |  
                          DLG_PNGWEBTUNER_SHOW_TOOL_COLORPICKER |  
                          DLG_PNGWEBTUNER_SHOW_TRANSPARENCY |  
                          DLG_PNGWEBTUNER_SHOW_ADDWINDOWCOLOR ;  
 
   DlgWeb.EnableCallBack (FALSE);  
   DlgWeb.EnablePreview (TRUE);  
   DlgWeb.EnableAutoProcess (TRUE);  
   DlgWeb.EnableToolbar (TRUE);  
 
   nRet = DlgWeb.SetPNGWebTunerParams (&DlgParams) ;  
   if(nRet != SUCCESS) 
      return nRet; 
 
   nRet = DlgWeb.DoModalPNGWebTuner(hWnd);  
   if(nRet < 1) 
      return nRet; 
 
   // Gets the updated values for the structure 
   DlgWeb.GetPNGWebTunerParams (&DlgParams, sizeof(DlgParams)) ;  
 
   if ( SUCCESS_DLG_OK == nRet )  
   { 
      nRet = ExportBitmap ( MAKE_IMAGE_PATH(TEXT("tuned.png")), DlgWeb.GetBitmap() , &DlgParams ) ;  
      if(nRet != SUCCESS) 
         return nRet; 
   } 
 
   nRet = LDialogImageEffect::Free (); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
} 
Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Common Dialog C++ Class Library Help