summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2011-06-08 12:30:39 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2011-06-08 12:30:39 (GMT)
commitb5c9d86fbefdc3402be2e6615bae0bc444a1d491 (patch)
tree915b493a97cb24b66543f6bc63fd4639c1652846
parentb5856bfa47020448961a60689dc2a44d09baf2ec (diff)
downloadpowder-b5c9d86fbefdc3402be2e6615bae0bc444a1d491.zip
powder-b5c9d86fbefdc3402be2e6615bae0bc444a1d491.tar.gz
Less blurry thumbnail scaling
-rw-r--r--includes/graphics.h2
-rw-r--r--src/graphics.c12
-rw-r--r--src/main.c4
3 files changed, 16 insertions, 2 deletions
diff --git a/includes/graphics.h b/includes/graphics.h
index 7489460..2d55638 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_nn(pixel *src, int sw, int sh, int rw, int rh);
+
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);
diff --git a/src/graphics.c b/src/graphics.c
index 0b8b8f8..af62862 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -140,6 +140,18 @@ pixel *ptif_unpack(void *datain, int size, int *w, int *h){
return result;
}
+pixel *resample_img_nn(pixel * src, int sw, int sh, int rw, int rh)
+{
+ int y, x;
+ pixel *q = NULL;
+ q = malloc(rw*rh*PIXELSIZE);
+ for (y=0; y<rh; y++)
+ for (x=0; x<rw; x++){
+ q[rw*y+x] = src[sw*(y*sh/rh)+(x*sw/rw)];
+ }
+ return q;
+}
+
pixel *resample_img(pixel *src, int sw, int sh, int rw, int rh)
{
int y, x;
diff --git a/src/main.c b/src/main.c
index 08f0f5c..3dd1f2b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1482,8 +1482,8 @@ int main(int argc, char *argv[])
free(datares);
datares = NULL;
}
- scaled_buf = resample_img(vid_buf, XRES, YRES, XRES/4, YRES/4);
- datares = ptif_pack(scaled_buf, XRES/4, YRES/4, &res);
+ scaled_buf = resample_img(vid_buf, XRES, YRES, XRES/GRID_Z, YRES/GRID_Z);
+ datares = ptif_pack(scaled_buf, XRES/GRID_Z, YRES/GRID_Z, &res);
if(datares!=NULL){
f=fopen(ptismallfilename, "wb");
fwrite(datares, res, 1, f);