SaveQFactor Example for Visual Basic

Dim RasterKrnDlg As New LEADRasterDlgKrn
Dim RasterFileDlg As New LEADRasterDlgFile
Dim RasterIO As New LEADRasterIO

Private Sub Form_Load()
   LEADRasterView1.Raster.UnlockSupport L_SUPPORT_J2K, L_KEY_J2K
   RasterIO.Load LEADRasterView1.Raster, "c:\parrots.jpg", 0, 0, 1
   RasterKrnDlg.InitDlg INIT_WITHOUT_COLOR
End Sub

Private Sub Save_Click()
   Dim nRet As Integer

   RasterFileDlg.DialogTitle = "Save a File"
   RasterFileDlg.FileDlgFlags = 0
   RasterFileDlg.InitialDir = "C:\"
   RasterFileDlg.SaveMulti = MULTIPAGE_OVERWRITE
   RasterFileDlg.UIFlags = SAVE_SHOW_FILEOPTIONS_PROGRESSIVE Or _
      SAVE_SHOW_FILEOPTIONS_MULTIPAGE Or _
      SAVE_SHOW_FILEOPTIONS_STAMP Or _
      SAVE_SHOW_FILEOPTIONS_QFACTOR Or _
      SAVE_SHOW_FILEOPTIONS_J2KOPTIONS Or _
      SAVE_SHOW_FILEOPTIONS_BASICJ2KOPTIONS

   RasterFileDlg.Bitmap = LEADRasterView1.Raster.Bitmap
   nRet = RasterFileDlg.ShowSaveDlg(hWnd)

   If (nRet = 0) Then
      If ((RasterFileDlg.SaveFormat = FILE_J2K) Or (RasterFileDlg.SaveFormat = FILE_JP2)) Then
         RasterIO.J2KUseColorTransform = RasterFileDlg.SaveJ2KuseColorTransform
         RasterIO.J2KDerivedQuantization = RasterFileDlg.SaveJ2KderivedQuantization
         RasterIO.J2KCompressionControl = RasterFileDlg.SaveJ2KcompressionControl
         RasterIO.J2KCompressionRatio = RasterFileDlg.SaveJ2KcompressionRatio
         RasterIO.J2KTargetFileSize = RasterFileDlg.SaveJ2KtargetFileSize
         RasterIO.J2KXOsiz = RasterFileDlg.SaveJ2KXOsiz
         RasterIO.J2KYOsiz = RasterFileDlg.SaveJ2KYOsiz
         RasterIO.J2KXTsiz = RasterFileDlg.SaveJ2KXTsiz
         RasterIO.J2KYTsiz = RasterFileDlg.SaveJ2KYTsiz
         RasterIO.J2KXTOsiz = RasterFileDlg.SaveJ2KXTOsiz
         RasterIO.J2KYTOsiz = RasterFileDlg.SaveJ2KYTOsiz
         RasterIO.J2KDecompLevel = RasterFileDlg.SaveJ2KDecompLevel
         RasterIO.J2KProgressOrder = RasterFileDlg.SaveJ2KprogressOrder
         RasterIO.J2KCodBlockWidth = RasterFileDlg.SaveJ2KcodBlockWidth
         RasterIO.J2KCodBlockHeight = RasterFileDlg.SaveJ2KcodBlockHeight
         RasterIO.J2KCBS_SelectiveACBypass = RasterFileDlg.SaveJ2KCBS_SelectiveACBypass
         RasterIO.J2KCBS_ResetContextOnBoundaries = RasterFileDlg.SaveJ2KCBS_ResetContextOnBoundaries
         RasterIO.J2KCBS_TerminationOnEachPass = RasterFileDlg.SaveJ2KCBS_TerminationOnEachPass
         RasterIO.J2KCBS_VerticallyCausalContext = RasterFileDlg.SaveJ2KCBS_VerticallyCausalContext
         RasterIO.J2KCBS_PredictableTermination = RasterFileDlg.SaveJ2KCBS_PredictableTermination
         RasterIO.J2KCBS_ErrorResilienceSymbol = RasterFileDlg.SaveJ2KCBS_ErrorResilienceSymbol
         RasterIO.J2KGuardBits = RasterFileDlg.SaveJ2KguardBits
         RasterIO.J2KDerivedBaseMantissa = RasterFileDlg.SaveJ2KderivedBaseMantissa
         RasterIO.J2KDerivedBaseExponent = RasterFileDlg.SaveJ2KderivedBaseExponent
         RasterIO.J2KUseSOPMarker = RasterFileDlg.SaveJ2KUseSOPMarker
         RasterIO.J2KUseEPHMarker = RasterFileDlg.SaveJ2KUseEPHMarker

         RasterIO.Save LEADRasterView1.Raster, RasterFileDlg.FileName, _
                  RasterFileDlg.SaveFormat, _
                  RasterFileDlg.SaveBitsPerPixel, _
                  RasterFileDlg.SaveQFactor, _
                  RasterFileDlg.SaveMulti

      End If
   End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
   RasterKrnDlg.FreeDlg
End Sub