diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-07-18 15:10:52 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-07-18 15:10:52 +0000 |
commit | 2bd2c7d4eeea689475c10c56068d99948bcee193 (patch) | |
tree | 236f3400492246f21dbdaff4cdc1ebd8ce6ea887 /w3mimg/fb/fb_gdkpixbuf.c | |
parent | ignore config.h (diff) | |
download | w3m-2bd2c7d4eeea689475c10c56068d99948bcee193.tar.gz w3m-2bd2c7d4eeea689475c10c56068d99948bcee193.zip |
indent
Diffstat (limited to 'w3mimg/fb/fb_gdkpixbuf.c')
-rw-r--r-- | w3mimg/fb/fb_gdkpixbuf.c | 182 |
1 files changed, 95 insertions, 87 deletions
diff --git a/w3mimg/fb/fb_gdkpixbuf.c b/w3mimg/fb/fb_gdkpixbuf.c index 1799df6..46a0bf6 100644 --- a/w3mimg/fb/fb_gdkpixbuf.c +++ b/w3mimg/fb/fb_gdkpixbuf.c @@ -1,4 +1,4 @@ -/* $Id: fb_gdkpixbuf.c,v 1.4 2002/07/18 15:01:31 ukai Exp $ */ +/* $Id: fb_gdkpixbuf.c,v 1.5 2002/07/18 15:12:06 ukai Exp $ */ /************************************************************************** fb_gdkpixbuf.c 0.2 Copyright (C) 2002, hito **************************************************************************/ @@ -6,124 +6,132 @@ #include "fb.h" #include "fb_img.h" -static void set_prm(IMAGE *img); +static void set_prm(IMAGE * img); -IMAGE *fb_load_image(char *filename, int w, int h) +IMAGE * +fb_load_image(char *filename, int w, int h) { - GdkPixbuf *pixbuf; - IMAGE *img; - - if(filename == NULL) - return NULL; - - img = malloc(sizeof(*img)); - if(img == NULL) - return NULL; - - pixbuf = gdk_pixbuf_new_from_file(filename); - if(pixbuf == NULL){ - free(img); - return NULL; - } + GdkPixbuf *pixbuf; + IMAGE *img; - img->pixbuf = pixbuf; - set_prm(img); + if (filename == NULL) + return NULL; - fb_resize_image(img, w, h); + img = malloc(sizeof(*img)); + if (img == NULL) + return NULL; - return img; -} + pixbuf = gdk_pixbuf_new_from_file(filename); + if (pixbuf == NULL) { + free(img); + return NULL; + } -int fb_draw_image(IMAGE *img, int x, int y, int sx, int sy, int width, int height) -{ - int i, j, r, g, b, offset, bpp; + img->pixbuf = pixbuf; + set_prm(img); - if(img == NULL) - return 1; + fb_resize_image(img, w, h); + + return img; +} - bpp = img->rowstride / img->width; - for(j = sy; j < sy + height && j < img->height; j++){ - offset = j * img->rowstride + bpp * sx; - for(i = sx; i < sx + width && i < img->width; i++, offset += bpp){ - r = img->pixels[offset]; - g = img->pixels[offset + 1]; - b = img->pixels[offset + 2]; - if(img->alpha && img->pixels[offset + 3] == 0) - fb_pset(i + x - sx, j + y - sy, bg_r, bg_g, bg_b); - else - fb_pset(i + x - sx, j + y - sy, r, g, b); +int +fb_draw_image(IMAGE * img, int x, int y, int sx, int sy, int width, int height) +{ + int i, j, r, g, b, offset, bpp; + + if (img == NULL) + return 1; + + bpp = img->rowstride / img->width; + for (j = sy; j < sy + height && j < img->height; j++) { + offset = j * img->rowstride + bpp * sx; + for (i = sx; i < sx + width && i < img->width; i++, offset += bpp) { + r = img->pixels[offset]; + g = img->pixels[offset + 1]; + b = img->pixels[offset + 2]; + if (img->alpha && img->pixels[offset + 3] == 0) + fb_pset(i + x - sx, j + y - sy, bg_r, bg_g, bg_b); + else + fb_pset(i + x - sx, j + y - sy, r, g, b); + } } - } - return 0; + return 0; } -int fb_resize_image(IMAGE *img, int width, int height) +int +fb_resize_image(IMAGE * img, int width, int height) { - GdkPixbuf *pixbuf; - if(width < 1 || height < 1 || img == NULL) - return 1; + GdkPixbuf *pixbuf; + if (width < 1 || height < 1 || img == NULL) + return 1; - if(width == img->width && height == img->height) - return 0; + if (width == img->width && height == img->height) + return 0; - pixbuf = gdk_pixbuf_scale_simple(img->pixbuf, width, height, GDK_INTERP_HYPER); - if(pixbuf == NULL) - return 1; - gdk_pixbuf_finalize(img->pixbuf); + pixbuf = + gdk_pixbuf_scale_simple(img->pixbuf, width, height, GDK_INTERP_HYPER); + if (pixbuf == NULL) + return 1; + gdk_pixbuf_finalize(img->pixbuf); - img->pixbuf = pixbuf; - set_prm(img); - return 0; + img->pixbuf = pixbuf; + set_prm(img); + return 0; } -void fb_free_image(IMAGE *img) +void +fb_free_image(IMAGE * img) { - if(img == NULL) - return; + if (img == NULL) + return; - gdk_pixbuf_finalize(img->pixbuf); - free(img); + gdk_pixbuf_finalize(img->pixbuf); + free(img); } -IMAGE *fb_dup_image(IMAGE *img) +IMAGE * +fb_dup_image(IMAGE * img) { - GdkPixbuf *pixbuf; - IMAGE *new_img; + GdkPixbuf *pixbuf; + IMAGE *new_img; - if(img == NULL) - return NULL; + if (img == NULL) + return NULL; - new_img = malloc(sizeof(*img)); - if(new_img == NULL) - return NULL; + new_img = malloc(sizeof(*img)); + if (new_img == NULL) + return NULL; - pixbuf = gdk_pixbuf_copy(img->pixbuf); - if(pixbuf == NULL){ - free(new_img); - return NULL; - } + pixbuf = gdk_pixbuf_copy(img->pixbuf); + if (pixbuf == NULL) { + free(new_img); + return NULL; + } - new_img->pixbuf = pixbuf; - set_prm(new_img); - return new_img; + new_img->pixbuf = pixbuf; + set_prm(new_img); + return new_img; } -int fb_rotate_image(IMAGE *img, int angle) +int +fb_rotate_image(IMAGE * img, int angle) { - return 1; + return 1; } -static void set_prm(IMAGE *img) +static void +set_prm(IMAGE * img) { - GdkPixbuf *pixbuf; + GdkPixbuf *pixbuf; - if(img == NULL) - return; - pixbuf = img->pixbuf; + if (img == NULL) + return; + pixbuf = img->pixbuf; - img->pixels = gdk_pixbuf_get_pixels(pixbuf); - img->width = gdk_pixbuf_get_width(pixbuf); - img->height = gdk_pixbuf_get_height(pixbuf); - img->alpha = gdk_pixbuf_get_has_alpha(pixbuf); - img->rowstride = gdk_pixbuf_get_rowstride(pixbuf); + img->pixels = gdk_pixbuf_get_pixels(pixbuf); + img->width = gdk_pixbuf_get_width(pixbuf); + img->height = gdk_pixbuf_get_height(pixbuf); + img->alpha = gdk_pixbuf_get_has_alpha(pixbuf); + img->rowstride = gdk_pixbuf_get_rowstride(pixbuf); } |