cabi.c
int compress_rle(const uint8_t *src, int w, int h, char *prefix, char *suffix)
{
	int pos;
	int rlen;
	int len;
	
	printf("const uint8_t PROGMEM %s%s[] = {", prefix, suffix);
	fflush(stdout);
	
	memset(&cs, 0, sizeof(cs));
	cs.src = src;
	cs.bit = 1;
	cs.w = w;
	cs.h = h;
	
	// header
	putval(w-1, 8);
	putval(h-1, 8);
	putval(getcol(0), 1); // first colour
	
	pos = 0;
	
	// span data
	
	while (pos < w*h)
	{
		rlen = find_rlen(pos, w*h);
		pos += rlen;
		putsplen(rlen-1);
	}
	
	// pad with zeros and flush
	while (cs.bit != 0x1)
		putbit(0);
		
	printf("\n};\n");
	
	return cs.out_pos; // bytes
}
/*
	comp
	
	compress plen 1-bit pixels from src to dest
	
*/
comp
compress plen 1-bit pixels from src to dest
comp compress plen 1 - bit pixels from src to dest
int compress_rle(const uint8_t *src, int w, int h, char *prefix, char *suffix)
{
	int pos;
	int rlen;
	int len;
	printf("const uint8_t PROGMEM %s%s[] = {", prefix, suffix);
	fflush(stdout);
	memset(&cs, 0, sizeof(cs));
	cs.src = src;
	cs.bit = 1;
	cs.w = w;
	cs.h = h;
	putval(w-1, 8);
	putval(h-1, 8);
	putval(getcol(0), 1); 
	pos = 0;
	while (pos < w*h)
	{
		rlen = find_rlen(pos, w*h);
		pos += rlen;
		putsplen(rlen-1);
	}
	while (cs.bit != 0x1)
		putbit(0);
	printf("\n};\n");
	return cs.out_pos; 
}
int compress_rle ( const uint8_t * src , int w , int h , char * prefix , char * suffix ) { int pos ; int rlen ; int len ; printf ( " " , prefix , suffix ) ; fflush ( stdout ) ; memset ( & cs , 0 , sizeof ( cs ) ) ; cs . src = src ; cs . bit = 1 ; cs . w = w ; cs . h = h ; putval ( w - 1 , 8 ) ; putval ( h - 1 , 8 ) ; putval ( getcol ( 0 ) , 1 ) ; pos = 0 ; while ( pos < w * h ) { rlen = find_rlen ( pos , w * h ) ; pos += rlen ; putsplen ( rlen - 1 ) ; } while ( cs . bit != 0x1 ) putbit ( 0 ) ; printf ( " \n \n " ) ; return cs . out_pos ; }
comp
compress plen 1-bit pixels from src to dest
comp compress plen 1 - bit pixels from src to dest
// header // first colour // span data // pad with zeros and flush // bytes