Store sequential array of colors in palette.
This commit is contained in:
parent
314e8c9222
commit
1489ae902d
@ -51,7 +51,8 @@ typedef struct guac_palette_entry {
|
||||
typedef struct guac_palette {
|
||||
|
||||
guac_palette_entry entries[0xFFF];
|
||||
int colors;
|
||||
int colors[256];
|
||||
int size;
|
||||
|
||||
} guac_palette;
|
||||
|
||||
|
@ -80,13 +80,14 @@ guac_palette* guac_palette_alloc(cairo_surface_t* surface) {
|
||||
if (entry->index == 0) {
|
||||
|
||||
/* Stop if already at capacity */
|
||||
if (palette->colors == 256) {
|
||||
if (palette->size == 256) {
|
||||
guac_palette_free(palette);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Add color to map, done */
|
||||
entry->index = ++palette->colors;
|
||||
palette->colors[palette->size] = color;
|
||||
entry->index = ++palette->size;
|
||||
entry->color = color;
|
||||
break;
|
||||
|
||||
|
@ -230,9 +230,11 @@ int __guac_socket_write_length_png(guac_socket* socket, cairo_surface_t* surface
|
||||
|
||||
guac_palette* palette = guac_palette_alloc(surface);
|
||||
if (palette != NULL) {
|
||||
|
||||
fprintf(stderr,
|
||||
"Created palette with %i entries.\n",
|
||||
palette->colors);
|
||||
palette->size);
|
||||
|
||||
guac_palette_free(palette);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user