SaveQFactor Example for Visual Basic

Dim RasterKrnDlg As New LEADRasterDlgKrn_U
Dim RasterFileDlg As New LEADRasterDlgFile_U
Dim nRet As Integer

LEAD1.UnlockSupport L_SUPPORT_J2K, L_KEY_J2K
LEAD1.Load "d:\\temp\\images\\jpeg\\golf.jpg", 0, 1, 1
RasterKrnDlg.InitDlg INIT_WITHOUT_COLOR

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 = LEAD1.Bitmap
nRet = RasterFileDlg.ShowSaveDlg(hWnd)

If (nRet = 0) Then
    If ((RasterFileDlg.SaveFormat = FILE_J2K) Or (RasterFileDlg.SaveFormat = FILE_JP2)) Then
        RasterIO.J2KUseColorTransformJ2KUseColorTransform = RasterFileDlg.SaveJ2KUseColorTransform
        RasterIO.J2KDerivedQuantizationJ2KDerivedQuantization = RasterFileDlg.SaveJ2KDerivedQuantization
        RasterIO.J2KCompressionControlJ2KCompressionControl = RasterFileDlg.SaveJ2KCompressionControl
        RasterIO.J2KCompressionRatioJ2KCompressionRatio = RasterFileDlg.SaveJ2KCompressionRatio
        RasterIO.J2KTargetFileSizeJ2KTargetFileSize = RasterFileDlg.SaveJ2KTargetFileSize
        RasterIO.J2KXOsizJ2KXOsiz = RasterFileDlg.SaveJ2KXOsiz
        RasterIO.J2KYOsizJ2KYOsiz = RasterFileDlg.SaveJ2KYOsiz
        RasterIO.J2KXTsizJ2KXTsiz = RasterFileDlg.SaveJ2KXTsiz
        RasterIO.J2KYTsizJ2KYTsiz = RasterFileDlg.SaveJ2KYTsiz
        RasterIO.J2KXTOsizJ2KXTOsiz = RasterFileDlg.SaveJ2KXTOsiz
        RasterIO.J2KYTOsizJ2KYTOsiz = RasterFileDlg.SaveJ2KYTOsiz
        RasterIO.J2KDecompLevelJ2KDecompLevel = RasterFileDlg.SaveJ2KDecompLevel
        RasterIO.J2KProgressOrderJ2KProgressOrder = RasterFileDlg.SaveJ2KProgressOrder
        RasterIO.J2KCodBlockWidthJ2KCodBlockWidth = RasterFileDlg.SaveJ2KCodBlockWidth
        RasterIO.J2KCodBlockHeightJ2KCodBlockHeight = RasterFileDlg.SaveJ2KCodBlockHeight
        RasterIO.J2KCBS_SelectiveACBypassJ2KCBS_SelectiveACBypass = RasterFileDlg.SaveJ2KCBS_SelectiveACBypass
        RasterIO.J2KCBS_ResetContextOnBoundaries J2KCBS_ResetContextOnBoundaries = RasterFileDlg.SaveJ2KCBS_ResetContextOnBoundaries
        RasterIO.J2KCBS_TerminationOnEachPassJ2KCBS_TerminationOnEachPass = RasterFileDlg.SaveJ2KCBS_TerminationOnEachPass
        RasterIO.J2KCBS_VerticallyCausalContext J2KCBS_VerticallyCausalContext = RasterFileDlg.SaveJ2KCBS_VerticallyCausalContext
        RasterIO.J2KCBS_PredictableTermination J2KCBS_PredictableTermination = RasterFileDlg.SaveJ2KCBS_PredictableTermination
        RasterIO.J2KCBS_ErrorResilienceSymbolJ2KCBS_ErrorResilienceSymbol = RasterFileDlg.SaveJ2KCBS_ErrorResilienceSymbol
        RasterIO.J2KGuardBitsJ2KGuardBits = RasterFileDlg.SaveJ2KGuardBits
        RasterIO.J2KDerivedBaseMantissaJ2KDerivedBaseMantissa = RasterFileDlg.SaveJ2KDerivedBaseMantissa
        RasterIO.J2KDerivedBaseExponentJ2KDerivedBaseExponent = RasterFileDlg.SaveJ2KDerivedBaseExponent
        RasterIO.J2KUseSOPMarkerJ2KUseSOPMarker = RasterFileDlg.SaveJ2KUseSOPMarker
        RasterIO.J2KUseEPHMarkerJ2KUseEPHMarker = RasterFileDlg.SaveJ2KUseEPHMarker

        LEAD1.Save RasterFileDlg.FileName, _
                   RasterFileDlg.SaveFormat, _
                   RasterFileDlg.SaveBitsPerPixel, _
                   RasterFileDlg.SaveQFactor, _
                   RasterFileDlg.SaveMulti
        End If
    End If
    RasterKrnDlg.FreeDlg