Hi,
trying to save some thumbnail viewer selected items into a new multipage TIFF file and deleting those from the
image collection, I simply don't get the clue.
Have some code sample for that issue?
Thank you and best regards
Guenther
Extract some pages to a new multipage tiff
Moderator: Alex
-
- Site Admin
- Posts: 2397
- Joined: Thu Jul 10, 2008 2:21 pm
Re: Extract some pages to a new multipage tiff
Hi Guenter,
Here is a code snippet that shows how to save images, which are selected in thumbnail viewer, to a TIFF file and remove saved images from thumbnail viewer:
Best regards, Alexander
Here is a code snippet that shows how to save images, which are selected in thumbnail viewer, to a TIFF file and remove saved images from thumbnail viewer:
Code: Select all
using System;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// add images to the thumbnail viewer
thumbnailViewer1.Images.Add("DocCleanMultipage.tif");
}
private void saveImagesButton_Click(object sender, EventArgs e)
{
// create or open TIFF file
using (System.IO.FileStream fs = new System.IO.FileStream("result.tif", System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite))
{
// create TIFF encoder
Vintasoft.Imaging.Codecs.Encoders.TiffEncoder tiffEncoder = new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder();
// specify that images must be added to the existing TIFF file
tiffEncoder.CreateNewFile = false;
// get the indices of thumbnails, which are selected in thumbnail viewer
Vintasoft.Imaging.UI.IndicesCollection indicesCollection = thumbnailViewer1.SelectedIndices;
// for each selected thumbnail
foreach (int i in indicesCollection)
{
// add image to the TIFF file
tiffEncoder.SaveImage(thumbnailViewer1.Images[i], fs);
}
// remove saved thumbnails from thumbnail viewer
thumbnailViewer1.Images.RemoveRange(indicesCollection.ToArray());
}
}
}
}
-
- Posts: 4
- Joined: Thu Sep 06, 2018 10:51 am
Re: Extract some pages to a new multipage tiff
That's great!
Thank you very much
Best Regards
Guenther
Thank you very much
Best Regards
Guenther