To quickly filter the specified picture or area, the common method takes out the picture data, and the extraction of the pixel and the specified filter color is very troublesome. It has also been seen that the useful Point or getPixel takes point operations online, and it is conceivable that it is impossible to know.
In fact, this operation can be accomplished using Bitblt, which can be completed at high speed. The following function can be 10 times faster than the array operation method, which will be thousands of times more than Point or getpixel estimation.
Private Type RECT Left As Long Top As Long Right As Long Bottom As LongEnd TypePrivate Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As LongPrivate Declare Function CreateSolidBrush Lib "gdi32.dll" (ByVal crColor As Long) As LongPrivate Declare Function FillRect Lib "user32.dll" (ByVal hdc As Long, lpRect As RECT, ByVal hBrush As Long) As LongPrivate Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal y As Long, ByVal nWidth As LONG, BYVAL NHEIGHT As Long, Byval Hsrcdc As Long, Byval Xsrc As Long, Byval Ysrc As Long, Byval DWROP AS Long AS Long
Public Sub FilterRGB (DHDC As Long, X As Long, Y As Long, W As Long, H AS Long, Optional TC as Long = & HFFF00) DIM TMPHDC AS MEMHDC, RC As Rect, Hbrush As Long TmpHDC = NewmyHDC (DHDC, W H) 'Creating a memory bit map rc.right = w rc.bottom = h hbrush = createsolidbrush (tc) FillRect TMPHDC.HDC, RC, HBrush' Fill images with filter color, generate a solid color picture deleteObject Hbrush Bitblt DHDC, X, Y, W, H, TMPHDC.HDC, 0, 0, VBSRCAND 'plot the target, and operate with the target, reach the filter effect TMPHDC = DelmyHDC (TMPHDC) end SUB
The public function in this article NewmyHDC, DelmyHDC and related structures and API declarations can be found in this article http://blog.9cbs.net/Homezj/archive/2005/04/14/348001.aspx