|
Bitwise operations between two bitmaps? |
nshade
Member #4,372
February 2004
|
Given two bitmaps how would you create a bitwise operation between the two without going pixel-by-pixel? It appears you use al_set_blender() but I don't know how to derive the functions I need Form my old legacy psudocode on a per-pixel basis I used the following operators: B_OR : t = t | b; //or I'm not sure how the ALLEGRO_ADD, ALLEGRO_ZERO, ALLEGRO_ONE stuff turns into bitwise math, unless I'm not seeing the mathematics properly or it's a type of math I don't understand. From the documentation, it appears that I can make a B_COPY by Thinking this through, this means that of the bit on the source will be written over the destination which is treated as a "mask" of zero? Kinda? How does this work? |
Elias
Member #358
May 2000
|
You can't do bitwise with blending. So for B_OR, B_AND, B_XOR, B_NOT I would say use a shader with two input textures. This shows a shader with two textures, but in your case simply use ~/&/^ on the rgb values. Here is the full example. B_COPY should be the normal behavior (for r/g/b at least, not necessarily for alpha). B_CUT won't work directly but Allegro supports a depth buffer which could be used for a very similar effect, like for example here. Also, if this is something you can pre-process once and is not needed in real time, just use al_lock_bitmap and modify the pixels directly. -- |
|