新闻中心
    新闻中心
联系我们
电话(销售热线):0755-28441200 0755-89368951 
传真:0755-28441200
 
新闻中心
mil10(MATROX IMAGING LIBRARY 10)图像框中显示中文
发布日期:【2019-12-5】 来源:【】 作者:【车生】 浏览次数【409】次 【打印】【返回

2019.12.05
mil10(MATROX IMAGING LIBRARY 10)图像框中显示中文
默认情况下,mil10(MATROX IMAGING LIBRARY 10)图像框中显示中文时,它会显示乱码,这是由于用户未指定字体所致,以前开发时需要用到此功能,并且以为它不能显示中文。原来是可以的。
系统配置:MIL10 64位(以前的MIL9版本并未测试)WIN10 64,VISUAL STUDIO 2019, MATROX SOLIOS(SOL2MECLF) CAMERALINK采集卡 SONY XCL-C500相机。
代码如下(vb.net):

'MIL 图像框显示中文
Imports Matrox.MatroxImagingLibrary '要先引用它Matrox.MatroxImagingLibrary.dll  它位于C:\Program Files\Matrox Imaging\MIL\MIL.NET

Public Class Form1
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 MilDigitizer As MIL_ID = MIL.M_NULL
Dim MilImage As MIL_ID = MIL.M_NULL

Dim BufSizeX As Integer ' MIL_INT '= DEFAULT_IMAGE_SIZE_X
Dim BufSizeY As Integer 'MIL_INT '= DEFAULT_IMAGE_SIZE_Y
Dim BufSizeBand As MIL_INT '= DEFAULT_IMAGE_SIZE_BAND
Dim MilGraphicContextId As MIL_ID = MIL.M_NULL '  Graphic context identifier


Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MIL.MappAlloc(MIL.M_DEFAULT, MilApplication) '应用分配
MIL.MappControl(MIL.M_ERROR, MIL.M_THROW_EXCEPTION) '击中错误,没此句时MIL的错误不会击中,就是说没它时MIL函数有错时只会弹框而不会击中错误句子。
MIL.MsysAlloc(MIL.M_DEFAULT, "M_DEFAULT", MIL.M_DEFAULT, MIL.M_DEFAULT, MilSystem) '系统分配 双引号内区分大小写
MIL.MdispAlloc(MilSystem, MIL.M_DEFAULT, "M_DEFAULT", MIL.M_WINDOWED, MilDisplay) '显示分配

'分配图形上下文
MIL.MgraAlloc(MilSystem, MilGraphicContextId)

If MIL.MsysInquire(MilSystem, MIL.M_DIGITIZER_NUM, MIL.M_NULL) > 0 Then
MIL.MdigAlloc(MilSystem, MIL.M_DEFAULT, "M_DEFAULT", MIL.M_DEFAULT, MilDigitizer) 'free
MIL.MdigInquire(MilDigitizer, MIL.M_SIZE_X, BufSizeX)
MIL.MdigInquire(MilDigitizer, MIL.M_SIZE_Y, BufSizeY)
MIL.MdigInquire(MilDigitizer, MIL.M_SIZE_BAND, BufSizeBand)
End If

MIL.MbufAlloc2d(MilSystem, BufSizeX, BufSizeY, 8 + MIL.M_UNSIGNED, MIL.M_IMAGE + MIL.M_DISP + MIL.M_GRAB + MIL.M_PROC, MilImage) '分配MILIMAGE图像缓冲区
MIL.MdispSelectWindow(MilDisplay, MilImage, Me.Handle) '关联显示与缓冲区

MIL.MdigGrab(MilDigitizer, MilImage) '单帧采

If MIL.M_MIL_USE_TTF_UNICODE = 1 Then
MIL.MgraFont(MilGraphicContextId, MIL.MIL_FONT_NAME(MIL.M_FONT_DEFAULT_TTF)) '关键函数,没有它时显示中文为乱码 功能:将文本字体与图形上下文关联。
MIL.MgraControl(MilGraphicContextId, MIL.M_FONT_SIZE, 24)
MIL.MgraText(MilGraphicContextId, MilImage, 200, 200, "ABC123中文")
End If

End Sub

End Class

感谢汇龙影像科技有限公司提供测试平台。


地址:深圳市龙岗区南湾街道平吉大道9号华熠大厦A1010   电话:0755-28441200,传真:0755-28441200
Copyright © 2013 深圳市汇龙影像科技有限公司 All Right Reserved.粤ICP备14000400号