'
'
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports Matrox.MatroxImagingLibrary
Namespace MBufColor
Friend Class Program
Private Const IMAGE_FILE As String = MIL.M_IMAGE_PATH & "Bird.mim"
Private Const IMAGE_LUMINANCE_OFFSET As Integer = 40
Shared Sub Main(ByVal args() As String)
Dim MilApplication As MIL_ID = MIL.M_NULL
Dim MilSystem As MIL_ID = MIL.M_NULL
Dim MilDisplay As MIL_ID = MIL.M_NULL
Dim MilImage As MIL_ID = MIL.M_NULL
Dim MilLeftSubImage As MIL_ID = MIL.M_NULL
Dim MilRightSubImage As MIL_ID = MIL.M_NULL
Dim MilLumSubImage As MIL_ID = MIL.M_NULL
Dim MilRedBandSubImage As MIL_ID = MIL.M_NULL
Dim MilGreenBandSubImage As MIL_ID = MIL.M_NULL
Dim MilBlueBandSubImage As MIL_ID = MIL.M_NULL
Dim SizeX As MIL_INT = 0
Dim SizeY As MIL_INT = 0
Dim SizeBand As MIL_INT = 0
Dim Type As MIL_INT = 0
MIL.MappAllocDefault(MIL.M_DEFAULT, MilApplication, MilSystem, MilDisplay, CType(MIL.M_NULL, IntPtr), CType(MIL.M_NULL, IntPtr))
MIL.MbufAllocColor(MilSystem, _
MIL.MbufDiskInquire(IMAGE_FILE, MIL.M_SIZE_BAND, SizeBand), _
MIL.MbufDiskInquire(IMAGE_FILE, MIL.M_SIZE_X, SizeX) * 2, _
MIL.MbufDiskInquire(IMAGE_FILE, MIL.M_SIZE_Y, SizeY), _
MIL.MbufDiskInquire(IMAGE_FILE, MIL.M_TYPE, Type), _
MIL.M_IMAGE + MIL.M_DISP + MIL.M_PROC, MilImage)
MIL.MbufClear(MilImage, 0)
MIL.MdispSelect(MilDisplay, MilImage)
'
MIL.MbufChild2d(MilImage, 0, 0, SizeX, SizeY, MilLeftSubImage)
MIL.MbufChild2d(MilImage, SizeX, 0, SizeX, SizeY, MilRightSubImage)
MIL.MbufLoad(IMAGE_FILE, MilLeftSubImage)
'
MIL.MbufChildColor(MilLeftSubImage, MIL.M_RED, MilRedBandSubImage)
MIL.MbufChildColor(MilLeftSubImage, MIL.M_GREEN, MilGreenBandSubImage)
MIL.MbufChildColor(MilLeftSubImage, MIL.M_BLUE, MilBlueBandSubImage)
'
MIL.MgraColor(MIL.M_DEFAULT, &HFF)
MIL.MgraText(MIL.M_DEFAULT, MilRedBandSubImage, SizeX / 16, SizeY / 8, " TOUCAN ")
MIL.MgraColor(MIL.M_DEFAULT, &H90)
MIL.MgraText(MIL.M_DEFAULT, MilGreenBandSubImage, SizeX / 16, SizeY / 8, " TOUCAN ")
MIL.MgraColor(MIL.M_DEFAULT, &H0)
MIL.MgraText(MIL.M_DEFAULT, MilBlueBandSubImage, SizeX / 16, SizeY / 8, " TOUCAN ")
Console.Write(Constants.vbLf + "COLOR OPERATIONS:" + Constants.vbLf)
Console.Write("-----------------" + Constants.vbLf + Constants.vbLf)
Console.Write("A color source image was loaded on the left and color text" + Constants.vbLf)
Console.Write("annotations were written in it." + Constants.vbLf)
Console.Write("Press <Enter> to continue." + Constants.vbLf + Constants.vbLf)
Console.ReadKey()
MIL.MimConvert(MilLeftSubImage, MilRightSubImage, MIL.M_RGB_TO_HSL)
MIL.MbufChildColor(MilRightSubImage, MIL.M_LUMINANCE, MilLumSubImage)
MIL.MimArith(MilLumSubImage, IMAGE_LUMINANCE_OFFSET, MilLumSubImage, MIL.M_ADD_CONST + MIL.M_SATURATION)
MIL.MimConvert(MilRightSubImage, MilRightSubImage, MIL.M_HSL_TO_RGB)
Console.Write("Luminance was increased using color image processing." + Constants.vbLf)
Console.Write("Press <Enter> to end." + Constants.vbLf)
Console.ReadKey()
MIL.MbufFree(MilLumSubImage)
MIL.MbufFree(MilRedBandSubImage)
MIL.MbufFree(MilGreenBandSubImage)
MIL.MbufFree(MilBlueBandSubImage)
MIL.MbufFree(MilRightSubImage)
MIL.MbufFree(MilLeftSubImage)
MIL.MbufFree(MilImage)
MIL.MappFreeDefault(MilApplication, MilSystem, MilDisplay, MIL.M_NULL, MIL.M_NULL)
End Sub
End Class
End Namespace