DrawImage Overloads

I'm sure that you've noticed that there are 30 different DrawImage subroutines, and it is easy to get lost in them. So, here I will cover the 18 (easiest) ones and what they do exactly. The 12 (harder) ones being ones where you have to setup and declare an ImageAttributes property, which is its own beast, but doesn't change the drawing source and destinations by any amount. :) Let's get to it. (Red denotes Single/float values and Blue denotes Integer/int values)

Overload 1: GFX.DrawImage(Bmp, New PointF(X, Y))

This is one of the easy ones. This copies the whole source picture to the destination. Note: The source picture is Bmp, but the destination is whatever the GFX object is aimed at. The upper-left corner of the picture is placed directly on the point X,Y of the destination. The width and height of the final drawing is the same as the source picture (width and height of Bmp).

Overload 2: GFX.DrawImage(Bmp, X, Y)

This is the same as Overload 1, except that you do not specify an actual point structure. Instead the destination coordinates are passed in directly as their own value. The same thing happens here as it does in Overload 1.

Overload 3: GFX.DrawImage(Bmp, New RectangleF(X, Y, W, H))

The 3rd overload does draw the entire source picture at the specified X,Y point on the destination, but it also stretches the source picture so that the final drawing's width and height match the rectangle's width and height specified. Again, the source picture is stretched to fill the rectangle if the rectangle was placed on the destination.

Overload 4: GFX.DrawImage(Bmp, X, Y, W, H)

This is the same as Overload 3, except you pass the X, Y, W, and H of the picture directly, instead of through the rectangle. The source picture is drawn at the coordinates of X,Y with a width of W and a height of H.

Overload 5: GFX.DrawImage(Bmp, New Point(X, Y))

This is the integer version of Overload 1. The upper-left corner of the picture is placed directly on the point X,Y of the destination. The width and height of the final drawing is the same as the source picture (width and height of Bmp).

Overload 6: GFX.DrawImage(Bmp, X, Y)

Integer version of Overload 2.

Overload 7: GFX.DrawImage(Bmp, New Rectangle(X, Y, W, H))

Integer version of Overload 3.

Overload 8: GFX.DrawImage(Bmp, X, Y, W, H)

Integer version of Overload 4. Overloads 9 and 10 deal with making parallelograms out of three points. The following picture demonstrates how the parallelogram is made. The first point specified indicates where the upperleft corner of the image will be. The second point is for the upper right corner and the third point is for the lower left corner. The three points can be thrown anywhere. If the points make a straight line, you won't see anything. The fourth point will be moved away from point three by the same amount that point two is moved away from point one, and similarly point 4 is away from point 2 just like point 3 is away from 1. The line connecting the points that are opposite of each other will be the same length and angle (characteristic of a parallelogram). This is what happens in Overloads 9 and 10

Overload 9: GFX.DrawImage(Bmp, New PointF() {New PointF(x1, y1), New PointF(x2, y2), New PointF(x3, y3)})

Parallelogram. Picture end points are translated into the parallelogram, which define how the appear.

Overload 10: GFX.DrawImage(Bmp, New Point() {New Point(x1, y1), New Point(x2, y2), New Point(x3, y3)})

Integer version of Overload 9. The following overloads are capable of taking only a portion of the source picture to be drawn.

Overload 11: GFX.DrawImage(Bmp, fX, fY, New RectangleF(X, Y, W, H), GraphicsUnit.Pixel)

This overload will take the rectangle from the source picture and copy this rectangle to the destination at the point with the coordinates of fX,fY. This overload is the second closest equivalent to BitBlt (Overload 12 is closest, only because of Integer arguments). The drawn picture will have the same width and height as the rectangle used to make a selection from the source picture.

Overload 12: GFX.DrawImage(Bmp, fX, fY, New Rectangle(X, Y, W, H), GraphicsUnit.Pixel)

Integer version of Overload 11. This overload will also take the rectangle from the source picture and copy this rectangle to the destination at the point with the coordinates of fX,fY.

Overload 13: GFX.DrawImage(Bmp, New RectangleF(fX, fY, fW, fH), New RectangleF(X, Y, W, H), GraphicsUnit.Pixel)

This overload is similar to Overload 11/12. It takes a rectangle selection from the source picture and draws it to the destination. However, the first rectangle specified is the rectangle that indicates where this selection will be drawn. So, the selection that was already taken from the source will be stretched over the final destination rectangle. This overload is similar to StretchBlt (of course, Overload 14 is closer because of its Integer arguments).

Overload 14: GFX.DrawImage(Bmp, New Rectangle(fX, fY, fW, fH), New Rectangle(X, Y, W, H), GraphicsUnit.Pixel)

Integer version of Overload 13. The selection from the source will be stretched over the final destination rectangle and drawn.

Overload 15: GFX.DrawImage(Bmp, New PointF() {New PointF(x1, y1), New PointF(x2, y2), New PointF(x3, y3)}, New RectangleF(X, Y, W, H), GraphicsUnit.Pixel)

This overload combines the effect of taking a selection from the source with the parallelogram drawings for destination. The selection from the source picture (instead of taking the entire source) will be stretched and translated onto the parallelogram described by the 3 points. Overloads 16, 17, and 18 are the same as Overload 15, except with the option to pass an image attributes object, a callback function, and callback data.

Overload 19: GFX.DrawImage(Bmp, New Point() {New Point(x1, y1), New Point(x2, y2), New Point(x3, y3)}, New Rectangle(X, Y, W, H), GraphicsUnit.Pixel)

Integer version of Overload 15. Overloads 20, 21, and 22 are Integer versions of Overloads 16, 17, and 18, respectively. They also have options for passing image attributes, callback functions, and callback data.

Overload 23: GFX.DrawImage(Bmp, New Rectangle(fX, fY, fW, fH), X, Y, W, H, GraphicsUnit.Pixel)

This overload is very similar to Overload 13, except the source rectangle parameters are passed directly to the function instead of through a rectangle. Another interesting thing about this overload, the rectangle is not a RectangleF, but an integer Rectangle. This is somehow related to the GraphicsUnit.Pixel operand. Since this operand will rarely be anything but GraphicsUnit.Pixel (unless you're using GDI+ to print, maybe?), I will overlook it for now. Overloads 24, 25, and 26 are the same as Overload 23, but with the option to pass image attributes, callback functions, and callback data.

Overload 27: GFX.DrawImage(Bmp, New Rectangle(fX, fY, fW, fH), X, Y, W, H, GraphicsUnit.Pixel)

Integer version of Overload 23. Overloads 28, 29, and 30 are the same as Overload 27, Integer versions of Overloads 24, 25 and 26, respectively, with the options for passing image attributes, callback functions, and callback data.