Many format filters in ImageGear have control parameters that effect filter operations, such as image reading and writing. Those parameters may be declared by the format specification, or they may be specific to the format implementation by ImageGear.
There are two ways to specify filter control parameters:
- Specify parameters globally. This effects all format reading and writing operations, and threads in the process. Use the Filters static property of the ImGearFileFormats Class to set parameters globally.
- Specify parameters locally. This effects only one reading or writing operation, and thus can be used for setting different parameters in different threads. To specify the local parameters, create an instance of ImGearFileFilters Class, assign it to ImGearLoadOptions.Filters property or ImGearSaveOptions.Filters property, and pass the Load or Save options object to the reading or writing method, correspondingly.
The following example sets a global control parameter:
C# | Copy Code |
---|---|
IImGearFormat JpgFormat = ImGearFileFormats.Filters.Get(ImGearFormats.JPG); ImGearControlParameter Param = JpgFormat.Parameters.GetByName("SaveType"); Param.Value = 1; // Lossless using (FileStream fsWrite = File.Open("Test.jpg", FileMode.Create, FileAccess.ReadWrite, FileShare.None)) ImGearFileFormats.SavePage(imGearPage, fsWrite, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.JPG, null); |
The following example sets a local control parameter:
C# | Copy Code |
---|---|
ImGearFileFilters LocalFilters = new ImGearFileFilters(); IImGearFormat JpgFormat = LocalFilters.Get(ImGearFormats.JPG); ImGearControlParameter Param = JpgFormat.Parameters.GetByName("SaveType"); Param.Value = 1; // Lossless ImGearSaveOptions SaveOptions = new ImGearSaveOptions(); SaveOptions.Filters = LocalFilters; using (FileStream fsWrite = File.Open("Test.jpg", FileMode.Create, FileAccess.ReadWrite, FileShare.None)) ImGearFileFormats.SavePage(imGearPage, fsWrite, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.JPG, SaveOptions); |