1 /* $Id: fb_imlib2.c,v 1.10 2004/08/04 17:32:28 ukai Exp $ */
2 /**************************************************************************
3 fb_imlib2.c 0.3 Copyright (C) 2002, hito
4 **************************************************************************/
11 static void draw(FB_IMAGE * img, Imlib_Image image);
12 static Imlib_Image resize_image(Imlib_Image image, int width, int height);
21 get_image_size(char *filename, int *w, int *h)
28 image = imlib_load_image(filename);
32 imlib_context_set_image(image);
33 *w = imlib_image_get_width();
34 *h = imlib_image_get_height();
41 fb_image_load(char *filename, int w, int h, int n)
49 image = imlib_load_image(filename);
53 image = resize_image(image, w, h);
57 imlib_context_set_image(image);
59 w = imlib_image_get_width();
60 h = imlib_image_get_height();
62 frame = fb_frame_new(w, h, 1);
69 draw(frame[0], image);
77 draw(FB_IMAGE * img, Imlib_Image image)
79 int i, j, r, g, b, a = 0, offset;
85 imlib_context_set_image(image);
86 data = imlib_image_get_data_for_reading_only();
88 for (j = 0; j < img->height; j++) {
89 offset = img->width * j;
90 for (i = 0; i < img->width; i++) {
91 a = (data[offset + i] >> 24) & 0x000000ff;
92 r = (data[offset + i] >> 16) & 0x000000ff;
93 g = (data[offset + i] >> 8) & 0x000000ff;
94 b = (data[offset + i]) & 0x000000ff;
97 fb_image_pset(img, i, j, bg_r, bg_g, bg_b);
100 fb_image_pset(img, i, j, r, g, b);
108 resize_image(Imlib_Image image, int width, int height)
110 Imlib_Image resized_image;
116 imlib_context_set_image(image);
117 w = imlib_image_get_width();
118 h = imlib_image_get_height();
120 if (width < 1 || height < 1)
123 if (w == width && h == height)
127 imlib_create_cropped_scaled_image(0, 0, w, h, width, height);
131 return resized_image;