GDI+ : Stretching vs. Tiling in Graphics.DrawImage
Posted on 2004-09-20
My app copies rectangular sections of one image to another. The destination is not necessarily the same size as the source...sometimes I want to stretch these images, and sometimes tile them.
Looks like Graphics.DrawImage can't tile an image, but I don't know. When copying using Graphics.DrawImage, the image is stretched...that's the default behavior. Certain overloads take ImageAttributes, which should allow me to tile, but can anyone get this to work. Here's a line from my code:
G.DrawImage(PaintImage, Destination, iLeftMargin, iTopMargin, iWidth, iHeight, GraphicsUnit.Pixel, imgAttributes)
Can anyone construct a code example where imgAttributes causes the source to tile into the destination? If not, then how to tile an image? I was thinking maybe that I have to create a brush to tile an image since DrawImage doesn't allow it...