SaveQFactor example for Delphi

procedure TForm1.ShowSaveDlg2Click(Sender: TObject); 
var
   nRet: L_INT; 
begin
   LEADDlgFile1.DialogTitle:= 'Save a File'; 
   LEADDlgFile1.MaxFileSize:= 0; 
   LEADDlgFile1.MaxFileTitleSize:= 0; 
   LEADDlgFile1.DlgFileFlags:= 0; 
   LEADDlgFile1.InitialDir:= 'C:\';         
   LEADDlgFile1.SaveMulti:= MULTIPAGE_OPERATION_OVERWRITE; 
   LEADDlgFile1.DlgFlags:= DLG_SAVE_SHOW_FILEOPTIONS_PROGRESSIVE     +
                           DLG_SAVE_SHOW_FILEOPTIONS_MULTIPAGE       +
                           DLG_SAVE_SHOW_FILEOPTIONS_STAMP           +
                           DLG_SAVE_SHOW_FILEOPTIONS_QFACTOR         +
                           DLG_SAVE_SHOW_FILEOPTIONS_J2KOPTIONS      +
                           DLG_SAVE_SHOW_FILEOPTIONS_BASICJ2KOPTIONS; 
   LEADDlgFile1.LEADImage:= LEADImage1; 
   nRet:= LEADDlgFile1.ShowSaveDlg ( Self ); 
   if ( nRet = SUCCESS_DLG_OK ) then
   begin
      if ( (LEADDlgFile1.SaveFormat = FILE_J2K) Or
           (LEADDlgFile1.SaveFormat = FILE_JP2) ) then
      begin
         LEADImage1.J2KUseColorTransform:= LEADDlgFile1.SaveJ2KUseColorTransform
         LEADImage1.J2KDerivedQuantization:= LEADDlgFile1.SaveJ2KDerivedQuantization
         LEADImage1.J2KCompressionControl:= LEADDlgFile1.SaveJ2KCompressionControl
         LEADImage1.J2KCompressionRatio:= LEADDlgFile1.SaveJ2KCompressionRatio;         
         LEADImage1.J2KTargetFileSize:= LEADDlgFile1.SaveJ2KTargetFileSize
         LEADImage1.J2KXOsiz:= LEADDlgFile1.SaveJ2KXOsiz
         LEADImage1.J2KYOsiz:= LEADDlgFile1.SaveJ2KYOsiz
         LEADImage1.J2KXTsiz:= LEADDlgFile1.SaveJ2KXTsiz
         LEADImage1.J2KYTsiz:= LEADDlgFile1.SaveJ2KYTsiz
         LEADImage1.J2KXTOsiz:= LEADDlgFile1.SaveJ2KXTOsiz
         LEADImage1.J2KYTOsiz:= LEADDlgFile1.SaveJ2KYTOsiz
         LEADImage1.J2KDecompLevel:= LEADDlgFile1.SaveJ2KDecompLevel
         LEADImage1.J2KProgressOrder:= LEADDlgFile1.SaveJ2KProgressOrder
         LEADImage1.J2KCodBlockWidth:= LEADDlgFile1.SaveJ2KCodBlockWidth
         LEADImage1.J2KCodBlockHeight:= LEADDlgFile1.SaveJ2KCodBlockHeight
         LEADImage1.J2KCBS_SelectiveACBypass:= LEADDlgFile1.SaveJ2KCBS_SelectiveACBypass
         LEADImage1.J2KCBS_ResetContextOnBoundaries:= LEADDlgFile1.SaveJ2KCBS_ResetContextOnBoundaries
         LEADImage1.J2KCBS_TerminationOnEachPass:= LEADDlgFile1.SaveJ2KCBS_TerminationOnEachPass
         LEADImage1.J2KCBS_VerticallyCausalContext:= LEADDlgFile1.SaveJ2KCBS_VerticallyCausalContext
         LEADImage1.J2KCBS_PredictableTermination:= LEADDlgFile1.SaveJ2KCBS_PredictableTermination
         LEADImage1.J2KCBS_ErrorResilienceSymbol:= LEADDlgFile1.SaveJ2KCBS_ErrorResilienceSymbol
         LEADImage1.J2KGuardBits:= LEADDlgFile1.SaveJ2KGuardBits
         LEADImage1.J2KDerivedBaseMantissa:= LEADDlgFile1.SaveJ2KDerivedBaseMantissa
         LEADImage1.J2KDerivedBaseExponent:= LEADDlgFile1.SaveJ2KDerivedBaseExponent
         LEADImage1.J2KUseSOPMarker:= LEADDlgFile1.SaveJ2KUseSOPMarker
         LEADImage1.J2KUseEPHMarker:= LEADDlgFile1.SaveJ2KUseEPHMarker

         LEADImage1.Save ( LEADDlgFile1.FileName
                           LEADDlgFile1.SaveFormat
                           LEADDlgFile1.SaveBitsPerPixel
                           LEADDlgFile1.SaveQFactor
                           LEADDlgFile1.SaveMulti ); 
      end; 
   end; 
end;