Leadtools.WinForms.CommonDialogs.File Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.8.31
RasterSaveDialog Class
See Also  Members   Example 
Leadtools.WinForms.CommonDialogs.File Namespace : RasterSaveDialog Class




Displays the Save dialog box, and gets the options for Save.

Object Model


Syntax

Visual Basic (Declaration) 
Public Class RasterSaveDialog 
Visual Basic (Usage)Copy Code
Dim instance As RasterSaveDialog
C# 
public class RasterSaveDialog 
Managed Extensions for C++ 
public __gc class RasterSaveDialog 
C++/CLI 
public ref class RasterSaveDialog 

Example

Visual BasicCopy Code
Public Sub saveDlg_Help(ByVal sender As Object, ByVal e As RasterDialogHelpEventArgs) Handles saveDlg.Help
   Select Case e.Dialog
      Case RasterDialogHelpName.Save
         MessageBox.Show("Save dialog Help")
         Exit Select

      Case RasterDialogHelpName.J2kOptions
         MessageBox.Show("Jpeg 2000 Save Options dialog Help")
         Exit Select

      Case RasterDialogHelpName.SaveOptions
         MessageBox.Show("Save Options dialog Help")
         Exit Select
   End Select
End Sub

WithEvents saveDlg As RasterSaveDialog


Public Sub RasterSaveDialogExample()
   Leadtools.Codecs.RasterCodecs.Startup()

   Dim rasterCodecs As RasterCodecs = New RasterCodecs()

   saveDlg = New RasterSaveDialog(rasterCodecs)

   Dim saveDlgFormatList As RasterSaveDialogFileFormatsList = New RasterSaveDialogFileFormatsList(RasterDialogFileFormatDataContent.User)

   ' Adding Cmp format
   saveDlgFormatList.Add(RasterDialogFileTypesIndex.Lead, RasterDialogBitsPerPixelDataContent.Default)

   ' Adding Tiff format
   saveDlgFormatList.Add(RasterDialogFileTypesIndex.Tiff, RasterDialogBitsPerPixelDataContent.User)
   saveDlgFormatList(1).Name = "Custom Tiff"

   'Adding all default 12-bit subtypes
   saveDlgFormatList(1).BitsPerPixelList.Add(RasterDialogFileTypesIndex.Tiff, 12, RasterDialogFileSubTypeDataContent.Default)

   'Adding all default 24-bit and some subtypes
   saveDlgFormatList(1).BitsPerPixelList.Add(RasterDialogFileTypesIndex.Tiff, 24, RasterDialogFileSubTypeDataContent.User)
   saveDlgFormatList(1).BitsPerPixelList(1).SubFormatsList.Add(RasterDialogFileTypesIndex.Tiff, 24, CInt(RasterDialogTiff24SubTypesIndex.UncompressedYCbCr))
   saveDlgFormatList(1).BitsPerPixelList(1).SubFormatsList.Add(RasterDialogFileTypesIndex.Tiff, 24, CInt(RasterDialogTiff24SubTypesIndex.PackbitsRgb))
   saveDlgFormatList(1).BitsPerPixelList(1).SubFormatsList.Add(RasterDialogFileTypesIndex.Tiff, 24, CInt(RasterDialogTiff24SubTypesIndex.PackbitsCmyk))

   saveDlg.AutoProcess = False
   saveDlg.BitsPerPixel = 24
   saveDlg.DefaultExt = "cmp"
   saveDlg.EnableSizing = True
   saveDlg.FileFormatsList = saveDlgFormatList
   saveDlg.FileName = "Image1.cmp"
   saveDlg.FileSubTypeIndex = CInt(RasterDialogCmpSubTypesIndex.NonProgressive)
   saveDlg.FileTypeIndex = RasterDialogFileTypesIndex.Lead
   saveDlg.InitialDirectory = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\"
   saveDlg.PageNumber = 1
   saveDlg.Passes = 1
   saveDlg.PromptOverwrite = True
   saveDlg.QualityFactor = 2
   saveDlg.ShowFileOptionsBasicJ2kOptions = False
   saveDlg.ShowFileOptionsJ2kOptions = False
   saveDlg.ShowFileOptionsMultipage = True
   saveDlg.ShowFileOptionsProgressive = True
   saveDlg.ShowFileOptionsQualityFactor = True
   saveDlg.ShowFileOptionsStamp = True
   saveDlg.ShowHelp = True
   saveDlg.ShowOptions = True
   saveDlg.ShowQualityFactor = True
   saveDlg.StampBitsPerPixel = 24
   saveDlg.StampHeight = 120
   saveDlg.StampWidth = 120
   saveDlg.Title = "Save Dialog"
   saveDlg.WithStamp = False

   ' Replace "Cancel" string with "Cancel Save"
   RasterSaveDialog.SetDialogString(New RasterDialogStrings("Cancel Save", RasterDialogStringsId.SaveCancel))

   If DialogResult.OK = saveDlg.ShowDialog(Nothing) Then
      Dim saveImage As Leadtools.RasterImage = rasterCodecs.Load("C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image.cmp")

      Select Case saveDlg.Format
         Case RasterImageFormat.Abc
            rasterCodecs.Options.Abc.Save.QualityFactor = saveDlg.AbcQualityFactor
            Exit Select

         Case RasterImageFormat.Ecw
            rasterCodecs.Options.Ecw.Save.QualityFactor = saveDlg.QualityFactor
            Exit Select

         Case RasterImageFormat.Png
            rasterCodecs.Options.Png.Save.QualityFactor = saveDlg.QualityFactor
            Exit Select

         Case RasterImageFormat.Cmp
            rasterCodecs.Options.Jpeg.Save.QualityFactor = saveDlg.QualityFactor
            rasterCodecs.Options.Jpeg.Save.CmpQualityFactorPredefined = saveDlg.CmpQualityFactor
            Exit Select

         Case Else
            rasterCodecs.Options.Jpeg.Save.QualityFactor = saveDlg.QualityFactor
            Exit Select
      End Select

      rasterCodecs.Options.Jpeg.Save.SaveWithStamp = saveDlg.WithStamp
      rasterCodecs.Options.Jpeg.Save.StampBitsPerPixel = saveDlg.StampBitsPerPixel
      rasterCodecs.Options.Jpeg.Save.StampWidth = saveDlg.StampWidth
      rasterCodecs.Options.Jpeg.Save.StampHeight = saveDlg.StampHeight

      rasterCodecs.Save(saveImage, saveDlg.FileName, saveDlg.Format, saveDlg.BitsPerPixel, saveImage.Page, saveImage.Page, saveDlg.PageNumber, saveDlg.MultiPage)

      Dim okButtonString As RasterDialogStrings = RasterSaveDialog.GetDialogString(RasterDialogStringsId.SaveCancel)
      MessageBox.Show(okButtonString.ToString())
   End If
   Leadtools.Codecs.RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void saveDlg_Help(object sender, RasterDialogHelpEventArgs e) 

   switch(e.Dialog) 
   { 
      case RasterDialogHelpName.Save: 
         { 
            MessageBox.Show("Save dialog Help"); 
            break; 
         } 
      case RasterDialogHelpName.J2kOptions: 
         { 
            MessageBox.Show("Jpeg 2000 Save Options dialog Help"); 
            break; 
         } 
 
      case RasterDialogHelpName.SaveOptions: 
         { 
            MessageBox.Show("Save Options dialog Help"); 
            break; 
         } 
   } 

 
 
