swk

static widget kit
git clone git://git.suckless.org/swk
Log | Files | Refs | README | LICENSE

image.c (747B)


      1 /* See LICENSE file for copyright and license details. */
      2 #include "swk.h"
      3 #include <stdlib.h>
      4 #include <string.h>
      5 #include <Imlib2.h>
      6 
      7 #define MAXIMGS 32
      8 //static SwkImage images[MAXIMGS];
      9 
     10 SwkImage *
     11 img_open(const char *str) {
     12 	SwkImage *img = (SwkImage*)malloc(sizeof(SwkImage));
     13 	if(str) {
     14 		strncpy(img->name, str, sizeof(img->name)-1);
     15 		img->priv = imlib_load_image (str);
     16 		imlib_context_set_image ((Imlib_Image*)img->priv);
     17 		img->w = imlib_image_get_width();
     18 		img->h = imlib_image_get_height();
     19 		img->data = imlib_image_get_data();
     20 		img->bpp = 24;
     21 	} else memset(img, 0, sizeof(SwkImage));
     22 	return img;
     23 }
     24 
     25 void
     26 img_free(SwkImage *img) {
     27 	img->ref--; // XXX
     28 	imlib_context_set_image ((Imlib_Image*)img->priv);
     29 	imlib_free_image ();
     30 }