From d07970d8d9c1ff6434656e66585ae4021ccf962c Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Thu, 3 Apr 2014 14:14:16 +1100 Subject: [PATCH] - image_bitmap --- src/image.c | 52 ---------------------------------------------------- src/image.h | 6 ------ 2 files changed, 58 deletions(-) diff --git a/src/image.c b/src/image.c index a3afd8b..2b4a081 100644 --- a/src/image.c +++ b/src/image.c @@ -90,55 +90,3 @@ image_from_file(const char *path, const char **errstr) return img; } - -int -image_bitmap(bitmap_t *bitmap, image_t *image, char **errstr) -{ - gdImagePtr src, dst = (NULL, NULL); - int16_t res_x, res_y = (160, 160); - int16_t i, j; - int oldcolor, newcolor, index; - - assert((dst = gdImageCreateTrueColor(res_x, res_y)) != NULL); - - /* resample to 160x160 */ - gdImageCopyResampled(dst, image->data, - 0, 0, /* dstX, dstY */ - 0, 0, /* srcX, srcY */ - res_x, res_y, /* dstW, dstH */ - image->res_x, image->res_y); /* srcW, srcH */ - - /* grayscale */ - gdFree(src); - src = dst; - assert((dst = gdImageCreateTrueColor(res_x, res_y)) != NULL); - for (i = 0; i < res_x; i++) { - for (j = 0; j < res_x; j++) { - /* WTF: begin */ - oldcolor = gdImageGetPixel(src, i, j); - newcolor = 0; - newcolor += 2 * gdImageGreen (src, oldcolor); - newcolor += 3 * gdImageRed (src, oldcolor); - newcolor += 4 * gdImageBlue (src, oldcolor); - newcolor /= 9; - /* WTF: end */ - if ((index = gdImageColorExact(dst,newcolor,newcolor,newcolor)) == -1) { - index = gdImageColorAllocate(dst,newcolor,newcolor,newcolor); - } - gdImageSetPixel(dst, i, j, index); - } - } - - /* blur */ - gdFree(src); - src = dst; - assert((dst = gdImageCreateTrueColor(res_x, res_y)) != NULL); - - /* normalize (intensity) */ - /* equalize (contrast) (sharpen?) */ - /* resample to 16x16 */ - /* convert to b&w (treshold?) */ - /* make bitmap */ - - return 0; -} diff --git a/src/image.h b/src/image.h index db5668c..4805cb0 100644 --- a/src/image.h +++ b/src/image.h @@ -11,11 +11,5 @@ typedef struct */ image_t * image_from_file(const char *path, const char **errstr); - -/** - * @returns: 0 on success, -1 on error - */ -int -image_bitmap(bitmap_t *bitmap, image_t *image, char **errstr); #endif #define HAS_IMAGE_H 1