using System;
using System.Collections.Generic;
using System.Text;
using Matrox.MatroxImagingLibrary;
namespace MBufColor
{
class Program
{
private const string IMAGE_FILE = MIL.M_IMAGE_PATH + "Bird.mim";
private const int IMAGE_LUMINANCE_OFFSET = 40;
static void Main(string[] args)
{
MIL_ID MilApplication = MIL.M_NULL;
MIL_ID MilSystem = MIL.M_NULL;
MIL_ID MilDisplay = MIL.M_NULL;
MIL_ID MilImage = MIL.M_NULL;
MIL_ID MilLeftSubImage = MIL.M_NULL;
MIL_ID MilRightSubImage = MIL.M_NULL;
MIL_ID MilLumSubImage = MIL.M_NULL;
MIL_ID MilRedBandSubImage = MIL.M_NULL;
MIL_ID MilGreenBandSubImage = MIL.M_NULL;
MIL_ID MilBlueBandSubImage = MIL.M_NULL;
MIL_INT SizeX = 0;
MIL_INT SizeY = 0;
MIL_INT SizeBand = 0;
MIL_INT Type = 0;
MIL.MappAllocDefault(MIL.M_DEFAULT, ref MilApplication, ref MilSystem, ref MilDisplay, MIL.M_NULL, MIL.M_NULL);
MIL.MbufAllocColor(MilSystem,
MIL.MbufDiskInquire(IMAGE_FILE, MIL.M_SIZE_BAND, ref SizeBand),
MIL.MbufDiskInquire(IMAGE_FILE, MIL.M_SIZE_X, ref SizeX) * 2,
MIL.MbufDiskInquire(IMAGE_FILE, MIL.M_SIZE_Y, ref SizeY),
MIL.MbufDiskInquire(IMAGE_FILE, MIL.M_TYPE, ref Type),
MIL.M_IMAGE + MIL.M_DISP + MIL.M_PROC, ref MilImage);
MIL.MbufClear(MilImage, 0);
MIL.MdispSelect(MilDisplay, MilImage);
MIL.MbufChild2d(MilImage, 0, 0, SizeX, SizeY, ref MilLeftSubImage);
MIL.MbufChild2d(MilImage, SizeX, 0, SizeX, SizeY, ref MilRightSubImage);
MIL.MbufLoad(IMAGE_FILE, MilLeftSubImage);
MIL.MbufChildColor(MilLeftSubImage, MIL.M_RED, ref MilRedBandSubImage);
MIL.MbufChildColor(MilLeftSubImage, MIL.M_GREEN, ref MilGreenBandSubImage);
MIL.MbufChildColor(MilLeftSubImage, MIL.M_BLUE, ref MilBlueBandSubImage);
MIL.MgraColor(MIL.M_DEFAULT, 0xFF);
MIL.MgraText(MIL.M_DEFAULT, MilRedBandSubImage, SizeX / 16, SizeY / 8, " TOUCAN ");
MIL.MgraColor(MIL.M_DEFAULT, 0x90);
MIL.MgraText(MIL.M_DEFAULT, MilGreenBandSubImage, SizeX / 16, SizeY / 8, " TOUCAN ");
MIL.MgraColor(MIL.M_DEFAULT, 0x00);
MIL.MgraText(MIL.M_DEFAULT, MilBlueBandSubImage, SizeX / 16, SizeY / 8, " TOUCAN ");
Console.Write("\nCOLOR OPERATIONS:\n");
Console.Write("-----------------\n\n");
Console.Write("A color source image was loaded on the left and color text\n");
Console.Write("annotations were written in it.\n");
Console.Write("Press <Enter> to continue.\n\n");
Console.ReadKey();
MIL.MimConvert(MilLeftSubImage, MilRightSubImage, MIL.M_RGB_TO_HSL);
MIL.MbufChildColor(MilRightSubImage, MIL.M_LUMINANCE, ref 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.\n");
Console.Write("Press <Enter> to end.\n");
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);
}
}
}