Hi, i'm working on a tool and got some problems with swizzling...
i found small swizzle function, but not unswizzle. could anyone help me with unswizzle?
void swizzle(unsigned char* out, unsigned char* in, unsigned int width, unsigned int height)
{
unsigned int i,j;
unsigned int rowblocks = (width / 16);
for (j = 0; j < height; ++j)
{
for (i = 0; i < width; ++i)
{
unsigned int blockx = i / 16;
unsigned int blocky = j / 8;
unsigned int x = (i - blockx*16);
unsigned int y = (j - blocky*8);
unsigned int block_index = blockx + ((blocky) * rowblocks);
unsigned int block_address = block_index * 16 * 8;
out[block_address + x + y * 16] = in[i+j*width];
}
}
}
Hmm, I would imagine you could come up with an algorithm that isn't "symmetrical" like that.
I would just take the algorithm and then do the opposite of what it's doing, in reverse order.
this algo is for 8 bit, but you always can add depth for higher bpp.
i actually solved it for now using another guy's dll, but would be great to implement it w/o external files.