>> On Mon, Jul 11, 2005 at 05:11:48PM +0200, Mattias Ellert wrote: >>> Even better would be: >>> >>> *dst-- = ((*src << 4) & 0xf0) + ((*src) & 0x0f); >>> *dst-- = ((*src) & 0xf0) + ((*src-- >> 4) & 0x0f); >>> >>> Then 0 would map to 0 and 15 to 255, i.e. white is white and black is >>> black. >> >> You're right. I've changed taht in sp15c.c in CVS. > >Some quick Googling doesn't provide dispositive information on this >strategy's impact on compressibility. However I suspect that introducing >pseudo-random data in the low nybble will reduce compressibility beyond >simply squaring the symbol table. (Hence, my initial ponderings on >tweaking the constant)
(Admittedly, I haven't been completely following this thread, but...) To scale from a [0,15] value to a [0,255] value, you have to multiply by (255/15) = 17. And the above nybble-duplication algorithm effectively muliplies by 0x11, i.e.... 17. So, it's not pseudo-random data; it's the effect of correctly scaling the original value. There isn't really any other way to do it without introducing junk/noise bits into the image. (However, given that 17 is the most random number, this may have some effect on compressibility. :) -matt m.