Convert OneNote to image in various color modes

Save OneNote to a grayscale image in Png format

The following code example demonstrates how to convert a OneNotet to a grayscale image. The ColorMode property of ImageSaveOptions instance is used to indicate that output image should be grayscale.

 1            // The path to the documents directory.
 2            string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
 3
 4            // Load the document into Aspose.Note.
 5            Document oneFile = new Document(dataDir + "Aspose.one");
 6
 7            dataDir = dataDir + "SaveAsGrayscaleImage_out.png";
 8
 9            // Save the document as gif.
10            oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
11                                      {
12                                          ColorMode = ColorMode.GrayScale
13                                      });

Save OneNote to a binary image

There are various methods for image’s binarization. Aspose.Note supports two well-known methods: thresholding and Otsu’s method.

The following code example demonstrates how to convert a OneNote to a binary image using thresholding method. The BinarizationOptions property of ImageSaveOptions instance is used to indicate that thresholding method should be applied.

 1            // The path to the documents directory.
 2            string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
 3
 4            // Load the document into Aspose.Note.
 5            Document oneFile = new Document(dataDir + "Aspose.one");
 6
 7            dataDir = dataDir + "SaveToBinaryImageUsingFixedThreshold_out.png";
 8
 9            // Save the document as gif.
10            oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
11                                      {
12                                          ColorMode = ColorMode.BlackAndWhite,
13                                          BinarizationOptions = new ImageBinarizationOptions()
14                                                                    {
15                                                                        BinarizationMethod = BinarizationMethod.FixedThreshold,
16                                                                        BinarizationThreshold = 123
17                                                                    }
18                                      });

The following code example demonstrates how to convert a OneNote to a binary image using Otsu’s method. The BinarizationOptions property of ImageSaveOptions instance is used to indicate that Otsu’s method should be applied.

 1            // The path to the documents directory.
 2            string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
 3
 4            // Load the document into Aspose.Note.
 5            Document oneFile = new Document(dataDir + "Aspose.one");
 6
 7            dataDir = dataDir + "SaveToBinaryImageUsingOtsuMethod_out.png";
 8
 9            // Save the document as gif.
10            oneFile.Save(dataDir, new ImageSaveOptions(SaveFormat.Png)
11                                    {
12                                        ColorMode = ColorMode.BlackAndWhite,
13                                        BinarizationOptions = new ImageBinarizationOptions()
14                                                              {
15                                                                  BinarizationMethod = BinarizationMethod.Otsu,
16                                                              }
17                                    });

Save OneNote to a binary image in TIFF format with specified compression and default binarization options

The following code example demonstrates how to convert a OneNote to a binary image and save it in TIFF format using Jpeg compression. The ColorMode property of ImageSaveOptions instance is used to indicate that output image should be binary. The TiffCompression property of ImageSaveOptions instance is used to indicate that Jpeg compression should be applied. By default thresholding binarization method with threshold 128 is applied.

 1            // The path to the documents directory.
 2            string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
 3
 4            // Load the document into Aspose.Note.
 5            Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
 6
 7            var dst = Path.Combine(dataDir, "SaveToTiffUsingJpegCompression.tiff");
 8
 9            // Save the document.
10            oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
11                                  {
12                                      TiffCompression = TiffCompression.Jpeg,
13                                      Quality = 93
14                                  });

The following code example demonstrates how to convert a OneNote to a binary image and save it in TIFF format using CCITT Group 3 fax compression. The TiffCompression property of ImageSaveOptions instance is used to indicate that CCITT Group 3 fax compression should be applied.

 1            string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
 2
 3            // Load the document into Aspose.Note.
 4            Document oneFile = new Document(Path.Combine(dataDir, "Aspose.one"));
 5
 6            var dst = Path.Combine(dataDir, "SaveToTiffUsingCcitt3Compression.tiff");
 7
 8            // Save the document.
 9            oneFile.Save(dst, new ImageSaveOptions(SaveFormat.Tiff)
10                                  {
11                                      ColorMode = ColorMode.BlackAndWhite,
12                                      TiffCompression = TiffCompression.Ccitt3
13                                  });
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.