Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var pPix = cast(ARGB ptr,pImg+1), iWidM = pImg->Width-1
- dim as integer iNextR(iWidM), iNextG(iWidM), iNextB(iWidM)
- for Y as integer = 0 to pImg->Height-1
- var iErrR = 0 , iErrG = 0 , iErrB = 0
- for X as integer = 0 to iWidM
- var iMinDiff=&hFFFFFF, iNum = -1
- var iR = cint(pPix->R)+iErrR+iNextR(X): if cuint(iR) > 255 then iR = iR>255 and 255
- var iG = cint(pPix->G)+iErrG+iNextG(X): if cuint(iG) > 255 then iG = iG>255 and 255
- var iB = cint(pPix->B)+iErrB+iNextB(X): if cuint(iB) > 255 then iB = iB>255 and 255
- with tColors( (iB shr 3) or ((iG shr 3) shl 5) or ((iR shr 3) shl 10) )
- iErrR = .DiffR : iErrG = .DiffG : iErrB = .DiffB
- iNextR(X) = iErrR shr 1: iErrR -= iNextR(X)
- iNextG(X) = iErrG shr 1: iErrG -= iNextG(X)
- iNextB(X) = iErrB shr 1: iErrB -= iNextR(X)
- *pPix = tFullPal( .iConColor shr 16): pPix += 1
- end with
- next X
- next Y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement