Click or drag to resize

IMcImageCreateRegionAccess Method

Create a McRegionAccess interface for read/write pixel access.

Namespace:  MediaCy.IQL.Engine
Assembly:  MediaCy.IQL.Engine (in MediaCy.IQL.Engine.dll) Version: 10.0.6912.0
Syntax
VB
Function CreateRegionAccess ( 
	<OptionalAttribute> Type As Object,
	Optional Channel As Integer = -1,
	Optional Frame As Integer = -2,
	Optional lLeft As Integer = -1,
	Optional lTop As Integer = -1,
	Optional lRight As Integer = -1,
	Optional lBottom As Integer = -1
) As McRegionAccess

Parameters

Type (Optional)
Type: SystemObject
If given, Type of pixel values different from the image Type. For instance, to set/get 16 bit pixel values to/from an 8 bit image, pass the constant mciqtGray16 or an equivalent IMcImageType interface. By default if Type is missing or Empty, the pixel values will be exposed in the native format of the image.
Channel (Optional)
Type: SystemInt32
If given, for multi-channel images, where each pixel has one value per channel, specifies which channel value (starting with channel 0, e.g. Red for mciqtRGB) is to be set/read. By default, if channel = -1, all channel values are considered. When given, the McRegionAccess Get* and Put* methods effectively access the given Channel as a monochrome array of pixels.
Frame (Optional)
Type: SystemInt32
If given, the 0-based frame index of the frame to be accessed. Other allowed values are McActiveFrame and McLastFrame. McActiveFrame is the default.
lLeft (Optional)
Type: SystemInt32
lTop (Optional)
Type: SystemInt32
lRight (Optional)
Type: SystemInt32
lBottom (Optional)
Type: SystemInt32

Return Value

Type: McRegionAccess
A new McRegionAccess instance allowing read-write pixel access to pixels of the given Type in the given Frame for the given Channel within the given limits.
Remarks
This method creates a McRegionAccess instance with read-write access to pixels. Use the CreateRegionAccessEx method to create a McRegionAccess instance with read-only or write-only access. CreateRegionAccessEx also allows specification of the region-of-interest as an array or LONGRECT rather than as four separate values. A McRegionAccess instance gives full control over access to pixel values. For simple pixel access, use GetPixel / PutPixel, GetLine / PutLine, GetArea / PutArea. The source Type.MinCastingLuminance and Type.MaxCastingLuminance can be set by assigning to the CastingSourceRange property. CastingSourceRange is always reset to its default value (RangeMin to RangeMax) after any call to CreateRegionAccess.
Examples
VB
'
' Read an image cast to monochrome into a 32 bit 2-D Long buffer
'
Sub GetAreaAsLong()
' Access image such that that:
' - we want a 32 bit monochrome region access
' - pixel values are to be kept in the same range as the native ones
Dim imageType As McImageType
imageType = ThisApplication.ActiveImage.Type
imageType.BitsPerChannel = mcBitsPerChannel.mcbpc32Bits '32-bits per value
imageType.NumberOfChannels = 1 'monochrome
imageType.MinCastingLuminance = ThisApplication.ActiveImage.RangeMin
imageType.MaxCastingLuminance = ThisApplication.ActiveImage.RangeMax
' Create the new 32 bit monochrome McRegionAccess
Dim regionAccess As IMcRegionAccess
regionAccess = ThisApplication.ActiveImage.CreateRegionAccess(imageType)
' Read the image into an automatically created 2-D Long array
Dim vArea
regionAccess.GetArea vArea
End Sub
See Also