Render window close button

This commit is contained in:
Johan Malm 2020-06-29 19:27:59 +01:00
parent 40e862f3ac
commit baca410560
17 changed files with 177 additions and 50 deletions

View file

@ -1,7 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cairo.h>
#include "xbm.h"
#include "theme/xbm/parse.h"
int main(int argc, char **argv)
{
@ -17,18 +19,29 @@ int main(int argc, char **argv)
exit(EXIT_FAILURE);
tokens = xbm_tokenize(buffer);
free(buffer);
cairo_surface_t *surface = xbm_create_bitmap(tokens);
struct pixmap pixmap = xbm_create_pixmap(tokens);
free(tokens);
if (!surface)
cairo_surface_t *g_surface;
g_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
pixmap.width, pixmap.height);
if (!g_surface) {
fprintf(stderr, "no surface\n");
exit(EXIT_FAILURE);
}
unsigned char *surface_data = cairo_image_surface_get_data(g_surface);
cairo_surface_flush(g_surface);
memcpy(surface_data, pixmap.data, pixmap.width * pixmap.height * 4);
if (pixmap.data)
free(pixmap.data);
cairo_surface_mark_dirty(g_surface);
char png_name[1024];
snprintf(png_name, sizeof(png_name), "%s.png", argv[1]);
if (cairo_surface_write_to_png(surface, png_name)) {
if (cairo_surface_write_to_png(g_surface, png_name)) {
fprintf(stderr, "cannot save png\n");
exit(EXIT_FAILURE);
}
cairo_surface_destroy(surface);
cairo_surface_destroy(g_surface);
exit(EXIT_SUCCESS);
}