【问题标题】:Repeat function for Tiff file needed TILE functionTiff 文件的重复功能需要 TILE 功能
【发布时间】:2021-06-02 14:22:43
【问题描述】:

我想读取图像文件 (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, 0, drawRect.Width, drawRect.Height); 
            g.DrawImage(image, drawRect, imageRect, GraphicsUnit.Pixel); 
        } 
    } 
}

【问题讨论】:

  • 它的代码很简单,但对于 1000x1000 像素的文件需要将近 15 分钟。
  • 你想达到什么目的?你能想象你的应用必须渲染多少像素吗?即使使用 Paint 或 Photoshop 打开此类文件,对于性能较弱的 PC 来说也可能是个问题。
  • @BorisSokolov 这是用于打印应用程序文件。打印尺寸约为 1208mmX3200mm,分辨率为 720 dpi,我们目前正在实现 2 个阶段,翻录和打印。我想设计一个可以直接打印的软件。
  • 嗯...在这种情况下,我宁愿使用某种专门的软件(Photoshop 等)。我不认为使用图形库实现合理的性能是不现实的跨度>

标签: c# imaging


【解决方案1】:
 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 文件数。但是,虽然附加它只提供一个具有原始文件大小的文件。 3天以来一直在努力并在最后一刻卡住了。 寻找你的朋友。

【讨论】:

    猜你喜欢
    • 2021-09-09
    • 1970-01-01
    • 1970-01-01
    • 2014-01-13
    • 2018-03-03
    • 1970-01-01
    • 1970-01-01
    • 2021-12-08
    • 1970-01-01
    相关资源
    最近更新 更多