public void Add(
RasterDialogFileTypesIndex fileTypeIndex,
int bitsPerPixe,
RasterDialogFileSubTypeDataContent subTypeDataContent
)
fileTypeIndex
Save dialog file type index that includes the bits per pixel, refer to RasterDialogFileTypesIndex.
bitsPerPixe
Save dialog bits per pixel to be added, refer to RasterDialogFileTypesIndex.
subTypeDataContent
The added sub-types for this bits per pixel data, refer to RasterDialogFileSubTypeDataContent.
The index of the added item.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.WinForms.CommonDialogs.File;
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.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());
}
}
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;
}
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}