public static void Run()
        {
            // ExStart:CreateThumbnailsFromPSDFiles
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            // Load a PSD in an instance of PsdImage
            using (PsdImage image = (PsdImage)Image.Load(dataDir + "sample.psd"))
            {
                // Iterate over the PSD resources
                foreach (var resource in image.ImageResources)
                {
                    // Check if the resource is of thumbnail type
                    if (resource is ThumbnailResource)
                    {
                        // Retrieve the ThumbnailResource and Check the format of the ThumbnailResource
                        var thumbnail = (ThumbnailResource)resource;
                        if (thumbnail.Format == ThumbnailFormat.KJpegRgb)
                        {
                            // Create a new BmpImage by specifying the width and height,  Store the pixels of thumbnail on to the newly created BmpImage and save image
                            BmpImage thumnailImage = new BmpImage(thumbnail.Width, thumbnail.Height);
                            thumnailImage.SavePixels(thumnailImage.Bounds, thumbnail.ThumbnailData);
                            thumnailImage.Save(dataDir + "CreateThumbnailsFromPSDFiles_out.bmp");
                        }
                    }
                }
            }
            // ExEnd:CreateThumbnailsFromPSDFiles
        }
        public static void Run()
        {
            // ExStart:CreateThumbnailsFromPSDFiles
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PSD();

            // Load a PSD in an instance of PsdImage
            using (PsdImage image = (PsdImage)Image.Load(dataDir + "sample.psd"))
            {
                // Iterate over the PSD resources
                foreach (var resource in image.ImageResources)
                {
                    // Check if the resource is of thumbnail type
                    if (resource is ThumbnailResource)
                    {
                        // Retrieve the ThumbnailResource and Check the format of the ThumbnailResource
                        var thumbnail = (ThumbnailResource)resource;                       
                        if (thumbnail.Format == ThumbnailFormat.KJpegRgb)
                        {
                            // Create a new BmpImage by specifying the width and height,  Store the pixels of thumbnail on to the newly created BmpImage and save image
                            BmpImage thumnailImage = new BmpImage(thumbnail.Width, thumbnail.Height);
                            thumnailImage.SavePixels(thumnailImage.Bounds, thumbnail.ThumbnailData);
                            thumnailImage.Save(dataDir + "CreateThumbnailsFromPSDFiles_out.bmp");
                        }
                    }
                }
            }
            // ExEnd:CreateThumbnailsFromPSDFiles
        }
Esempio n. 3
0
        public static void Run()
        {
            Console.WriteLine("Running example ExtractTIFFFramesToBMPImageFormat");
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_ModifyingAndConvertingImages();

            using (TiffImage multiImage = (TiffImage)Image.Load(dataDir + "SampleTiff1.tiff"))
            {
                // Create an instance of int to keep track of frames in TiffImage
                int frameCounter = 0;

                // Iterate over the TiffFrames in TiffImage
                foreach (TiffFrame tiffFrame in multiImage.Frames)
                {
                    multiImage.ActiveFrame = tiffFrame;

                    // Load Pixels of TiffFrame into an array of Colors
                    Color[] pixels = multiImage.LoadPixels(tiffFrame.Bounds);

                    // Create an instance of bmpCreateOptions
                    BmpOptions bmpCreateOptions = new BmpOptions();
                    bmpCreateOptions.BitsPerPixel = 24;

                    // Set the Source of bmpCreateOptions as FileCreateSource by specifying the location where output will be saved
                    bmpCreateOptions.Source = new FileCreateSource(string.Format("{0}\\ConcatExtractTIFFFramesToBMP_out{1}.bmp", dataDir, frameCounter), false);

                    // Create a new bmpImage
                    using (BmpImage bmpImage = (BmpImage)Image.Create(bmpCreateOptions, tiffFrame.Width, tiffFrame.Height))
                    {
                        // Save the bmpImage with pixels from TiffFrame
                        bmpImage.SavePixels(tiffFrame.Bounds, pixels);
                        bmpImage.Save();
                    }
                    frameCounter++;
                }
            }

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