private IList<Image> Clone(IList<Image> images)
{
IList<Image> clonedImages = new List<Image>();
foreach (Image image in (index == -1 ? images : ((List<Image>)images).GetRange(index, 1)))
{
if (dpiX == 0 || dpiY == 0)
{
if (rect == null || rect == Rectangle.Empty)
{
clonedImages.Add(image);
}
else
{
clonedImages.Add(ImageHelper.Crop(image, rect));
rect = Rectangle.Empty; // no rectangle is needed for processing a subimage
}
}
else
{
// rescaling
if (rect == null || rect == Rectangle.Empty)
{
clonedImages.Add(ImageHelper.Rescale(image, dpiX, dpiY));
}
else
{
clonedImages.Add(ImageHelper.Rescale(ImageHelper.Crop(image, rect), dpiX, dpiY));
rect = Rectangle.Empty; // no rectangle is needed for processing a subimage
}
}
}
return clonedImages;
}