public void RasterSaveDialogExample() 

   RasterCodecs.Startup(); 
   RasterCodecs rasterCodecs = new RasterCodecs(); 
 
   RasterSaveDialog saveDlg = new RasterSaveDialog(rasterCodecs); 
   RasterSaveDialogFileFormatsList saveDlgFormatList = new RasterSaveDialogFileFormatsList(RasterDialogFileFormatDataContent.User); 
 
   // Adding Cmp format 
   saveDlgFormatList.Add(RasterDialogFileTypesIndex.Lead, RasterDialogBitsPerPixelDataContent.Default); 
 
   // Adding Tiff format 
   saveDlgFormatList.Add(RasterDialogFileTypesIndex.Tiff, RasterDialogBitsPerPixelDataContent.User); 
   saveDlgFormatList[1].Name = "Custom Tiff"; 
 
   //Adding all default 12-bit subtypes 
   saveDlgFormatList[1].BitsPerPixelList.Add(RasterDialogFileTypesIndex.Tiff, 12, RasterDialogFileSubTypeDataContent.Default); 
 
   //Adding all default 24-bit and some subtypes 
   saveDlgFormatList[1].BitsPerPixelList.Add(RasterDialogFileTypesIndex.Tiff, 24, RasterDialogFileSubTypeDataContent.User); 
   saveDlgFormatList[1].BitsPerPixelList[1].SubFormatsList.Add(RasterDialogFileTypesIndex.Tiff, 24, (int)RasterDialogTiff24SubTypesIndex.UncompressedYCbCr); 
   saveDlgFormatList[1].BitsPerPixelList[1].SubFormatsList.Add(RasterDialogFileTypesIndex.Tiff, 24, (int)RasterDialogTiff24SubTypesIndex.PackbitsRgb); 
   saveDlgFormatList[1].BitsPerPixelList[1].SubFormatsList.Add(RasterDialogFileTypesIndex.Tiff, 24, (int)RasterDialogTiff24SubTypesIndex.PackbitsCmyk); 
 
   saveDlg.AutoProcess = false; 
   saveDlg.BitsPerPixel = 24; 
   saveDlg.DefaultExt = "cmp"; 
   saveDlg.EnableSizing = true; 
   saveDlg.FileFormatsList = saveDlgFormatList; 
   saveDlg.FileName = "Image1.cmp"; 
   saveDlg.FileSubTypeIndex = (int)RasterDialogCmpSubTypesIndex.NonProgressive; 
   saveDlg.FileTypeIndex = RasterDialogFileTypesIndex.Lead; 
   saveDlg.InitialDirectory = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\"; 
   saveDlg.PageNumber = 1; 
   saveDlg.Passes = 1; 
   saveDlg.PromptOverwrite = true; 
   saveDlg.QualityFactor = 2; 
   saveDlg.ShowFileOptionsBasicJ2kOptions = false; 
   saveDlg.ShowFileOptionsJ2kOptions = false; 
   saveDlg.ShowFileOptionsMultipage = true; 
   saveDlg.ShowFileOptionsProgressive = true; 
   saveDlg.ShowFileOptionsQualityFactor = true; 
   saveDlg.ShowFileOptionsStamp = true; 
   saveDlg.ShowHelp = true; 
   saveDlg.ShowOptions = true; 
   saveDlg.ShowQualityFactor = true; 
   saveDlg.StampBitsPerPixel = 24; 
   saveDlg.StampHeight = 120; 
   saveDlg.StampWidth = 120; 
   saveDlg.Title = "Save Dialog"; 
   saveDlg.WithStamp = false; 
   saveDlg.Help += new EventHandler<RasterDialogHelpEventArgs>(saveDlg_Help); 
 
   // Replace "Cancel" string with "Cancel Save" 
   RasterSaveDialog.SetDialogString(new RasterDialogStrings("Cancel Save", RasterDialogStringsId.SaveCancel)); 
 
   if(DialogResult.OK == saveDlg.ShowDialog(null)) 
   { 
      Leadtools.RasterImage saveImage = rasterCodecs.Load(@"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image.cmp"); 
 
      switch(saveDlg.Format) 
      { 
         case RasterImageFormat.Abc: 
            { 
               rasterCodecs.Options.Abc.Save.QualityFactor = saveDlg.AbcQualityFactor; 
               break; 
            } 
 
         case RasterImageFormat.Ecw: 
            { 
               rasterCodecs.Options.Ecw.Save.QualityFactor = saveDlg.QualityFactor; 
               break; 
            } 
 
         case RasterImageFormat.Png: 
            { 
               rasterCodecs.Options.Png.Save.QualityFactor = saveDlg.QualityFactor; 
               break; 
            } 
 
         case RasterImageFormat.Cmp: 
            { 
               rasterCodecs.Options.Jpeg.Save.QualityFactor = saveDlg.QualityFactor; 
               rasterCodecs.Options.Jpeg.Save.CmpQualityFactorPredefined = saveDlg.CmpQualityFactor; 
               break; 
            } 
 
         default: 
            { 
               rasterCodecs.Options.Jpeg.Save.QualityFactor = saveDlg.QualityFactor; 
               break; 
            } 
      } 
 
      rasterCodecs.Options.Jpeg.Save.SaveWithStamp = saveDlg.WithStamp; 
      rasterCodecs.Options.Jpeg.Save.StampBitsPerPixel = saveDlg.StampBitsPerPixel; 
      rasterCodecs.Options.Jpeg.Save.StampWidth = saveDlg.StampWidth; 
      rasterCodecs.Options.Jpeg.Save.StampHeight = saveDlg.StampHeight; 
 
      rasterCodecs.Save(saveImage, 
                        saveDlg.FileName, 
                        saveDlg.Format, 
                        saveDlg.BitsPerPixel, 
                        saveImage.Page, 
                        saveImage.Page, 
                        saveDlg.PageNumber, 
                        saveDlg.MultiPage); 
 
      RasterDialogStrings okButtonString = RasterSaveDialog.GetDialogString(RasterDialogStringsId.SaveCancel); 
      MessageBox.Show(okButtonString.ToString()); 
   } 
   RasterCodecs.Shutdown(); 
}

Remarks

The Save dialog can be seen below:

Inheritance Hierarchy

System.Object
   Leadtools.WinForms.CommonDialogs.File.RasterSaveDialog

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also