2016-03-08 62 views
-1

你好,我尝试打印图像数量在同一页与我的指定点如何编写e.Graphics.DrawImage的重载方法?为获得图像[],点[]

如何编写一个重载函数“e.Graphics.DrawImage”?

该重载的函数必须获取阵列和阵列的点的图像。然后图像[0]设置点[0],图像[1]设置点[1] .....该打印页后

现在绘制图像函数就像那样= e.Graphics.DrawImage(newImage,Point []); 但我需要像= e.Graphics.DrawImage(newImage [],Point []); if if before before pls help me

+0

我真的不明白你在问什么。请澄清你的问题。告诉我们你已经尝试过什么,并解释它为什么不起作用。 –

+0

sory我的英语不好。你能再读一遍吗? –

+0

你可以在'Graphics'上写一个扩展方法,如果这是你以后的样子的话。 –

回答

0

图形类是密封的而不是局部的,所以你不能覆盖或添加方法到这个类。但是你可以为该类

public static class GraphicsExtension 
{ 
    public static void DrawImage(this Graphics graphics, Image[] images, Point[] points) 
    { 
     for (int i = 0; i < images.Length; i++) 
     { 
      graphics.DrawImage(images[i], points[i]); 
     } 
    } 
} 

有了这个扩展,你可以叫你的DrawImage实施Graphics情况下做出extension。例如:e.Graphics.DrawImage(new Image[1], new Point[1]);

+0

thaks为您的答复。你能帮我写下你在哪里写的“//逻辑在这里”。得到包含5个图像的图像[]和包含5个点的点[]。那些图像必须在同一页上打印 –

+0

@çağrıGündüz我举了一个例子,可能它是你想要的。 – Valentin

+0

谢谢你的工作 –

相关问题