RasterSaveDialog Class

Syntax
C#
VB
C++
public class RasterSaveDialog : IDisposable 
  
Public Class RasterSaveDialog  
   Implements System.IDisposable  
public ref class RasterSaveDialog : public System.IDisposable   

Remarks

The Save dialog can be seen below:

savedialog.jpg

Example
C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.WinForms.CommonDialogs.File; 
 
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 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 = "Out_Image1.cmp"; 
   saveDlg.FileSubTypeIndex = (int)RasterDialogCmpSubTypesIndex.NonProgressive; 
   saveDlg.FileTypeIndex = RasterDialogFileTypesIndex.Lead; 
   saveDlg.InitialDirectory = LEAD_VARS.ImagesDir; 
   saveDlg.InitialView = FileDialogInitialView.List; 
   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.ShowPdfProfiles = true; 
   saveDlg.ShowBitsPerPixel = true; 
   saveDlg.ShowFormatSubType = 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(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")); 
 
      switch (saveDlg.Format) 
      { 
         case RasterImageFormat.Abc: 
            { 
               rasterCodecs.Options.Abc.Save.QualityFactor = saveDlg.AbcQualityFactor; 
               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()); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.WinForms.CommonDialogs.File 
 
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() 
   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 = "Out_Image.cmp" 
   saveDlg.FileSubTypeIndex = CInt(RasterDialogCmpSubTypesIndex.NonProgressive) 
   saveDlg.FileTypeIndex = RasterDialogFileTypesIndex.Lead 
   saveDlg.InitialDirectory = LEAD_VARS.ImagesDir 
   saveDlg.InitialView = FileDialogInitialView.List 
   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.ShowPdfProfiles = True 
   saveDlg.ShowHelp = True 
   saveDlg.ShowOptions = True 
   saveDlg.ShowQualityFactor = True 
   saveDlg.ShowBitsPerPixel = True 
   saveDlg.ShowFormatSubType = 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(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")) 
 
      Select Case saveDlg.Format 
         Case RasterImageFormat.Abc 
            rasterCodecs.Options.Abc.Save.QualityFactor = saveDlg.AbcQualityFactor 
            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 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 

Requirements

Target Platforms

Help Version 20.0.2020.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.WinForms.CommonDialogs.File Assembly