need a hint - small pixel animations

hello everyone,
as a beginner i'm looking for a hint - i need to create few basic animations (12x12 pixels, square) like rotating rainbow or else.
is there any library, or class i should start? i prefer to generate animation "on the fly" rather that load .gif image.
I need alsoe to read pixel by pixel from generated image ...