Well there are faster, but more complicated, tehnicques:
First, declare functions and types
Code:Private Type Bitmap bmType As Long bmWidth As Long bmHeight As Long bmWidthBytes As Long bmPlanes As Integer bmBitsPixel As Integer bmBits As Long End Type dim rightpixels(0 to 512,0 to 512) as boolean 'instead 512 w-1 and h-1 :-) Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, ByRef lpObject As Any) As Long Private Declare Function GetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, ByRef lpBits As Any) As Long Private Declare Function SetBitmapBits Lib "gdi32" (ByVal hBitmap As Long, ByVal dwCount As Long, ByRef lpBits As Any) As Long
Now, you can get pixels more faster than with getpixel by this proc:
I hope you understand thisCode:sub getrightpixels(color) dim bm As bitmap getobject picture1.image, len(bm), bm dim pixeldata() as Byte 'byte beacuse you will get each of R,G, and B components redim pixeldata(0 To (bm.bmBitsPixel \ 8) - 1, 0 To bm.bmWidth - 1, 0 To bm.bmHeight - 1) 'first dimension of array is 0=red, 1=green, 2=blue , second is x, and third is y getbitmapbits picture1.image, bm.bmWidthBytes * bm.bmHeight, pixeldata(0, 0, 0) 'getting pixels for i=0 to bm.bmWidth-1 for j=0 to bm.bmHeight-1 if RGB(pixeldata(0,i,j),pixeldata(1,i,j),pixeldata(2,i,j))=color then rightpixel(i,j)=true next j next i end sub![]()
About regions i don't know very much, but i will find out![]()




Reply With Quote