LEADTOOLS Windows Forms (Leadtools.WinForms.CommonDialogs.File assembly)
LEAD Technologies, Inc

RasterSaveDialog Class

Example 





Members 
Displays the Save dialog box, and gets the options for Leadtools.Codecs.RasterCodecs.Save(Leadtools.RasterImage,System.Uri,Leadtools.RasterImageFormat,System.Int32,System.Int32,System.Int32).
Object Model
RasterSaveDialog ClassRasterSaveDialogFileFormatsList Class
Syntax
public class RasterSaveDialog : System.IDisposable  
'Declaration
 
Public Class RasterSaveDialog 
   Implements System.IDisposable 
'Usage
 
Dim instance As RasterSaveDialog
function Leadtools.WinForms.CommonDialogs.File.RasterSaveDialog()
public ref class RasterSaveDialog : public System.IDisposable  
Remarks

The Save dialog can be seen below:

Example
 
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.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
End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
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.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());
      }
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RasterSaveDialog Members
Leadtools.WinForms.CommonDialogs.File Namespace
Leadtools.Codecs.RasterCodecs.Save(Leadtools.RasterImage,System.Uri,Leadtools.RasterImageFormat,System.Int32,System.Int32,System.Int32)

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.