FreeImage.CreateView Method

FreeImage.NET

FreeImageCreateView Method
Creates a dynamic read/write view into a FreeImage bitmap.

Namespace: FreeImageAPI
Assembly: FreeImageNET (in FreeImageNET.dll) Version: 3.17.0.4 (3.17.0)
Syntax
C#
public static FIBITMAP CreateView(
	FIBITMAP dib,
	int left,
	int top,
	int right,
	int bottom
)

Parameters

dib
Type: FreeImageAPIFIBITMAP
The FreeImage bitmap on which to create the view.
left
Type: SystemInt32
The left position of the view's area.
top
Type: SystemInt32
The top position of the view's area.
right
Type: SystemInt32
The right position of the view's area.
bottom
Type: SystemInt32
The bottom position of the view's area.

Return Value

Type: FIBITMAP
A handle to the newly created view or returns NULL if the view was not created.
Remarks

A dynamic view is a FreeImage bitmap with its own width and height, that, however, shares its bits with another FreeImage bitmap. Typically, views are used to define one or more rectangular sub-images of an existing bitmap. All FreeImage operations, like saving, displaying and all the toolkit functions, when applied to the view, only affect the view's rectangular area.

Although the view's backing image's bits not need to be copied around, which makes the view much faster than similar solutions using Copy(FIBITMAP, Int32, Int32, Int32, Int32), a view uses some private memory that needs to be freed by calling Unload(FIBITMAP) on the view's handle to prevent memory leaks.

Only the backing image's pixels are shared by the view. For all other image data, notably for the resolution, background color, color palette, transparency table and for the ICC profile, the view gets a private copy of the data. By default, the backing image's metadata is NOT copied to the view.

As with all FreeImage functions that take a rectangle region, top and left positions are included, whereas right and bottom positions are excluded from the rectangle area. Since the memory block shared by the backing image and the view must start at a byte boundary, the value of parameter left must be a multiple of 8 for 1-bit images and a multiple of 2 for 4-bit images.

See Also