From 72f72d64a422d6628c4796f5c0bf2e508f134214 Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Wed, 4 May 2011 16:05:14 +0900 Subject: Adding upstream version 0.5.1 --- w3mimg/fb/fb_imlib2.c | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 w3mimg/fb/fb_imlib2.c (limited to 'w3mimg/fb/fb_imlib2.c') diff --git a/w3mimg/fb/fb_imlib2.c b/w3mimg/fb/fb_imlib2.c new file mode 100644 index 0000000..972f06e --- /dev/null +++ b/w3mimg/fb/fb_imlib2.c @@ -0,0 +1,126 @@ +/* $Id: fb_imlib2.c,v 1.9 2003/03/24 15:45:59 ukai Exp $ */ +/************************************************************************** + fb_imlib2.c 0.3 Copyright (C) 2002, hito + **************************************************************************/ + +#include +#include +#include "fb.h" +#include "fb_img.h" + +static void draw(FB_IMAGE * img, Imlib_Image image); +static Imlib_Image resize_image(Imlib_Image image, int width, int height); + +int +get_image_size(char *filename, int *w, int *h) +{ + Imlib_Image image; + + if (filename == NULL) + return 1; + + image = imlib_load_image(filename); + if (image == NULL) + return 1; + + imlib_context_set_image(image); + *w = imlib_image_get_width(); + *h = imlib_image_get_height(); + imlib_free_image(); + + return 0; +} + +FB_IMAGE ** +fb_image_load(char *filename, int w, int h, int n) +{ + Imlib_Image image; + FB_IMAGE **frame; + + if (filename == NULL) + return NULL; + + image = imlib_load_image(filename); + if (image == NULL) + return NULL; + + image = resize_image(image, w, h); + if (image == NULL) + return NULL; + + imlib_context_set_image(image); + + w = imlib_image_get_width(); + h = imlib_image_get_height(); + + frame = fb_frame_new(w, h, 1); + + if (frame == NULL) { + imlib_free_image(); + return NULL; + } + + draw(frame[0], image); + + imlib_free_image(); + + return frame; +} + +static void +draw(FB_IMAGE * img, Imlib_Image image) +{ + int i, j, r, g, b, a = 0, offset; + DATA32 *data; + + if (img == NULL) + return; + + imlib_context_set_image(image); + data = imlib_image_get_data_for_reading_only(); + + for (j = 0; j < img->height; j++) { + offset = img->width * j; + for (i = 0; i < img->width; i++) { + a = (data[offset + i] >> 24) & 0x000000ff; + r = (data[offset + i] >> 16) & 0x000000ff; + g = (data[offset + i] >> 8) & 0x000000ff; + b = (data[offset + i]) & 0x000000ff; + + if (a == 0) { + fb_image_pset(img, i, j, bg_r, bg_g, bg_b); + } + else { + fb_image_pset(img, i, j, r, g, b); + } + } + } + return; +} + +static Imlib_Image +resize_image(Imlib_Image image, int width, int height) +{ + Imlib_Image resized_image; + int w, h; + + if (image == NULL) + return NULL; + + imlib_context_set_image(image); + w = imlib_image_get_width(); + h = imlib_image_get_height(); + + if (width < 1 || height < 1) + return image; + + if (w == width && h == height) + return image; + + resized_image = + imlib_create_cropped_scaled_image(0, 0, w, h, width, height); + + imlib_free_image(); + + return resized_image; +} -- cgit v1.2.3 From 6db339b3d7a391f196e7c4b725a4ed0bd00f31cf Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Wed, 4 May 2011 16:23:02 +0900 Subject: Adding upstream version 0.5.2 --- w3mimg/fb/fb_imlib2.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'w3mimg/fb/fb_imlib2.c') diff --git a/w3mimg/fb/fb_imlib2.c b/w3mimg/fb/fb_imlib2.c index 972f06e..ea36637 100644 --- a/w3mimg/fb/fb_imlib2.c +++ b/w3mimg/fb/fb_imlib2.c @@ -1,4 +1,4 @@ -/* $Id: fb_imlib2.c,v 1.9 2003/03/24 15:45:59 ukai Exp $ */ +/* $Id: fb_imlib2.c,v 1.10 2004/08/04 17:32:28 ukai Exp $ */ /************************************************************************** fb_imlib2.c 0.3 Copyright (C) 2002, hito **************************************************************************/ @@ -11,6 +11,12 @@ static void draw(FB_IMAGE * img, Imlib_Image image); static Imlib_Image resize_image(Imlib_Image image, int width, int height); +void +fb_image_init() +{ + return; +} + int get_image_size(char *filename, int *w, int *h) { -- cgit v1.2.3 From 1d0ba25a660483da1272a31dd077ed94441e3d9f Mon Sep 17 00:00:00 2001 From: Tatsuya Kinoshita Date: Sat, 2 Jan 2021 09:20:37 +0900 Subject: New upstream version 0.5.3+git20210102 --- w3mimg/fb/fb_imlib2.c | 1 - 1 file changed, 1 deletion(-) (limited to 'w3mimg/fb/fb_imlib2.c') diff --git a/w3mimg/fb/fb_imlib2.c b/w3mimg/fb/fb_imlib2.c index ea36637..1a5151c 100644 --- a/w3mimg/fb/fb_imlib2.c +++ b/w3mimg/fb/fb_imlib2.c @@ -3,7 +3,6 @@ fb_imlib2.c 0.3 Copyright (C) 2002, hito **************************************************************************/ -#include #include #include "fb.h" #include "fb_img.h" -- cgit v1.2.3