vb6内嵌汇编实现图像快速对比,1024x768的两个图像对比最快仅用时4ms (XP/2.4G/512M)。
(声明:魏滔序原创,转贴请注明出处。)
';:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ' vb6内嵌汇编实现图像快速对比 ' Programmed by 魏滔序 ' WebSite: http://www.chenoe.com ' Blog: http://blog.youkuaiyun.com/Modest ';:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Option Explicit Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (lpPrevWndFunc As Any, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private AsmCode(46) As Byte Private Sub InitAsmCode() If AsmCode(0) <> &H55 Then AsmCode(0) = &H55 AsmCode(1) = &H8B AsmCode(2) = &HEC AsmCode(3) = &H8B AsmCode(4) = &H55 AsmCode(5) = &H10 AsmCode(6) = &H85 AsmCode(7) = &HD2 AsmCode(8) = &H76 AsmCode(9) = &H21 AsmCode(10) = &H8B AsmCode(11) = &H45 AsmCode(12) = &HC AsmCode(13) = &H8B AsmCode(14) = &H4D AsmCode(15) = &H8 AsmCode(16) = &H56 AsmCode(17) = &H57 AsmCode(18) = &H8B AsmCode(19) = &H31 AsmCode(20) = &H8B AsmCode(21) = &H38 AsmCode(22) = &H3B AsmCode(23) = &HF7 AsmCode(24) = &H75 AsmCode(25) = &H6 AsmCode(26) = &HC7 AsmCode(27) = &H0 AsmCode(28) = &H0 AsmCode(29) = &H0 AsmCode(30) = &H0 AsmCode(31) = &H0 AsmCode(32) = &H83 AsmCode(33) = &HC1 AsmCode(34) = &H4 AsmCode(35) = &H83 AsmCode(36) = &HC0 AsmCode(37) = &H4 AsmCode(38) = &H4A AsmCode(39) = &H75 AsmCode(40) = &HE9 AsmCode(41) = &H5F AsmCode(42) = &H5E AsmCode(43) = &H5D AsmCode(44) = &HC2 AsmCode(45) = &H10 AsmCode(46) = &H0 End If End Sub Public Function ImgCompare(SrcData As cDIB, DestData As cDIB) As Boolean Call InitAsmCode CallWindowProc AsmCode(0), SrcData.ImagePtr, DestData.ImagePtr, SrcData.mWidth * SrcData.mHeight, 0 ImgCompare = True End Function
本文详细介绍了使用VB6内嵌汇编语言实现高效图像对比的方法,展示了1024x768分辨率下图像对比仅需4ms的惊人速度,适用于XP/2.4G/512M硬件环境。
442

被折叠的 条评论
为什么被折叠?



