Exemple #1
0
        public static void Run()
        {
            // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Create instances of FileStream and initialize with Tiff images
            FileStream fileStream  = new FileStream(dataDir + "TestDemo.tif", FileMode.Open);
            FileStream fileStream1 = new FileStream(dataDir + "sample.tif", FileMode.Open);

            // Create an instance of TiffImage and load the destination image from filestream
            using (TiffImage image = (TiffImage)Image.Load(fileStream))
            {
                // Create an instance of TiffImage and load the source image from filestream
                using (TiffImage image1 = (TiffImage)Image.Load(fileStream1))
                {
                    // Create an instance of TIffFrame and copy active frame of source image
                    TiffFrame frame = TiffFrame.CopyFrame(image1.ActiveFrame);

                    // Add copied frame to destination image
                    image.AddFrame(frame);
                }
                // Save the image with changes
                image.Save(dataDir + "ConcatenatingTIFFImagesfromStream_out.tif");

                // Close the FileStreams
                fileStream.Close();
                fileStream1.Close();
            }
        }
Exemple #2
0
        public static void Run()
        {
            //ExStart:ConcatTIFFImages
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Create a copy of original image to avoid any alteration
            File.Copy(dataDir + "demo.tif", dataDir + "TestDemo.tif", true);

            // Create an instance of TiffImage and load the copied destination image
            using (TiffImage image = (TiffImage)Image.Load(dataDir + "TestDemo.tif"))
            {
                // Create an instance of TiffImage and load the source image
                using (TiffImage image1 = (TiffImage)Image.Load(dataDir + "sample.tif"))
                {
                    // Create an instance of TIffFrame and copy active frame of source image, Add copied frame to destination image and  Save the image with changes.
                    TiffFrame frame = TiffFrame.CopyFrame(image1.ActiveFrame);
                    image.AddFrame(frame);
                    image.Save(dataDir + "ConcatTIFFImages_out.tiff");
                }
            }
            //ExEnd:ConcatTIFFImages
            // Display Status.
            Console.WriteLine("Concatenation of TIF files done successfully.");
        }
Exemple #3
0
        public static void Run()
        {
            // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");
            // ExStart:ConcatTIFFImages
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Create a copy of original image to avoid any alteration
            File.Copy(dataDir + "demo.tif", dataDir + "TestDemo.tif", true);

            // Create an instance of TiffImage and load the copied destination image
            using (TiffImage image = (TiffImage)Image.Load(dataDir + "TestDemo.tif"))
            {
                // Create an instance of TiffImage and load the source image
                using (TiffImage image1 = (TiffImage)Image.Load(dataDir + "sample.tif"))
                {
                    // Create an instance of TIffFrame and copy active frame of source image
                    TiffFrame frame = TiffFrame.CopyFrame(image1.ActiveFrame);

                    // Add copied frame to destination image
                    image.AddFrame(frame);

                    // save the image with changes.
                    image.Save(dataDir + "ConcatTIFFImages_out.tiff");
                }
            }
            // ExEnd:ConcatTIFFImages
            // Display Status.
            Console.WriteLine("Concatenation of TIF files done successfully.");
        }
Exemple #4
0
        public static void Run()
        {
            Console.WriteLine("Running example ConcatenatingTIFFImagesfromStream");
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            // Create instances of FileStream and initialize with Tiff images
            FileStream fileStream  = new FileStream(dataDir + "TestDemo.tif", FileMode.Open);
            FileStream fileStream1 = new FileStream(dataDir + "sample.tif", FileMode.Open);

            // Create an instance of TiffImage and load the destination image from filestream
            using (TiffImage image = (TiffImage)Image.Load(fileStream))
            {
                // Create an instance of TiffImage and load the source image from filestream
                using (TiffImage image1 = (TiffImage)Image.Load(fileStream1))
                {
                    // Create an instance of TIffFrame and copy active frame of source image
                    TiffFrame frame = TiffFrame.CopyFrame(image1.ActiveFrame);

                    // Add copied frame to destination image
                    image.AddFrame(frame);
                }

                // Save the image with changes
                image.Save(dataDir + "ConcatenatingTIFFImagesfromStream_out.tif");

                // Close the FileStreams
                fileStream.Close();
                fileStream1.Close();
            }

            Console.WriteLine("Finished example ConcatenatingTIFFImagesfromStream");
        }
