If anyone wants to use this solution, here it is. The nested if statements are intentional. DB Pro processes all ANDs, even if the first is false.
function UiRemoveBlack(img)
mb = 1
while memblock exist(mb) = 1
inc mb
endwhile
make memblock from image mb, img
depth = memblock dword(mb,8)
for n = 12 to (get memblock size(mb) - 1) step (depth / 8)
clrR = memblock byte(mb, n)
clrG = memblock byte(mb, n + 1)
clrB = memblock byte(mb, n + 2)
if clrR = 0
if clrG = 0
if clrB = 0
write memblock byte mb, n, clrR + 1
write memblock byte mb, n + 1, clrG + 1
write memblock byte mb, n + 2, clrB + 1
endif
endif
endif
next n
make image from memblock img,mb
delete memblock mb
endfunction