BitmapDataExtensionsResize Method

Resizes the specified source.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.1.0
C#
public static IReadWriteBitmapData Resize(
	this IReadableBitmapData source,
	Size newSize,
	ScalingMode scalingMode = ScalingMode.Auto,
	bool keepAspectRatio = false
)

Parameters

source  IReadableBitmapData
The source IReadableBitmapData to resize.
newSize  Size
The requested new size.
scalingMode  ScalingMode  (Optional)
A ScalingMode value, which determines the quality of the result as well as the processing time. This parameter is optional.
Default value: Auto.
keepAspectRatio  Boolean  (Optional)
to keep aspect ratio of the specified source; otherwise, . This parameter is optional.
Default value: .

Return Value

IReadWriteBitmapData
A new IReadWriteBitmapData, which is the resized version of the specified source.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IReadableBitmapData. 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).

Remarks

  Note

This method adjusts the degree of parallelization automatically, blocks the caller, and does not support cancellation or reporting progress. Use the BeginResize or ResizeAsync (in .NET Framework 4.0 and above) methods for asynchronous call and to adjust parallelization, set up cancellation and for reporting progress.

The result PixelFormat depends on the WorkingColorSpace of the source bitmap data but is always at least a 32 BPP format. To resize a bitmap data with a custom pixel format you can create a new IReadWriteBitmapData instance by the CreateBitmapData(Size, KnownPixelFormat, Color32, Byte) method and use the DrawInto extension methods, which has several overloads that also allow quantizing and dithering.

Exceptions

ArgumentNullExceptionsource is .
ArgumentOutOfRangeExceptionscalingMode has an unsupported value.

See Also