Exemple #5
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Imaging.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            //Create a copy of original image to avoid any alteration
            File.Copy(dataDir + "demo.tif", dataDir + "TestDemo.tif", true);

            //Create an instance of TiffImage and load the copied destination image
            using (TiffImage image = (TiffImage)Aspose.Imaging.Image.Load(dataDir + "TestDemo.tif"))
            {
                //Create an instance of TiffImage and load the source image
                using (TiffImage image1 = (TiffImage)Aspose.Imaging.Image.Load(dataDir + "sample.tif"))
                {
                    // Create an instance of TIffFrame and copy active frame of source image
                    TiffFrame frame = TiffFrame.CopyFrame(image1.ActiveFrame);

                    // Add copied frame to destination image
                    image.AddFrame(frame);

                    // save the image with changes.
                    image.Save();
                }
            }

            // Display Status.
            System.Console.WriteLine("Concatenation of TIF files done successfully.");
        }
        public static void Run()
        {
            Console.WriteLine("Running example AddFramesToTIFFImage");
            // To get proper output please apply a valid Aspose.Imaging License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx.");

            // The path to the documents directory.
            string      dataDir        = RunExamples.GetDataDir_ModifyingAndConvertingImages();
            TiffOptions outputSettings = new TiffOptions(TiffExpectedFormat.Default);

            outputSettings.BitsPerSample = new ushort[] { 1 };
            outputSettings.Compression   = TiffCompressions.CcittFax3;
            outputSettings.Photometric   = TiffPhotometrics.MinIsWhite;
            outputSettings.Source        = new StreamSource(new MemoryStream());
            int    newWidth  = 500;
            int    newHeight = 500;
            string path      = dataDir + "AddFramesToTIFFImage_out.tif";

            using (TiffImage tiffImage = (TiffImage)Image.Create(outputSettings, newWidth, newHeight))
            {
                int index = 0;
                foreach (var file in Directory.GetFiles(dataDir, "*.jpg"))
                {
                    using (RasterImage ri = (RasterImage)Image.Load(file))
                    {
                        ri.Resize(newWidth, newHeight, ResizeType.NearestNeighbourResample);
                        TiffFrame frame = tiffImage.ActiveFrame;
                        if (index > 0)
                        {
                            frame = new TiffFrame(new TiffOptions(outputSettings) /*ensure options are cloned for each frame*/,
                                                  newWidth, newHeight);
                            // If there is a TIFF image loaded you need to enumerate the frames and perform the following
                            // Frame = TiffFrame.CreateFrameFrom(sourceFrame, outputSettings);
                        }

                        frame.SavePixels(frame.Bounds, ri.LoadPixels(ri.Bounds));
                        if (index > 0)
                        {
                            tiffImage.AddFrame(frame);
                        }
                        index++;
                    }
                }
                tiffImage.Save(path);
            }

            Console.WriteLine("Finished example AddFramesToTIFFImage");
        }
        public static void Run()
        {
            //ExStart:MultipleImagesToTIFF
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();
            //String path = @"C:\Imaging Data\IMG\";
            int page      = 0;
            var tempImage = Aspose.Imaging.Image.Load(dataDir + "Image1.png");
            int width     = 500;
            int height    = 500;

            width  = tempImage.Width;
            height = tempImage.Height;
            Aspose.Imaging.ImageOptions.TiffOptions tiffOptions = new Aspose.Imaging.ImageOptions.TiffOptions(TiffExpectedFormat.Default);
            tiffOptions.Source = new Aspose.Imaging.Sources.FileCreateSource(dataDir + "MultiPage.tiff", false);

            //Create an instance of Image and initialize it with instance of BmpOptions by calling Create method
            using (TiffImage TiffImage = (TiffImage)Aspose.Imaging.Image.Create(tiffOptions, width, height))
            {
                //do some image processing
                DirectoryInfo di    = new DirectoryInfo(dataDir);
                FileInfo[]    files = di.GetFiles("*.img");
                int           index = 0;
                foreach (var file in files)
                {
                    using (Aspose.Imaging.Image inputImage = Aspose.Imaging.Image.Load(file.FullName))
                    {
                        inputImage.Resize(width, height, ResizeType.NearestNeighbourResample);
                        //  var frame = TiffImage.ActiveFrame;
                        if (index > 0)
                        {
                            var newframe = new TiffFrame(tiffOptions, width, height);
                            TiffImage.AddFrame(newframe);
                            int cnt = TiffImage.Frames.Count();
                        }
                        var frame = TiffImage.Frames[index];
                        frame.SavePixels(frame.Bounds, ((RasterImage)inputImage).LoadPixels(inputImage.Bounds));

                        index += 1;
                    }
                }

                // save all changes
                TiffImage.Save(dataDir + "output.tiff");
            }
        }
Exemple #8
0
        public static void Main(string[] args)
        {
            // The path to the documents directory.
            string dataDir = Aspose.Imaging.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            TiffOptions outputSettings = new TiffOptions();

            outputSettings.BitsPerSample = new ushort[] { 1 };
            outputSettings.Compression   = TiffCompressions.CcittFax3;
            outputSettings.Photometric   = TiffPhotometrics.MinIsWhite;
            outputSettings.Source        = new StreamSource(new MemoryStream());
            int    newWidth  = 500;
            int    newHeight = 500;
            string path      = dataDir + "output.tif";

            using (TiffImage tiffImage = (TiffImage)Image.Create(outputSettings, newWidth, newHeight))
            {
                int index = 0;
                foreach (var file in Directory.GetFiles(dataDir, "*.jpg"))
                {
                    using (RasterImage ri = (RasterImage)Image.Load(file))
                    {
                        ri.Resize(newWidth, newHeight, ResizeType.NearestNeighbourResample);
                        TiffFrame frame = tiffImage.ActiveFrame;
                        if (index > 0)
                        {
                            frame = new TiffFrame(new TiffOptions(outputSettings) /*ensure options are cloned for each frame*/,
                                                  newWidth, newHeight);
                            // If there is a TIFF image loaded you need to enumerate the frames and perform the following
                            // frame = TiffFrame.CreateFrameFrom(sourceFrame, outputSettings);
                        }

                        frame.SavePixels(frame.Bounds, ri.LoadPixels(ri.Bounds));
                        if (index > 0)
                        {
                            tiffImage.AddFrame(frame);
                        }

                        index++;
                    }
                }

                tiffImage.Save(path);
            }
        }