Function rename + palette alloc test.

This commit is contained in:
Michael Jumper 2012-04-01 21:54:03 -07:00
parent 859395022f
commit e22323c4d9
3 changed files with 14 additions and 6 deletions

View File

@ -55,8 +55,8 @@ typedef struct guac_palette {
} guac_palette; } guac_palette;
guac_palette* __guac_create_palette(cairo_surface_t* surface); guac_palette* guac_palette_alloc(cairo_surface_t* surface);
void __guac_free_palette(guac_palette* palette); void guac_palette_free(guac_palette* palette);
#endif #endif

View File

@ -47,7 +47,7 @@
#include "palette.h" #include "palette.h"
guac_palette* __guac_create_palette(cairo_surface_t* surface) { guac_palette* guac_palette_alloc(cairo_surface_t* surface) {
int x, y; int x, y;
@ -81,7 +81,7 @@ guac_palette* __guac_create_palette(cairo_surface_t* surface) {
/* Stop if already at capacity */ /* Stop if already at capacity */
if (palette->colors == 256) { if (palette->colors == 256) {
__guac_free_palette(palette); guac_palette_free(palette);
return NULL; return NULL;
} }
@ -111,7 +111,7 @@ guac_palette* __guac_create_palette(cairo_surface_t* surface) {
} }
void __guac_free_palette(guac_palette* palette) { void guac_palette_free(guac_palette* palette) {
free(palette); free(palette);
} }

View File

@ -227,7 +227,15 @@ int __guac_socket_write_length_png(guac_socket* socket, cairo_surface_t* surface
cairo_surface_flush(surface); cairo_surface_flush(surface);
if (format == CAIRO_FORMAT_RGB24) { if (format == CAIRO_FORMAT_RGB24) {
__guac_create_palette(surface);
guac_palette* palette = guac_palette_alloc(surface);
if (palette != NULL) {
fprintf(stderr,
"Created palette with %i entries.\n",
palette->colors);
guac_palette_free(palette);
}
png_rows = __guac_create_png_rgb(surface, 0); png_rows = __guac_create_png_rgb(surface, 0);
png_format = PNG_COLOR_TYPE_RGB; png_format = PNG_COLOR_TYPE_RGB;
} }