From 380a45a4c9ad1f38f5cbee2d75e813fd0911cfcc Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Sat, 28 May 2011 14:19:01 +0100 Subject: [PATCH] Image resampling for thumbnails --- includes/graphics.h | 2 ++ src/graphics.c | 17 +++++++++++++++++ src/interface.c | 7 +++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/includes/graphics.h b/includes/graphics.h index 17aaa263c..fe13d2b98 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -52,6 +52,8 @@ void *ptif_pack(pixel *src, int w, int h, int *result_size); pixel *ptif_unpack(void *datain, int size, int *w, int *h); +pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh); + pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f); void sdl_blit_1(int x, int y, int w, int h, pixel *src, int pitch); diff --git a/src/graphics.c b/src/graphics.c index 6cc9310dd..b59a5bc40 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -138,6 +138,23 @@ pixel *ptif_unpack(void *datain, int size, int *w, int *h){ return result; } +pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh) +{ + int y, x; + //int i,j,x,y,w,h,r,g,b,c; + pixel *q; + q = malloc(rw*rh*PIXELSIZE); + //TODO: Actual resampling, this is just cheap nearest pixel crap + for (y=0; y