ImageExtensionsDrawInto Method (Image, Bitmap, Rectangle, Point, IDitherer)

KGy SOFT Drawing Libraries Help
Draws the source Image into the target Bitmap. This method is similar to Graphics.DrawImage except that it never scales the image and that works between any pair of source and target PixelFormats. If target can represent a narrower set of colors, then the result will be automatically quantized to the colors of the target, and also an optional ditherer can be specified.
See the Remarks section for details.

Namespace:  KGySoft.Drawing
Assembly:  KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 5.1.0
Syntax

public static void DrawInto(
	this Image source,
	Bitmap target,
	Rectangle sourceRect,
	Point targetLocation,
	IDitherer ditherer = null
)

Parameters

source
Type: System.DrawingImage
The source Image to be drawn into the target.
target
Type: System.DrawingBitmap
The target Bitmap into which source should be drawn.
sourceRect
Type: System.DrawingRectangle
The source area to be drawn into the target.
targetLocation
Type: System.DrawingPoint
The target location. Target size will be always the same as the source size.
ditherer (Optional)
Type: KGySoft.Drawing.ImagingIDitherer
The ditherer to be used for the drawing. Has no effect, if target pixel format has at least 24 bits-per-pixel size. This parameter is optional.
Default value: .

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Image. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Exceptions

ExceptionCondition
ArgumentNullExceptionsource or target is
Remarks

The method has the best performance if both source and target images have Format32bppPArgb formats but works between any combinations and it is always faster than the Graphics.DrawImage method.

The image to be drawn is automatically clipped if its size or targetLocation makes it impossible to completely fit in the target.

See Also

Reference