summaryrefslogtreecommitdiff
path: root/src
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
parentabb0ceb98134903e9c339c0ba2546c82eaadfc3c (diff)
downloadpowder-380a45a4c9ad1f38f5cbee2d75e813fd0911cfcc.zip
powder-380a45a4c9ad1f38f5cbee2d75e813fd0911cfcc.tar.gz
Image resampling for thumbnails
Diffstat (limited to 'src')
-rw-r--r--src/graphics.c17
-rw-r--r--src/interface.c7
2 files changed, 22 insertions, 2 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;
diff --git a/src/interface.c b/src/interface.c
index 93af41f..eab39b4 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -2493,10 +2493,13 @@ int search_ui(pixel *vid_buf)
{
//render_thumb(search_thumbs[pos], search_thsizes[pos], 1, v_buf, gx, gy, GRID_S);
int finh, finw;
- char *thumb_imgdata = ptif_unpack(search_thumbs[pos], search_thsizes[pos], &finw, &finh);
+ pixel *thumb_rsdata = NULL;
+ pixel *thumb_imgdata = ptif_unpack(search_thumbs[pos], search_thsizes[pos], &finw, &finh);
if(thumb_imgdata!=NULL){
- draw_image(v_buf, thumb_imgdata, gx, gy, finw, finh, 255);
+ thumb_rsdata = resample_img(thumb_imgdata, finw, finh, XRES/GRID_S, YRES/GRID_S);
+ draw_image(v_buf, thumb_rsdata, gx, gy, XRES/GRID_S, YRES/GRID_S, 255);
free(thumb_imgdata);
+ free(thumb_rsdata);
}
thumb_drawn[pos] = 1;
}