summaryrefslogtreecommitdiff
path: root/src/graphics.c
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-05-28 13:19:01 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-05-28 13:19:01 (GMT)
commit380a45a4c9ad1f38f5cbee2d75e813fd0911cfcc (patch)
tree9ad962c94b4b3e3cb9bf724b8ce25f21c626b9a9 /src/graphics.c
parentabb0ceb98134903e9c339c0ba2546c82eaadfc3c (diff)
downloadpowder-380a45a4c9ad1f38f5cbee2d75e813fd0911cfcc.zip
powder-380a45a4c9ad1f38f5cbee2d75e813fd0911cfcc.tar.gz
Image resampling for thumbnails
Diffstat (limited to 'src/graphics.c')
-rw-r--r--src/graphics.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 6cc9310..b59a5bc 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<rh; y++)
+ for (x=0; x<rw; x++)
+ {
+ q[rw*y+x] = src[sw*(y*sh/rh)+(x*sw/rw)];
+ }
+ //*qw = w;
+ //*qh = h;
+ return q;
+}
+
pixel *rescale_img(pixel *src, int sw, int sh, int *qw, int *qh, int f)
{
int i,j,x,y,w,h,r,g,b,c;