This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, generate has been updated via 108607fa657f1e25d17ee497bfc1b840f5e9ac0c (commit) via 27108512e85e27b4f46c4be703126f2b2ee9fd68 (commit) via af00d9dd985a5b6a6ef304281a94ddd245e05cc4 (commit) via def6da387aaeaaef3071c0015ec053561da26780 (commit) from 631e1ca332e1b3bfccd1ebc4d83fa407eba13d51 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/108607fa657f1e25d17ee497bfc1b840f5e9a...
commit 108607fa657f1e25d17ee497bfc1b840f5e9ac0c Author: Cyril Hrubis metan@ucw.cz Date: Sun Oct 2 17:08:41 2011 +0200
Way more work on the progress callback.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index 4ea0543..8da1833 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -29,6 +29,16 @@
#include "params.h"
+static GP_ProgressCallback *progress_callback = NULL; + +static const char *progress_prefix = NULL; + +static void show_progress(GP_ProgressCallback *self) +{ + fprintf(stderr, "rFilter %s %3.2f%%", + progress_prefix, self->percentage); +} + static int param_err(const struct param *self, const char *val, void *priv) { /* invalid parameter name */ @@ -107,7 +117,7 @@ static GP_RetCode resize(GP_Context **c, const char *params) GP_Size h = ratio * (*c)->h; GP_Context *res = NULL;
- res = GP_FilterResize(*c, NULL, alg, w, h); + res = GP_FilterResize(*c, progress_callback, alg, w, h); if (res == NULL) return GP_EINVAL; @@ -161,7 +171,7 @@ static GP_RetCode scale(GP_Context **c, const char *params)
GP_Context *res = NULL;
- res = GP_FilterResize(*c, NULL, alg, w, h); + res = GP_FilterResize(*c, progress_callback, alg, w, h);
if (res == NULL) return GP_EINVAL; @@ -296,7 +306,7 @@ static GP_RetCode blur(GP_Context **c, const char *params) GP_Context *res = NULL;
- res = GP_FilterGaussianBlur(*c, sigma); + res = GP_FilterGaussianBlur(*c, progress_callback, sigma, sigma);
if (res == NULL) return GP_EINVAL; @@ -393,11 +403,18 @@ static void apply_filters(GP_Context **src) unsigned int i; GP_RetCode ret;
- for (i = 0; i < filter_cnt; i++) + for (i = 0; i < filter_cnt; i++) { + + progress_prefix = filters[i]->name; + if ((ret = filters[i]->apply(src, filter_params[i]))) { fprintf(stderr, "Error: %sn", GP_RetCodeName(ret)); exit(1); } + + if (progress_callback != NULL) + fprintf(stderr, " donen"); + } }
static const char *app_help = { @@ -416,6 +433,7 @@ static const char *app_help = { " =============== n" " n" "-h - prints this help n" + "-p - show filter progress n" "-v int - sets gfxprim verbosity level n" "-f params - apply filter, multiple filters may be usedn" " n" @@ -445,7 +463,11 @@ int main(int argc, char *argv[]) GP_RetCode ret; int opt, i;
- while ((opt = getopt(argc, argv, "f:hv:")) != -1) { + GP_ProgressCallback callback = { + .callback = show_progress, + }; + + while ((opt = getopt(argc, argv, "f:hpv:")) != -1) { switch (opt) { case 'h': print_help(); @@ -457,6 +479,9 @@ int main(int argc, char *argv[]) case 'f': add_filter(optarg); break; + case 'p': + progress_callback = &callback; + break; default: print_help(); return 1; diff --git a/include/filters/GP_Linear.h b/include/filters/GP_Filter.h similarity index 71% copy from include/filters/GP_Linear.h copy to include/filters/GP_Filter.h index 98e53f0..cc9918d 100644 --- a/include/filters/GP_Linear.h +++ b/include/filters/GP_Filter.h @@ -22,15 +22,37 @@
/*
- Linear filters. + Common filters typedefs and includes.
*/
-#ifndef GP_LINEAR_H -#define GP_LINEAR_H +#ifndef GP_FILTER_H +#define GP_FILTER_H
-#include <GP_Context.h> +#include "core/GP_Context.h"
-GP_Context *GP_FilterGaussianBlur(GP_Context *src, float sigma); +/* + * Progress callback + */ +typedef struct GP_ProgressCallback { + float percentage; + void (*callback)(struct GP_ProgressCallback *self); + void *priv; +} GP_ProgressCallback; + +static inline void GP_ProgressCallbackReport(GP_ProgressCallback *callback, + float percentage) +{ + if (callback == NULL) + return; + + callback->percentage = percentage; + callback->callback(callback); +} + +static inline void GP_ProgressCallbackDone(GP_ProgressCallback *callback) +{ + GP_ProgressCallbackReport(callback, 100); +}
-#endif /* GP_LINEAR_H */ +#endif /* GP_FILTER_H */ diff --git a/include/filters/GP_Linear.h b/include/filters/GP_Linear.h index 98e53f0..ae0debd 100644 --- a/include/filters/GP_Linear.h +++ b/include/filters/GP_Linear.h @@ -29,8 +29,24 @@ #ifndef GP_LINEAR_H #define GP_LINEAR_H
-#include <GP_Context.h> +#include "GP_Filter.h"
-GP_Context *GP_FilterGaussianBlur(GP_Context *src, float sigma); +/* + * Gaussian blur + * + * The sigma parameters defines the blur radii in horizontal and vertical + * direction. + * + * This variant could work in-place so it's perectly okay to call + * + * GP_FilterGaussianBlur_Raw(context, context, ...); + */ +void GP_FilterGaussianBlur_Raw(GP_Context *src, GP_Context *res, + GP_ProgressCallback *callback, + float sigma_x, float sigma_y); + +GP_Context *GP_FilterGaussianBlur(GP_Context *src, + GP_ProgressCallback *callback, + float sigma_x, float sigma_y);
#endif /* GP_LINEAR_H */ diff --git a/include/filters/GP_Resize.h b/include/filters/GP_Resize.h index 884a8f7..54acaed 100644 --- a/include/filters/GP_Resize.h +++ b/include/filters/GP_Resize.h @@ -52,10 +52,10 @@ typedef enum GP_InterpolationType { } GP_InterpolationType;
void GP_FilterResize_Raw(GP_Context *src, GP_Context *res, - GP_ProgressCallback callback, + GP_ProgressCallback *callback, GP_InterpolationType type);
-GP_Context *GP_FilterResize(GP_Context *src, GP_ProgressCallback callback, +GP_Context *GP_FilterResize(GP_Context *src, GP_ProgressCallback *callback, GP_InterpolationType type, GP_Size w, GP_Size h);
#endif /* GP_RESIZE_H */ diff --git a/libs/filters/GP_Linear.c b/libs/filters/GP_Linear.c index 764d6b6..1538ee2 100644 --- a/libs/filters/GP_Linear.c +++ b/libs/filters/GP_Linear.c @@ -29,46 +29,102 @@
#include <GP_Linear.h>
-static void GP_FilterLinearConvolution(const GP_Context *src, GP_Context *dst, +static void GP_FilterLinearConvolution(const GP_Context *src, GP_Context *res, + GP_ProgressCallback *callback, float kernel[], uint32_t kw, uint32_t kh);
-GP_Context *GP_FilterGaussianBlur(GP_Context *src, float sigma) +static inline unsigned int gaussian_kernel_size(float sigma) { - GP_Context *dst; - - if (src->pixel_type != GP_PIXEL_RGB888) - return NULL; - - dst = GP_ContextCopy(src, 0); - - if (dst == NULL) - return NULL; + int center = 3 * sigma;
+ return 2 * center + 1; +}
- /* compute kernel */ +static inline void gaussian_kernel_init(float sigma, float *kernel) +{ int i, center = 3 * sigma; int N = 2 * center + 1; - float kernel[N]; - + double sigma2 = sigma * sigma; - + for (i = 0; i < N; i++) { double r = center - i; - kernel[i] = exp(-0.5 * (r * r) / sigma2); } +}
- GP_DEBUG(1, "Gaussian blur sigma=%2.3f kernel %ix%i image %ux%u", - sigma, N, N, src->w, src->h); +static void gaussian_callback_1(GP_ProgressCallback *self) +{ + GP_ProgressCallbackReport(self->priv, self->percentage/2); +}
- /* apply in both directions */ - GP_FilterLinearConvolution(src, dst, kernel, N, 1); - GP_FilterLinearConvolution(dst, dst, kernel, 1, N); +static void gaussian_callback_2(GP_ProgressCallback *self) +{ + GP_ProgressCallbackReport(self->priv, self->percentage/2 + 50); +} + +void GP_FilterGaussianBlur_Raw(GP_Context *src, GP_Context *res, + GP_ProgressCallback *callback, + float sigma_x, float sigma_y) +{ + unsigned int size_x = gaussian_kernel_size(sigma_x); + unsigned int size_y = gaussian_kernel_size(sigma_y); + + GP_DEBUG(1, "Gaussian blur sigma_x=%2.3f sigma_y=%2.3f kernel %ix%i image %ux%u", + sigma_x, sigma_y, size_x, size_y, src->w, src->h); + + GP_ProgressCallback *new_callback = NULL;
- return dst; + GP_ProgressCallback gaussian_callback = { + .callback = gaussian_callback_1, + .priv = callback + }; + + if (callback != NULL) + new_callback = &gaussian_callback; + + /* compute kernel and apply on horizontal direction */ + float kernel_x[size_x]; + gaussian_kernel_init(sigma_x, kernel_x); + GP_FilterLinearConvolution(src, res, new_callback, kernel_x, size_x, 1); + + if (new_callback != NULL) + new_callback->callback = gaussian_callback_2; + + /* compute kernel and apply on vertical direction */ + float kernel_y[size_y]; + gaussian_kernel_init(sigma_y, kernel_y); + GP_FilterLinearConvolution(res, res, new_callback, kernel_y, 1, size_y); + + if (callback != NULL) { + callback->percentage = 100; + callback->callback(callback); + } }
-static void GP_FilterLinearConvolution(const GP_Context *src, GP_Context *dst, +GP_Context *GP_FilterGaussianBlur(GP_Context *src, + GP_ProgressCallback *callback, + float sigma_x, float sigma_y) +{ + GP_Context *res; + + if (src->pixel_type != GP_PIXEL_RGB888) + return NULL; + + res = GP_ContextCopy(src, 0); + + if (res == NULL) { + GP_DEBUG(1, "Malloc failed :("); + return NULL; + } + + GP_FilterGaussianBlur_Raw(src, res, callback, sigma_x, sigma_y); + + return res; +} + +static void GP_FilterLinearConvolution(const GP_Context *src, GP_Context *res, + GP_ProgressCallback *callback, float kernel[], uint32_t kw, uint32_t kh) { float kernel_sum = 0; @@ -83,7 +139,7 @@ static void GP_FilterLinearConvolution(const GP_Context *src, GP_Context *dst, kernel_sum += kernel[i];
/* do linear convolution */ - for (y = 0; y < (GP_Coord)dst->h; y++) { + for (y = 0; y < (GP_Coord)res->h; y++) { GP_Pixel pix; uint32_t R[kw][kh], G[kw][kh], B[kw][kh];
@@ -112,7 +168,7 @@ static void GP_FilterLinearConvolution(const GP_Context *src, GP_Context *dst,
int idx = kw - 1;
- for (x = 0; x < (GP_Coord)dst->w; x++) { + for (x = 0; x < (GP_Coord)res->w; x++) { float r = 0, g = 0, b = 0;
for (j = 0; j < kh; j++) { @@ -166,13 +222,17 @@ static void GP_FilterLinearConvolution(const GP_Context *src, GP_Context *dst,
pix = GP_Pixel_CREATE_RGB888((uint32_t)r, (uint32_t)g, (uint32_t)b);
- GP_PutPixel_Raw_24BPP(dst, x, y, pix); + GP_PutPixel_Raw_24BPP(res, x, y, pix); idx++;
if (idx >= (int)kw) idx = 0; } + + if (callback != NULL && y % 100 == 0) + GP_ProgressCallbackReport(callback, 100.00 * y/res->h); } -}
+ GP_ProgressCallbackDone(callback); +} diff --git a/libs/filters/GP_Resize.c b/libs/filters/GP_Resize.c index 50041c2..6f944a6 100644 --- a/libs/filters/GP_Resize.c +++ b/libs/filters/GP_Resize.c @@ -28,7 +28,7 @@ #include <GP_Resize.h>
void GP_FilterInterpolate_NN(GP_Context *src, GP_Context *res, - GP_ProgressCallback callback) + GP_ProgressCallback *callback) { GP_Coord x, y; @@ -45,7 +45,12 @@ void GP_FilterInterpolate_NN(GP_Context *src, GP_Context *res,
GP_PutPixel_Raw_24BPP(res, x, y, pix); } + + if (callback != NULL && y % 100 == 0) + GP_ProgressCallbackReport(callback, 100.00 * y/res->h); } + + GP_ProgressCallbackDone(callback); }
#define A 0.5 @@ -75,7 +80,7 @@ typedef union v4f { #define SUM_V4SF(a) ((a).f[0] + (a).f[1] + (a).f[2] + (a).f[3])
void GP_FilterInterpolate_Cubic(GP_Context *src, GP_Context *res, - GP_ProgressCallback callback) + GP_ProgressCallback *callback) { float col_r[src->h], col_g[src->h], col_b[src->h]; uint32_t i, j; @@ -196,11 +201,16 @@ void GP_FilterInterpolate_Cubic(GP_Context *src, GP_Context *res, GP_Pixel pix = GP_Pixel_CREATE_RGB888((uint8_t)r, (uint8_t)g, (uint8_t)b); GP_PutPixel_Raw_24BPP(res, i, j, pix); } + + if (callback != NULL && i % 100 == 0) + GP_ProgressCallbackReport(callback, 100.00 * i/res->w); } + + GP_ProgressCallbackDone(callback); }
void GP_FilterResize_Raw(GP_Context *src, GP_Context *res, - GP_ProgressCallback callback, + GP_ProgressCallback *callback, GP_InterpolationType type) { switch (type) { @@ -213,7 +223,7 @@ void GP_FilterResize_Raw(GP_Context *src, GP_Context *res, } }
-GP_Context *GP_FilterResize(GP_Context *src, GP_ProgressCallback callback, +GP_Context *GP_FilterResize(GP_Context *src, GP_ProgressCallback *callback, GP_InterpolationType type, GP_Size w, GP_Size h) { GP_Context *res;
http://repo.or.cz/w/gfxprim.git/commit/27108512e85e27b4f46c4be703126f2b2ee9f...
commit 27108512e85e27b4f46c4be703126f2b2ee9fd68 Author: Cyril Hrubis metan@ucw.cz Date: Sun Oct 2 15:09:51 2011 +0200
The GP.h header shouldn't be used in library itself.
diff --git a/libs/core/GP_Blit.gen.c.t b/libs/core/GP_Blit.gen.c.t index 2491b0b..2bc3f69 100644 --- a/libs/core/GP_Blit.gen.c.t +++ b/libs/core/GP_Blit.gen.c.t @@ -6,7 +6,7 @@ #include <stdio.h> #include <string.h> #include "GP_Pixel.h" -#include "GP.h" +#include "GP_GetPutPixel.h" #include "GP_Context.h" #include "GP_Blit.h"
http://repo.or.cz/w/gfxprim.git/commit/af00d9dd985a5b6a6ef304281a94ddd245e05...
commit af00d9dd985a5b6a6ef304281a94ddd245e05cc4 Author: Cyril Hrubis metan@ucw.cz Date: Sun Oct 2 12:33:02 2011 +0200
Cleaned up resize filters api, prepared for progress callback.
diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index 82e7228..4ea0543 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -107,15 +107,8 @@ static GP_RetCode resize(GP_Context **c, const char *params) GP_Size h = ratio * (*c)->h; GP_Context *res = NULL;
- switch (alg) { - case 0: - res = GP_Scale_NN(*c, w, h); - break; - case 1: - res = GP_Scale_BiCubic(*c, w, h); - break; - } - + res = GP_FilterResize(*c, NULL, alg, w, h); + if (res == NULL) return GP_EINVAL;
@@ -168,14 +161,7 @@ static GP_RetCode scale(GP_Context **c, const char *params)
GP_Context *res = NULL;
- switch (alg) { - case 0: - res = GP_Scale_NN(*c, w, h); - break; - case 1: - res = GP_Scale_BiCubic(*c, w, h); - break; - } + res = GP_FilterResize(*c, NULL, alg, w, h);
if (res == NULL) return GP_EINVAL; diff --git a/include/filters/GP_Filters.h b/include/filters/GP_Filters.h index fc498b0..90f63b3 100644 --- a/include/filters/GP_Filters.h +++ b/include/filters/GP_Filters.h @@ -35,10 +35,13 @@ /* Image rotations (90 180 270 grads) and mirroring */ #include "filters/GP_Rotate.h"
+/* Point filters, brightness, contrast ... */ #include "filters/GP_Point.h" + +/* Linear convolution base filters (mostly blurs) */ #include "filters/GP_Linear.h"
-/* Image down and up scaling */ -#include "filters/GP_Scale.h" +/* Image scaling */ +#include "filters/GP_Resize.h"
#endif /* GP_FILTERS_H */ diff --git a/include/filters/GP_Scale.h b/include/filters/GP_Resize.h similarity index 63% rename from include/filters/GP_Scale.h rename to include/filters/GP_Resize.h index 06414c2..884a8f7 100644 --- a/include/filters/GP_Scale.h +++ b/include/filters/GP_Resize.h @@ -22,31 +22,40 @@
/*
- GP_Context resize. + GP_Context interpolations.
- */ + Nearest Neighbour + ~~~~~~~~~~~~~~~~~
-#ifndef GP_SCALE_H -#define GP_SCALE_H + Fast, but produces pixelated images. Works however well for images with sharp + edges mostly consisting of big one color regions (eg doesn't blur the + result on upscaling).
-#include "core/GP_Context.h"
-/* - * Nearest neighbour - * - * Faster than others, but produces pixelated images. Works however well for - * images with sharp edges mostly consisting of big once color parts (eg - * doesn't blurr the result on upscaling). - */ -GP_Context *GP_Scale_NN(GP_Context *src, GP_Size w, GP_Size h); + Bicubic + ~~~~~~~ + + Works well for upscaling as is. To get decent result on downscaling, + low-pass filter (for example gaussian blur) must be used on original image + before scaling is done.
-/* - * Bicubic Scaling - * - * Works well for upscaling. Not so good for downscaling big images to small - * ones (looses too much information). */ -GP_Context *GP_Scale_BiCubic(GP_Context *src, GP_Size w, GP_Size h);
+#ifndef GP_RESIZE_H +#define GP_RESIZE_H + +#include "GP_Filter.h" + +typedef enum GP_InterpolationType { + GP_INTER_NN, /* Nearest Neighbour */ + GP_INTER_CUBIC, /* Bicubic */ +} GP_InterpolationType; + +void GP_FilterResize_Raw(GP_Context *src, GP_Context *res, + GP_ProgressCallback callback, + GP_InterpolationType type); + +GP_Context *GP_FilterResize(GP_Context *src, GP_ProgressCallback callback, + GP_InterpolationType type, GP_Size w, GP_Size h);
-#endif /* GP_SCALE_H */ +#endif /* GP_RESIZE_H */ diff --git a/libs/filters/GP_Scale.c b/libs/filters/GP_Resize.c similarity index 75% rename from libs/filters/GP_Scale.c rename to libs/filters/GP_Resize.c index 88c14a9..50041c2 100644 --- a/libs/filters/GP_Scale.c +++ b/libs/filters/GP_Resize.c @@ -25,38 +25,27 @@
#include <GP_Debug.h>
-#include <GP_Scale.h> +#include <GP_Resize.h>
- -GP_Context *GP_Scale_NN(GP_Context *src, GP_Size w, GP_Size h) +void GP_FilterInterpolate_NN(GP_Context *src, GP_Context *res, + GP_ProgressCallback callback) { - GP_Context *dst; - - if (src->pixel_type != GP_PIXEL_RGB888) - return NULL; - - dst = GP_ContextAlloc(w, h, GP_PIXEL_RGB888); - - if (dst == NULL) - return NULL; - - GP_DEBUG(1, "Scaling image %ux%u -> %ux%u %2.2f %2.2f", - src->w, src->h, w, h, - 1.00 * w / src->w, 1.00 * h / src->h); - GP_Coord x, y; + + GP_DEBUG(1, "Scaling image %ux%u -> %ux%u %2.2f %2.2f", + src->w, src->h, res->w, res->h, + 1.00 * res->w / src->w, 1.00 * res->h / src->h);
- for (y = 0; y < (int)h; y++) - for (x = 0; x < (int)w; x++) { - GP_Coord xi = (1.00 * x / w) * src->w; - GP_Coord yi = (1.00 * y / h) * src->h; + for (y = 0; y < (GP_Coord)res->h; y++) { + for (x = 0; x < (GP_Coord)res->w; x++) { + GP_Coord xi = (1.00 * x / res->w) * src->w; + GP_Coord yi = (1.00 * y / res->h) * src->h; GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, xi, yi);
- GP_PutPixel_Raw_24BPP(dst, x, y, pix); + GP_PutPixel_Raw_24BPP(res, x, y, pix); } - - return dst; + } }
#define A 0.5 @@ -85,26 +74,18 @@ typedef union v4f { #define MUL_V4SF(a, b) ((union v4f)((a).v * (b).v)) #define SUM_V4SF(a) ((a).f[0] + (a).f[1] + (a).f[2] + (a).f[3])
-GP_Context *GP_Scale_BiCubic(GP_Context *src, GP_Size w, GP_Size h) +void GP_FilterInterpolate_Cubic(GP_Context *src, GP_Context *res, + GP_ProgressCallback callback) { - GP_Context *dst; float col_r[src->h], col_g[src->h], col_b[src->h]; uint32_t i, j;
- if (src->pixel_type != GP_PIXEL_RGB888) - return NULL; - - dst = GP_ContextAlloc(w, h, GP_PIXEL_RGB888); - - if (dst == NULL) - return NULL; - GP_DEBUG(1, "Scaling image %ux%u -> %ux%u %2.2f %2.2f", - src->w, src->h, w, h, - 1.00 * w / src->w, 1.00 * h / src->h); + src->w, src->h, res->w, res->h, + 1.00 * res->w / src->w, 1.00 * res->h / src->h);
- for (i = 0; i < w; i++) { - float x = (1.00 * i / w) * (src->w - 4.5) + 2.5; + for (i = 0; i < res->w; i++) { + float x = (1.00 * i / res->w) * (src->w - 4.5) + 2.5; v4f cvx; int xi = x - 1;
@@ -154,8 +135,8 @@ GP_Context *GP_Scale_BiCubic(GP_Context *src, GP_Size w, GP_Size h) }
/* now interpolate column for new image */ - for (j = 0; j < h; j++) { - float y = (1.00 * j / h) * (src->h - 4.5) + 2.5; + for (j = 0; j < res->h; j++) { + float y = (1.00 * j / res->h) * (src->h - 4.5) + 2.5; v4f cvy, rv, gv, bv; float r, g, b; int yi = y - 1; @@ -213,9 +194,41 @@ GP_Context *GP_Scale_BiCubic(GP_Context *src, GP_Size w, GP_Size h) b = 0; GP_Pixel pix = GP_Pixel_CREATE_RGB888((uint8_t)r, (uint8_t)g, (uint8_t)b); - GP_PutPixel_Raw_24BPP(dst, i, j, pix); + GP_PutPixel_Raw_24BPP(res, i, j, pix); } } +} + +void GP_FilterResize_Raw(GP_Context *src, GP_Context *res, + GP_ProgressCallback callback, + GP_InterpolationType type) +{ + switch (type) { + case GP_INTER_NN: + GP_FilterInterpolate_NN(src, res, callback); + break; + case GP_INTER_CUBIC: + GP_FilterInterpolate_Cubic(src, res, callback); + break; + } +} + +GP_Context *GP_FilterResize(GP_Context *src, GP_ProgressCallback callback, + GP_InterpolationType type, GP_Size w, GP_Size h) +{ + GP_Context *res; + + if (src->pixel_type != GP_PIXEL_RGB888) + return NULL; + + res = GP_ContextAlloc(w, h, GP_PIXEL_RGB888); + + if (res == NULL) { + GP_DEBUG(1, "Malloc failed :("); + return NULL; + } + + GP_FilterResize_Raw(src, res, callback, type);
- return dst; + return res; }
http://repo.or.cz/w/gfxprim.git/commit/def6da387aaeaaef3071c0015ec053561da26...
commit def6da387aaeaaef3071c0015ec053561da26780 Author: Cyril Hrubis metan@ucw.cz Date: Sun Oct 2 12:27:44 2011 +0200
Remove scale test as demos/grinder serves better.
diff --git a/tests/SDL/Makefile b/tests/SDL/Makefile index 6d93313..8c02ba1 100644 --- a/tests/SDL/Makefile +++ b/tests/SDL/Makefile @@ -6,8 +6,7 @@ INCLUDE=core gfx SDL backends LDLIBS+=-lGP -L$(TOPDIR)/build/ -lGP_SDL -lSDL -lpng
APPS=pixeltest fileview fonttest linetest randomshapetest shapetest sierpinsky- symbolstest textaligntest trianglefps input blittest subcontext scale_test- showimage + symbolstest textaligntest trianglefps input blittest subcontext showimage
include $(TOPDIR)/include.mk include $(TOPDIR)/app.mk diff --git a/tests/SDL/scale_test.c b/tests/SDL/scale_test.c deleted file mode 100644 index aa026b9..0000000 --- a/tests/SDL/scale_test.c +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -#include <stdio.h> -#include <stdlib.h> - -#include "GP.h" - -int main(int argc, char *argv[]) -{ - GP_Context *bitmap; - GP_SetDebugLevel(10); - GP_RetCode ret; - GP_Size w, h; - - if (argc < 4) { - fprintf(stderr, "Usage: image w hn"); - return 1; - } - - if ((ret = GP_LoadImage(argv[1], &bitmap))) { - fprintf(stderr, "Failed to load bitmap: %sn", GP_RetCodeName(ret)); - return 1; - } - - w = atoi(argv[2]); - h = atoi(argv[3]); - - bitmap = GP_Scale_BiCubic(bitmap, w, h); - - if ((ret = GP_SavePPM("out.ppm", bitmap, "b"))) { - fprintf(stderr, "Failed to load bitmap: %sn", GP_RetCodeName(ret)); - return 1; - } - - return 0; -}
-----------------------------------------------------------------------
Summary of changes: demos/grinder/grinder.c | 51 +++++++----- include/filters/{GP_Scale.h => GP_Filter.h} | 46 ++++++----- include/filters/GP_Filters.h | 7 +- include/filters/GP_Linear.h | 20 ++++- include/filters/{GP_Point.h => GP_Resize.h} | 48 ++++++----- libs/core/GP_Blit.gen.c.t | 2 +- libs/filters/GP_Linear.c | 114 ++++++++++++++++++++------ libs/filters/{GP_Scale.c => GP_Resize.c} | 105 +++++++++++++++---------- tests/SDL/Makefile | 3 +- tests/SDL/scale_test.c | 56 ------------- 10 files changed, 259 insertions(+), 193 deletions(-) rename include/filters/{GP_Scale.h => GP_Filter.h} (72%) copy include/filters/{GP_Point.h => GP_Resize.h} (63%) rename libs/filters/{GP_Scale.c => GP_Resize.c} (72%) delete mode 100644 tests/SDL/scale_test.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.