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 aa8f80b7334e88d72171f325bb37cfc4b2245d0e (commit) via 473d31d4feafd632b9cd7c668fb7548a6855ce03 (commit) via 8c0a1d4f59d6c69dfbffa2817236b6b18d7f261b (commit) from 4061392c7024e648dc2bcfde720ce11e0f70dedb (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/aa8f80b7334e88d72171f325bb37cfc4b2245...
commit aa8f80b7334e88d72171f325bb37cfc4b2245d0e Author: Cyril Hrubis metan@ucw.cz Date: Mon Oct 31 14:22:24 2011 +0100
Fixed the interpolation filters api.
diff --git a/demos/fbshow/fbshow.c b/demos/fbshow/fbshow.c index 76dcb99..ffa2c6a 100644 --- a/demos/fbshow/fbshow.c +++ b/demos/fbshow/fbshow.c @@ -48,7 +48,7 @@ static GP_Context *image_to_display(GP_Context *img, uint32_t w, uint32_t h) { float rat = calc_img_size(img->w, img->h, w, h);
- return GP_FilterResize(img, NULL, GP_INTERP_CUBIC, img->w * rat, img->h * rat); + return GP_FilterResize(img, NULL, GP_INTERP_CUBIC, img->w * rat, img->h * rat, NULL); }
static int show_image(GP_Framebuffer *fb, const char *img_path, int clear) diff --git a/demos/grinder/grinder.c b/demos/grinder/grinder.c index 27d8ded..3582c38 100644 --- a/demos/grinder/grinder.c +++ b/demos/grinder/grinder.c @@ -117,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, progress_callback, alg, w, h); + res = GP_FilterResize(*c, NULL, alg, w, h, progress_callback); if (res == NULL) return GP_EINVAL; @@ -177,7 +177,7 @@ static GP_RetCode scale(GP_Context **c, const char *params)
GP_Context *res = NULL;
- res = GP_FilterResize(*c, progress_callback, alg, w, h); + res = GP_FilterResize(*c, NULL, alg, w, h, progress_callback);
if (res == NULL) return GP_EINVAL; diff --git a/include/filters/GP_Filters.h b/include/filters/GP_Filters.h index 90f63b3..8e2d84d 100644 --- a/include/filters/GP_Filters.h +++ b/include/filters/GP_Filters.h @@ -38,10 +38,10 @@ /* Point filters, brightness, contrast ... */ #include "filters/GP_Point.h"
-/* Linear convolution base filters (mostly blurs) */ +/* Linear convolution based filters (mostly blurs) */ #include "filters/GP_Linear.h"
-/* Image scaling */ +/* Image scaling (resampling) */ #include "filters/GP_Resize.h"
#endif /* GP_FILTERS_H */ diff --git a/include/filters/GP_Linear.h b/include/filters/GP_Linear.h index ae028fc..3c0d1e9 100644 --- a/include/filters/GP_Linear.h +++ b/include/filters/GP_Linear.h @@ -63,7 +63,8 @@ GP_Context *GP_FilterGaussianBlur(const GP_Context *src, GP_Context *dst, /* * Linear convolution. * - * The kernel is array of kw * kh floats and is indexed as two directional array. + * The kernel is array of kw * kh floats and is indexed as two directional + * array. * * To define 3x3 average filter * diff --git a/include/filters/GP_Resize.h b/include/filters/GP_Resize.h index 05f80c7..63a6143 100644 --- a/include/filters/GP_Resize.h +++ b/include/filters/GP_Resize.h @@ -41,8 +41,8 @@
*/
-#ifndef GP_RESIZE_H -#define GP_RESIZE_H +#ifndef FILTERS_GP_RESIZE_H +#define FILTERS_GP_RESIZE_H
#include "GP_Filter.h"
@@ -51,11 +51,26 @@ typedef enum GP_InterpolationType { GP_INTERP_CUBIC, /* Bicubic */ } GP_InterpolationType;
-void GP_FilterResize_Raw(GP_Context *src, GP_Context *res, - GP_ProgressCallback *callback, - GP_InterpolationType type); +/* + * Just interpolate the source context into destination context. + */ +void GP_FilterResize_Raw(const GP_Context *src, GP_Context *dst, + GP_InterpolationType type, + GP_ProgressCallback *callback);
-GP_Context *GP_FilterResize(GP_Context *src, GP_ProgressCallback *callback, - GP_InterpolationType type, GP_Size w, GP_Size h); +/* + * If destination is non NULL, the w and h are used to create subcontext from + * destination which is then used to interpolate the image to. + * + * Otherwise if destination is NULL, the context of size w and h is allocated + * and returned. + * + * In both cases the pointer to destination or NULL in case of failure is + * returned. + */ +GP_Context *GP_FilterResize(const GP_Context *src, GP_Context *dst, + GP_InterpolationType type, + GP_Size w, GP_Size h, + GP_ProgressCallback *callback);
-#endif /* GP_RESIZE_H */ +#endif /* FILTERS_GP_RESIZE_H */ diff --git a/libs/filters/GP_Resize.c b/libs/filters/GP_Resize.c index 192d5f5..eb42478 100644 --- a/libs/filters/GP_Resize.c +++ b/libs/filters/GP_Resize.c @@ -27,27 +27,27 @@
#include <GP_Resize.h>
-void GP_FilterInterpolate_NN(GP_Context *src, GP_Context *res, +void GP_FilterInterpolate_NN(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback) { 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); + src->w, src->h, dst->w, dst->h, + 1.00 * dst->w / src->w, 1.00 * dst->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; + for (y = 0; y < (GP_Coord)dst->h; y++) { + for (x = 0; x < (GP_Coord)dst->w; x++) { + GP_Coord xi = (1.00 * x / dst->w) * src->w; + GP_Coord yi = (1.00 * y / dst->h) * src->h; GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, xi, yi);
- GP_PutPixel_Raw_24BPP(res, x, y, pix); + GP_PutPixel_Raw_24BPP(dst, x, y, pix); } if (callback != NULL && y % 100 == 0) - GP_ProgressCallbackReport(callback, 100.00 * y/res->h); + GP_ProgressCallbackReport(callback, 100.00 * y/dst->h); }
GP_ProgressCallbackDone(callback); @@ -79,18 +79,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])
-void GP_FilterInterpolate_Cubic(GP_Context *src, GP_Context *res, +void GP_FilterInterpolate_Cubic(const GP_Context *src, GP_Context *dst, GP_ProgressCallback *callback) { float col_r[src->h], col_g[src->h], col_b[src->h]; uint32_t i, j;
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); + src->w, src->h, dst->w, dst->h, + 1.00 * dst->w / src->w, 1.00 * dst->h / src->h);
- for (i = 0; i < res->w; i++) { - float x = (1.00 * i / res->w) * (src->w - 4.5) + 2.5; + for (i = 0; i < dst->w; i++) { + float x = (1.00 * i / dst->w) * (src->w - 4.5) + 2.5; v4f cvx; int xi = x - 1;
@@ -140,8 +140,8 @@ void GP_FilterInterpolate_Cubic(GP_Context *src, GP_Context *res, }
/* now interpolate column for new image */ - for (j = 0; j < res->h; j++) { - float y = (1.00 * j / res->h) * (src->h - 4.5) + 2.5; + for (j = 0; j < dst->h; j++) { + float y = (1.00 * j / dst->h) * (src->h - 4.5) + 2.5; v4f cvy, rv, gv, bv; float r, g, b; int yi = y - 1; @@ -199,46 +199,58 @@ void GP_FilterInterpolate_Cubic(GP_Context *src, GP_Context *res, b = 0; GP_Pixel pix = GP_Pixel_CREATE_RGB888((uint8_t)r, (uint8_t)g, (uint8_t)b); - GP_PutPixel_Raw_24BPP(res, i, j, pix); + GP_PutPixel_Raw_24BPP(dst, i, j, pix); } if (callback != NULL && i % 100 == 0) - GP_ProgressCallbackReport(callback, 100.00 * i/res->w); + GP_ProgressCallbackReport(callback, 100.00 * i/dst->w); }
GP_ProgressCallbackDone(callback); }
-void GP_FilterResize_Raw(GP_Context *src, GP_Context *res, - GP_ProgressCallback *callback, - GP_InterpolationType type) +void GP_FilterResize_Raw(const GP_Context *src, GP_Context *dst, + GP_InterpolationType type, + GP_ProgressCallback *callback) { switch (type) { case GP_INTERP_NN: - GP_FilterInterpolate_NN(src, res, callback); + GP_FilterInterpolate_NN(src, dst, callback); break; case GP_INTERP_CUBIC: - GP_FilterInterpolate_Cubic(src, res, callback); + GP_FilterInterpolate_Cubic(src, dst, callback); break; } }
-GP_Context *GP_FilterResize(GP_Context *src, GP_ProgressCallback *callback, - GP_InterpolationType type, GP_Size w, GP_Size h) +GP_Context *GP_FilterResize(const GP_Context *src, GP_Context *dst, + GP_InterpolationType type, + GP_Size w, GP_Size h, + GP_ProgressCallback *callback) { - GP_Context *res; - + GP_Context sub, *res; + + /* TODO: Templatize */ 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; + + if (dst == NULL) { + dst = GP_ContextAlloc(w, h, src->pixel_type); + + if (dst == NULL) + return NULL; + + res = dst; + } else { + GP_ASSERT(src->pixel_type == dst->pixel_type, + "The src and dst pixel types must match"); + /* + * The size of w and h is asserted in subcontext initalization + */ + res = GP_ContextSubContext(dst, &sub, 0, 0, w, h); }
- GP_FilterResize_Raw(src, res, callback, type); + GP_FilterResize_Raw(src, res, type, callback);
- return res; + return dst; }
http://repo.or.cz/w/gfxprim.git/commit/473d31d4feafd632b9cd7c668fb7548a6855c...
commit 473d31d4feafd632b9cd7c668fb7548a6855ce03 Author: Cyril Hrubis metan@ucw.cz Date: Mon Oct 31 14:05:32 2011 +0100
Remove the redundant linker flags.
diff --git a/demos/fbshow/Makefile b/demos/fbshow/Makefile index 2ca7439..0a8147c 100644 --- a/demos/fbshow/Makefile +++ b/demos/fbshow/Makefile @@ -3,7 +3,7 @@ TOPDIR=../.. CSOURCES=$(shell echo *.c)
INCLUDE= -LDLIBS+=-lGP -L$(TOPDIR)/build/ -lpng +LDLIBS+=-lGP -L$(TOPDIR)/build/
APPS=fbshow
diff --git a/demos/grinder/Makefile b/demos/grinder/Makefile index 7cf1e72..a984bd9 100644 --- a/demos/grinder/Makefile +++ b/demos/grinder/Makefile @@ -3,7 +3,7 @@ TOPDIR=../.. CSOURCES=$(shell echo *.c)
INCLUDE=core gfx SDL backends -LDLIBS+=-lGP -L$(TOPDIR)/build/ -lpng +LDLIBS+=-lGP -L$(TOPDIR)/build/
APPS=grinder
diff --git a/tests/SDL/Makefile b/tests/SDL/Makefile index 8c02ba1..123889b 100644 --- a/tests/SDL/Makefile +++ b/tests/SDL/Makefile @@ -3,7 +3,7 @@ TOPDIR=../.. CSOURCES=$(shell echo *.c)
INCLUDE=core gfx SDL backends -LDLIBS+=-lGP -L$(TOPDIR)/build/ -lGP_SDL -lSDL -lpng +LDLIBS+=-lGP -L$(TOPDIR)/build/ -lGP_SDL -lSDL
APPS=pixeltest fileview fonttest linetest randomshapetest shapetest sierpinsky symbolstest textaligntest trianglefps input blittest subcontext showimage
http://repo.or.cz/w/gfxprim.git/commit/8c0a1d4f59d6c69dfbffa2817236b6b18d7f2...
commit 8c0a1d4f59d6c69dfbffa2817236b6b18d7f261b Author: Cyril Hrubis metan@ucw.cz Date: Mon Oct 31 13:57:09 2011 +0100
Allow GP_ContextSubContext() to inialized given buffer.
diff --git a/include/core/GP_Context.h b/include/core/GP_Context.h index 80794d9..ef2940e 100644 --- a/include/core/GP_Context.h +++ b/include/core/GP_Context.h @@ -104,9 +104,15 @@ GP_Context *GP_ContextCopy(const GP_Context *src, int flag);
/* * Create subcontext. + * + * If pointer to subcontext is NULL, new context is allocated + * otherwise context pointed by subcontext pointer is initalized. + * + * The free_pixels flag is set to 0 upon subcontext initalization so the + * GP_ContextFree() would not call free() upon the subcontext->pixels pointer. */ -GP_Context *GP_ContextSubContext(GP_Context *context, GP_Coord x, GP_Coord y, - GP_Size w, GP_Size h); +GP_Context *GP_ContextSubContext(GP_Context *context, GP_Context *subcontext, + GP_Coord x, GP_Coord y, GP_Size w, GP_Size h);
/* * Converts context to different pixel type. diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c index 83c9f73..67aca4f 100644 --- a/libs/core/GP_Context.c +++ b/libs/core/GP_Context.c @@ -127,17 +127,21 @@ void GP_ContextFree(GP_Context *context) free(context); }
-GP_Context *GP_ContextSubContext(GP_Context *context, GP_Coord x, GP_Coord y, - GP_Size w, GP_Size h) +GP_Context *GP_ContextSubContext(GP_Context *context, GP_Context *subcontext, + GP_Coord x, GP_Coord y, GP_Size w, GP_Size h) { GP_CHECK(context, "NULL context"); GP_CHECK(context->w >= x + w, "Subcontext w out of original context."); GP_CHECK(context->h >= y + h, "Subcontext h out of original context."); + + GP_Context *ret = subcontext;
- GP_Context *ret = malloc(sizeof(GP_Context)); + if (ret == NULL) { + GP_Context *ret = malloc(sizeof(GP_Context));
- if (ret == NULL) - return NULL; + if (ret == NULL) + return NULL; + }
ret->bpp = context->bpp; ret->bytes_per_row = context->bytes_per_row; diff --git a/tests/SDL/subcontext.c b/tests/SDL/subcontext.c index bbdfeae..25db7fb 100644 --- a/tests/SDL/subcontext.c +++ b/tests/SDL/subcontext.c @@ -260,7 +260,7 @@ int main(int argc, char *argv[]) white = GP_ColorToContextPixel(GP_COL_WHITE, &context); gray = GP_ColorToContextPixel(GP_COL_GRAY_DARK, &context);
- sub_context = GP_ContextSubContext(&context, 100, 100, 440, 280); + sub_context = GP_ContextSubContext(&context, NULL, 100, 100, 440, 280); GP_Fill(sub_context, gray);
timer = SDL_AddTimer(60, timer_callback, NULL);
-----------------------------------------------------------------------
Summary of changes: demos/fbshow/Makefile | 2 +- demos/fbshow/fbshow.c | 2 +- demos/grinder/Makefile | 2 +- demos/grinder/grinder.c | 4 +- include/core/GP_Context.h | 10 ++++- include/filters/GP_Filters.h | 4 +- include/filters/GP_Linear.h | 3 +- include/filters/GP_Resize.h | 31 ++++++++++++---- libs/core/GP_Context.c | 14 +++++--- libs/filters/GP_Resize.c | 82 ++++++++++++++++++++++++------------------ tests/SDL/Makefile | 2 +- tests/SDL/subcontext.c | 2 +- 12 files changed, 98 insertions(+), 60 deletions(-)
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.