|
|
@@ -44,14 +44,17 @@ char* cucul_get_html(cucul_t *qq, int *size) |
|
|
|
0x000, 0x008, 0x080, 0x088, 0x800, 0x808, 0x880, 0x888, |
|
|
|
0x444, 0x44f, 0x4f4, 0x4ff, 0xf44, 0xf4f, 0xff4, 0xfff, |
|
|
|
}; |
|
|
|
char *buffer, *cur; |
|
|
|
char *cur; |
|
|
|
unsigned int x, y, len; |
|
|
|
|
|
|
|
/* 13000 -> css palette |
|
|
|
* 40 -> max size used for a pixel (plus 10, never know)*/ |
|
|
|
/* FIXME: Check this value */ |
|
|
|
buffer = malloc((13000 + ((qq->width*qq->height) * 40)) * sizeof(char)); |
|
|
|
cur = buffer; |
|
|
|
if(qq->html_buffer) |
|
|
|
free(qq->html_buffer); |
|
|
|
|
|
|
|
qq->html_buffer = malloc((13000 + ((qq->width*qq->height) * 40)) * sizeof(char)); |
|
|
|
cur = qq->html_buffer; |
|
|
|
|
|
|
|
/* HTML header */ |
|
|
|
cur += sprintf(cur, "<html>\n<head>\n<title>Generated by libcaca %s</title>\n", VERSION); |
|
|
@@ -96,10 +99,10 @@ char* cucul_get_html(cucul_t *qq, int *size) |
|
|
|
cur += sprintf(cur, "</div></body></html>\n"); |
|
|
|
|
|
|
|
/* Crop to really used size */ |
|
|
|
*size = (strlen(buffer) + 1) * sizeof(char); |
|
|
|
buffer = realloc(buffer, *size); |
|
|
|
*size = (strlen(qq->html_buffer) + 1) * sizeof(char); |
|
|
|
qq->html_buffer = realloc(qq->html_buffer, *size); |
|
|
|
|
|
|
|
return buffer; |
|
|
|
return qq->html_buffer; |
|
|
|
} |
|
|
|
|
|
|
|
/** \brief Generate HTML3 representation of current image. |
|
|
@@ -119,13 +122,17 @@ char* cucul_get_html3(cucul_t *qq, int *size) |
|
|
|
0x444444, 0x4444ff, 0x44ff44, 0x44ffff, |
|
|
|
0xff4444, 0xff44ff, 0xffff44, 0xffffff, |
|
|
|
}; |
|
|
|
char *buffer, *cur; |
|
|
|
char *cur; |
|
|
|
unsigned int x, y, len; |
|
|
|
|
|
|
|
/* 13000 -> css palette |
|
|
|
* 40 -> max size used for a pixel (plus 10, never know) */ |
|
|
|
buffer = malloc((13000 + ((qq->width*qq->height)*40))*sizeof(char)); |
|
|
|
cur = buffer; |
|
|
|
|
|
|
|
if(qq->html3_buffer) |
|
|
|
free(qq->html3_buffer); |
|
|
|
|
|
|
|
qq->html3_buffer = malloc((13000 + ((qq->width*qq->height)*40))*sizeof(char)); |
|
|
|
cur = qq->html3_buffer; |
|
|
|
|
|
|
|
/* Table */ |
|
|
|
cur += sprintf(cur, "<table cols='%d' cellpadding='0' cellspacing='0'>\n", |
|
|
@@ -173,10 +180,10 @@ char* cucul_get_html3(cucul_t *qq, int *size) |
|
|
|
cur += sprintf(cur, "</table>\n"); |
|
|
|
|
|
|
|
/* Crop to really used size */ |
|
|
|
*size = (strlen(buffer) + 1) * sizeof(char); |
|
|
|
buffer = realloc(buffer, *size); |
|
|
|
*size = (strlen(qq->html3_buffer) + 1) * sizeof(char); |
|
|
|
qq->html3_buffer = realloc(qq->html3_buffer, *size); |
|
|
|
|
|
|
|
return buffer; |
|
|
|
return qq->html3_buffer; |
|
|
|
} |
|
|
|
|
|
|
|
/** \brief Generate IRC representation of current image. |
|
|
@@ -192,7 +199,7 @@ char* cucul_get_irc(cucul_t *qq, int *size) |
|
|
|
14, 12, 9, 11, 4, 13, 8, 0, /* Light */ |
|
|
|
}; |
|
|
|
|
|
|
|
char *buffer, *cur; |
|
|
|
char *cur; |
|
|
|
unsigned int x, y; |
|
|
|
|
|
|
|
/* 11 bytes assumed for max length per pixel. Worst case scenario: |
|
|
@@ -202,8 +209,12 @@ char* cucul_get_irc(cucul_t *qq, int *size) |
|
|
|
* \r\n 2 bytes |
|
|
|
* In real life, the average bytes per pixel value will be around 5. |
|
|
|
*/ |
|
|
|
buffer = malloc((2 + (qq->width * qq->height * 11)) * sizeof(char)); |
|
|
|
cur = buffer; |
|
|
|
|
|
|
|
if(qq->irc_buffer) |
|
|
|
free(qq->irc_buffer); |
|
|
|
|
|
|
|
qq->irc_buffer = malloc((2 + (qq->width * qq->height * 11)) * sizeof(char)); |
|
|
|
cur = qq->irc_buffer; |
|
|
|
|
|
|
|
*cur++ = '\x0f'; |
|
|
|
|
|
|
@@ -255,10 +266,10 @@ char* cucul_get_irc(cucul_t *qq, int *size) |
|
|
|
*cur++ = '\x0f'; |
|
|
|
|
|
|
|
/* Crop to really used size */ |
|
|
|
*size = (strlen(buffer) + 1) * sizeof(char); |
|
|
|
buffer = realloc(buffer, *size); |
|
|
|
*size = (strlen(qq->irc_buffer) + 1) * sizeof(char); |
|
|
|
qq->irc_buffer = realloc(qq->irc_buffer, *size); |
|
|
|
|
|
|
|
return buffer; |
|
|
|
return qq->irc_buffer; |
|
|
|
} |
|
|
|
|
|
|
|
/** \brief Generate ANSI representation of current image. |
|
|
|