Bitmap.LockBits Method (Rectangle, ImageLockMode, PixelFormat, BitmapData)

Locks a Bitmap into system memory

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

public BitmapData LockBits (
	Rectangle rect,
	ImageLockMode flags,
	PixelFormat format,
	BitmapData bitmapData
)
public BitmapData LockBits (
	Rectangle rect, 
	ImageLockMode flags, 
	PixelFormat format, 
	BitmapData bitmapData
)
public function LockBits (
	rect : Rectangle, 
	flags : ImageLockMode, 
	format : PixelFormat, 
	bitmapData : BitmapData
) : BitmapData
Not applicable.

Parameters

rect

A rectangle structure specifying the portion of the Bitmap to lock.

flags

One of the ImageLockMode values specifying the access level (read/write) for the Bitmap.

format

One of the PixelFormat values indicating the data format of the Bitmap.

bitmapData

A BitmapData containing information about the lock operation.

Return Value

A BitmapData containing information about the lock operation.

Exception typeCondition

ArgumentException

PixelFormat value is not a specific bits-per-pixel value.

-or-

The incorrect PixelFormat is passed in for a bitmap.

Exception

The operation failed.

This version of the LockBits method is intended to be used with a flags value of ImageLockMode.UserInputBuffer.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Show: