glcomptextpng.c 1.1 KB

123456789101112131415161718192021222324252627
  1. /*************************************************************************
  2. * Copyright (c) 2011 AT&T Intellectual Property
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: Details at https://graphviz.org
  9. *************************************************************************/
  10. #include <glcomp/glcompfont.h>
  11. #include <glcomp/glcomptextpng.h>
  12. #include <gtk/gtk.h>
  13. #include <png.h>
  14. #include <stddef.h>
  15. unsigned char *glCompLoadPng(cairo_surface_t **surface, const char *filename,
  16. int *imageWidth, int *imageHeight) {
  17. *surface = cairo_image_surface_create_from_png(filename);
  18. if (*surface == NULL ||
  19. cairo_surface_status(*surface) != CAIRO_STATUS_SUCCESS) {
  20. return NULL;
  21. }
  22. *imageWidth = cairo_image_surface_get_width(*surface);
  23. *imageHeight = cairo_image_surface_get_height(*surface);
  24. return cairo_image_surface_get_data(*surface);
  25. }