-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
29 lines (25 loc) · 1.21 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System.IO;
using ImageGear.Core;
using ImageGear.Formats;
namespace SetFilterControlParametersGlobally
{
internal class Program
{
static void Main()
{
// Initialize common formats.
ImGearCommonFormats.Initialize();
// Set JPEG Filter Control Parameter "SaveType" to 1 so that ImageGear saves JPEG using lossless compression instead of lossy compression.
IImGearFormat jpgFormat = ImGearFileFormats.Filters.Get(ImGearFormats.JPG);
ImGearControlParameter Param = jpgFormat.Parameters.GetByName("SaveType");
Param.Value = 1;
// Load image page.
ImGearPage imGearPage = null;
using (FileStream inputStream = new FileStream(@"../../../../../../Sample Input/water.jpg", FileMode.Open, FileAccess.Read, FileShare.Read))
imGearPage = ImGearFileFormats.LoadPage(inputStream);
// Save image page as lossless JPEG.
using (FileStream outputStream = new FileStream(@"../../../../../../Sample Output/SetFilterControlParametersGlobally.jpg", FileMode.Create))
ImGearFileFormats.SavePage(imGearPage, outputStream, ImGearSavingFormats.JPG);
}
}
}