コード例 #1
0
        public static void Run()
        {
            Console.WriteLine("Running example SupportOfTextRenderingHint");
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            string[] files = new string[] {
                "TextHintTest.cdr",
                "TextHintTest.cmx",
                "TextHintTest.emf",
                "TextHintTest.wmf",
                "TextHintTest.odg",
                "TextHintTest.svg"
            };
            TextRenderingHint[] textRenderingHints = new TextRenderingHint[] {
                TextRenderingHint.AntiAlias, TextRenderingHint.AntiAliasGridFit,
                TextRenderingHint.ClearTypeGridFit, TextRenderingHint.SingleBitPerPixel, TextRenderingHint.SingleBitPerPixelGridFit
            };
            foreach (string fileName in files)
            {
                using (Image image = Image.Load(dataDir + fileName))
                {
                    VectorRasterizationOptions vectorRasterizationOptions;
                    if (image is CdrImage)
                    {
                        vectorRasterizationOptions = new CdrRasterizationOptions();
                    }
                    else if (image is CmxImage)
                    {
                        vectorRasterizationOptions = new CmxRasterizationOptions();
                    }
                    else if (image is EmfImage)
                    {
                        vectorRasterizationOptions = new EmfRasterizationOptions();
                    }
                    else if (image is WmfImage)
                    {
                        vectorRasterizationOptions = new WmfRasterizationOptions();
                    }
                    else if (image is OdgImage)
                    {
                        vectorRasterizationOptions = new OdgRasterizationOptions();
                    }
                    else if (image is SvgImage)
                    {
                        vectorRasterizationOptions = new SvgRasterizationOptions();
                    }
                    else
                    {
                        throw new Exception("This is image is not supported in this example");
                    }
                    vectorRasterizationOptions.PageSize = image.Size;
                    foreach (TextRenderingHint textRenderingHint in textRenderingHints)
                    {
                        string outputFileName = dataDir + "image_" + textRenderingHint + "_" + fileName + ".png";
                        vectorRasterizationOptions.TextRenderingHint = textRenderingHint;
                        image.Save(outputFileName, new PngOptions()
                        {
                            VectorRasterizationOptions = vectorRasterizationOptions
                        });
                    }
                }
            }

            Console.WriteLine("Finished example SupportOfTextRenderingHint");
        }
コード例 #2
0
        public static void Run()
        {
            Console.WriteLine("Running example SupportOfSmoothingMode");
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();


            string[] files = new string[]
            {
                "SmoothingTest.cdr", "SmoothingTest.cmx", "SmoothingTest.emf", "SmoothingTest.wmf",
                "SmoothingTest.odg", "SmoothingTest.svg"
            };
            SmoothingMode[] smoothingModes = new SmoothingMode[] { SmoothingMode.AntiAlias, SmoothingMode.None };
            foreach (string fileName in files)
            {
                using (Image image = Image.Load(dataDir + fileName))
                {
                    VectorRasterizationOptions vectorRasterizationOptions;
                    if (image is CdrImage)
                    {
                        vectorRasterizationOptions = new CdrRasterizationOptions();
                    }
                    else if (image is CmxImage)
                    {
                        vectorRasterizationOptions = new CmxRasterizationOptions();
                    }
                    else if (image is EmfImage)
                    {
                        vectorRasterizationOptions = new EmfRasterizationOptions();
                    }
                    else if (image is WmfImage)
                    {
                        vectorRasterizationOptions = new WmfRasterizationOptions();
                    }
                    else if (image is OdgImage)
                    {
                        vectorRasterizationOptions = new OdgRasterizationOptions();
                    }
                    else if (image is SvgImage)
                    {
                        vectorRasterizationOptions = new SvgRasterizationOptions();
                    }
                    else
                    {
                        throw new Exception("This is image is not supported in this example");
                    }

                    vectorRasterizationOptions.PageSize = image.Size;
                    foreach (SmoothingMode smoothingMode in smoothingModes)
                    {
                        string outputFileName = dataDir + "image_" + smoothingMode + "_" + fileName + ".png";
                        vectorRasterizationOptions.SmoothingMode = smoothingMode;
                        image.Save(
                            outputFileName,
                            new PngOptions()
                        {
                            VectorRasterizationOptions = vectorRasterizationOptions
                        });
                    }
                }
            }

            Console.WriteLine("Finished example SupportOfSmoothingMode");
        }