1
General chat / Mindcandy 3
« on: November 24, 2011 »
I'm just watching the Mindcandy 3 blu-ray on a 40" screen and it's really amazing.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
[url=linkToYourThread] [img]http://linkToYourSignatureImage[/img] [/url]
Cheers.
You may change your colour pallette throughout the demo as long as you don't display more than 4 at once...I figured it would be easy to alternate two (or more) different palettes from frame to frame, thus making two different colours at the same pixel-position appear as a new, different colour.
void dither(unsigned int *dst, unsigned char *src, unsigned int *pal, int xres, int yres)
{
// standard bayer dithering matrix:
char bayer[16]=
{ 1, 9, 3,11,
13, 5,15, 7,
4,12, 2,10,
16, 8,14, 6 };
for (int y=0;y<yres;y++)
{
// select the corresponding line of the dither-matrix
char *matrix= bayer + ((y & 3)<<2);
for (int x=0;x<xres;x++)
{
unsigned char value= *src++ >> 2; // no need for the lowest two bits (0..255 -> 0..63)
unsigned char col= value >> 4; // upper two bits define colour (0..3)
unsigned char sub= value & 0xf; // lower four bits are "sub-precision" for matrix-compare
if (sub >= matrix[x & 3]) // use either "col" or "col+1"
col++;
// to avoid an overflow-check here you can simply set pal[4]=pal[3] initially.
*dst++= pal[col]; // store actual colour
}
}
}
x= (i+1)>>1&1;
y= i >> 1 & 1;
z= i >> 2 & 1;
(Swapping 2/3 and 6/7 simplifies x to "i & 1", but keeping them clockwise gives ready-to-use quad-order).char edges[12]= {0x01,0x12,0x23,0x30,0x45,0x56,0x67,0x74, 0x04,0x15,0x26,0x37};
v1= edges[e] >> 4 & 0xf;
v2= edges[e] & 0xf;
v1= e & 7;
input: 0123 4567 89AB
output: 1230 5674 4567