Tiff 文件的重复功能需要 TILE 功能

问题描述

我想读取图像文件 (6477 X 6840) 像素并在 Y 方向复制 2 次,在 X 方向复制 8 次。 试了这么多程序,时间太长了。

public static void FillPattern(Graphics g,Image image,Rectangle rect) 
{ 
    Rectangle imageRect; 
    Rectangle drawRect; 
    for (int x = rect.X; x < rect.Right; x += image.Width) 
    { 
        for (int y = rect.Y; y < rect.Bottom; y += image.Height) 
        { 
            drawRect = new Rectangle(x,y,Math.Min(image.Width,rect.Right - x),Math.Min(image.Height,rect.Bottom - y)); 
            imageRect = new Rectangle(0,drawRect.Width,drawRect.Height); 
            g.DrawImage(image,drawRect,imageRect,GraphicsUnit.Pixel); 
        } 
    } 
}

解决方法

 if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            foreach (String file in openFileDialog1.FileNames)
            {
                using (MagickImage image = new MagickImage(file))
                {
                    image.Format = MagickFormat.Tiff;
                    EnteredRepeat = short.Parse(TxbLenRpt.Text);
                    for (int i = 0; i < EnteredRepeat; i++)
                    {
                        image.Write("D:\\IMAGICK\\Apped Folder\\Outfile" + i+".tiff");
                    }
                    using (MagickImageCollection frames = new MagickImageCollection())
                    {
                        for (int i = 0; i < EnteredRepeat; i++)
                        {
                            string[] files = Directory.GetFiles(@"D:\\IMAGICK\\Apped Folder","*.tiff");
                            frames.Add(files[i]);
                            frames.AppendHorizontally();
                            frames.Write("D:\\IMAGICK\\MultiRepeat.tiff");
                        }
                    }
                }
            }
        }

我发现这种从文件创建多个文件的方法,然后将它们水平附加以实现受约束的解决方案。 代码工作正常,没有任何错误。它还会创建 EnteredRepeat nos 文件。但是在附加时它只给出了一个具有原始文件大小的文件。 从 3 天开始就一直在努力并在最后一刻卡住了。 寻找你的朋友。