View Single Post
Old 11-22-2012, 04:53 PM   #246
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Týr
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,586
Karma: 6299991
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Hi I was reading http://bisqwit.iki.fi/story/howto/dither/jy/ and then http://www.efg2.com/Lab/Library/Imag...sing/DHALF.TXT and

was wondering if this (almost complete) snippet would be of use to try a cheap 8bpp -dithered target?

1) This code (in the C programming language) dithers a 256-level
monochrome image onto a black-and-white display with the Bayer ordered
dither.
Spoiler:

PHP Code:
/* Bayer-method ordered dither.  The array line[] contains the intensity
** values for the line being processed.  As you can see, the ordered
** dither is much simpler than the error dispersion dither.  It is also
** many times faster, but it is not as accurate and produces cross-hatch
** patterns on the output.
*/

unsigned char line[WIDTH];

int pattern[8][8] = {
    { 
032,  840,  2341042},   /* 8x8 Bayer ordered dithering  */
    
{4816562450185826},   /* pattern.  Each input pixel   */
    
{1244,  4361446,  638},   /* is scaled to the 0..63 range */
    
{6028522062305422},   /* before looking in this table */
    
3351143,  133,  941},   /* to determine the action.     */
    
{5119592749175725},
    {
1547,  7391345,  537},
    {
6331552361295321} };

int getline();               /* Function to read line[] from image      */
                             /* file; must return EOF when done.        */

putdot(int xint y);        /* Plot white dot at given x, y.           */

dither()
{
    
int xy;

    while (
getline() != EOF) {
        for (
x=0x<WIDTH; ++x) {
            
line[x] >> 2;           /* Scale value to 0..63 range   */

            
if (pattern[7][7]) putdot(xy);
        }
        ++
y;
    }



and
Spoiler:

Code:
void rfb16ToFramebuffer8(int x, int y, int w, int h) {
	int cx, cy;

	/* we read single pixels */
	uint16_t *src = (uint16_t*)(client->frameBuffer) + client->width*y + x;
	/* and we write single pixels */
	uint8_t *dest = (uint8_t*)fbdata + finfo.line_length*y + x;

	for(cy = 0; cy < h; cy++) {
		for(cx = 0; cx < w; cx++) {
			uint32_t c;
			uint16_t v;
			uint8_t dval;

			v = *(src + cx);
#ifdef PERFECT_COLOR_CONVERSION
			c = ((v & 0x001F) * 77 // red
				+ ((v & 0x03E0) >> 5) * 151 // green
				+ ((v & 0x7C00) >> 10) * 28 // blue
			    ) >> (8 /* from multipl. above */ + 1 /* 5 -> 4 */ );
#else
			c = ((v & 0x001F) // red
				+ (((v & 0x03E0) >> 5) << 1) // green counts 2x
				+ ((v & 0x7C00) >> 10) // blue
			    ) >> (2 /* from shifts above */ + 1 /* 5 -> 4 */ );
#endif
			*(dest+cx) = (((uint8_t)c << 4) + ((uint8_t)c & 0xF)) ^ 255; /* repeat value in lower nibble */
		}
		dest += finfo.line_length;
		src += client->width;
	}
}

I guess?

Would dearly love to see a (cheap) dithered target for the touch as the one on the 3 does such a great job. Did think about getting it done myself but once again the maths has stumbled me.

Anyways, I know you are busy but I documented the thought.

Also:


Is the GIT the latest code?

I don't understand how I can get an error message that I cant find in the code???
The one about "4bpp only being supported for now sorry" Am I being stupid?


also this was worth a read http://www.virtualdub.org/blog/pivot/entry.php?id=151

Last edited by twobob; 11-23-2012 at 02:54 PM.
twobob is offline   Reply With Quote