"
x AND
mask" keeps all bits of x where mask is 1 and clears the others.
In case of '255', or 'FF' in hex, or '11111111' in binary, the lower 8 bits are kept, all other become zero.
It's the same as a "modulo 256" but is magnitudes faster because the modulo-operation requires a division.
In image-processing you'll usually have the r,g,b,a-values of a pixel stored in a single integer:
AAAAAAAA:RRRRRRRR:GGGGGGGG:BBBBBBBBTo extract a single color-component you can remove the others by anding with $000000FF, $0000FF00, $00FF0000 or $FF000000.
(but keep in mind that your value is still "shifted up").
say I have a colour palette that is 640. is it as simple as: col=pal( image(x,y)) and 639?
No, it just works with powers of two (you can only keep "whole" bits).
So just make your palette 512 or 1024 entries long and it works again.