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 4df6d59aba3f76c23c9f9155721db580f3b6cff1 (commit) via 1fcb3cc5e9f943f00a4a724ddbc60f641a84a93c (commit) via 9ddbb807bfcc5cf721012761d7bfc1a9073a0a75 (commit) from 4e6371664c0ae7cffb760e86403bae8bd372c555 (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/4df6d59aba3f76c23c9f9155721db580f3b6c...
commit 4df6d59aba3f76c23c9f9155721db580f3b6cff1 Author: Cyril Hrubis metan@ucw.cz Date: Wed Sep 21 15:22:25 2011 +0200
Started to work on bitmap resize filters.
diff --git a/include/filters/GP_Filters.h b/include/filters/GP_Filters.h index eb63d43..b09b5d2 100644 --- a/include/filters/GP_Filters.h +++ b/include/filters/GP_Filters.h @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -32,6 +32,8 @@ #ifndef GP_FILTERS_H #define GP_FILTERS_H
+ #include "GP_Rotate.h" +#include "GP_Resize.h"
#endif /* GP_FILTERS_H */ diff --git a/include/filters/GP_Filters.h b/include/filters/GP_Resize.h similarity index 79% copy from include/filters/GP_Filters.h copy to include/filters/GP_Resize.h index eb63d43..4a0f9b6 100644 --- a/include/filters/GP_Filters.h +++ b/include/filters/GP_Resize.h @@ -16,22 +16,21 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
/*
- GP_Context filters. + GP_Context resize.
*/
-#ifndef GP_FILTERS_H -#define GP_FILTERS_H +#ifndef GP_RESIZE_H +#define GP_RESIZE_H + +#include "core/GP_Context.h"
-#include "GP_Rotate.h" +GP_Context *GP_ScaleDown(GP_Context *src);
-#endif /* GP_FILTERS_H */ +#endif /* GP_RESIZE_H */ diff --git a/tests/SDL/ppm_test.c b/libs/filters/GP_ScaleDown.c similarity index 76% copy from tests/SDL/ppm_test.c copy to libs/filters/GP_ScaleDown.c index fce7989..2cc379b 100644 --- a/tests/SDL/ppm_test.c +++ b/libs/filters/GP_ScaleDown.c @@ -20,26 +20,35 @@ * * *****************************************************************************/
-#include <stdio.h> -#include <stdlib.h> +#include <GP_Context.h> +#include <GP_GetPutPixel.h>
-#include "GP.h" +#include <GP_Debug.h>
-int main(int argc, char *argv[]) +#include <GP_Resize.h> + +GP_Context *GP_ScaleDown(GP_Context *src) { - GP_Context *bitmap; - GP_SetDebugLevel(10); - GP_RetCode ret; + uint32_t w, h, x, y; + GP_Context *dst; + + if (src->pixel_type != GP_PIXEL_RGB888) + return NULL; + + w = src->w/2; + h = src->h/2; + + dst = GP_ContextAlloc(w, h, GP_PIXEL_RGB888); + + if (dst == NULL) + return NULL;
- if ((ret = GP_LoadPPM("ball.ppm", &bitmap))) { - fprintf(stderr, "Failed to load bitmap: %sn", GP_RetCodeName(ret)); - return 1; - } + for (y = 0; y < h; y++) + for (x = 0; x < w; x++) { + GP_Pixel pix = GP_GetPixel_Raw_24BPP(src, 2*x, 2*y);
- if ((ret = GP_SavePPM("ball2.ppm", bitmap, "b"))) { - fprintf(stderr, "Failed to load bitmap: %sn", GP_RetCodeName(ret)); - return 1; - } + GP_PutPixel_Raw_24BPP(dst, x, y, pix); + }
- return 0; + return dst; } diff --git a/libs/filters/Makefile b/libs/filters/Makefile index 7fc92d3..9e5120a 100644 --- a/libs/filters/Makefile +++ b/libs/filters/Makefile @@ -1,5 +1,6 @@ TOPDIR=../.. CSOURCES=$(shell ls *.c) LIBNAME=filters +INCLUDE=core include $(TOPDIR)/include.mk include $(TOPDIR)/lib.mk diff --git a/tests/SDL/ppm_test.c b/tests/SDL/ppm_test.c index fce7989..a0653b2 100644 --- a/tests/SDL/ppm_test.c +++ b/tests/SDL/ppm_test.c @@ -31,12 +31,14 @@ int main(int argc, char *argv[]) GP_SetDebugLevel(10); GP_RetCode ret;
- if ((ret = GP_LoadPPM("ball.ppm", &bitmap))) { + if ((ret = GP_LoadPPM(argv[1], &bitmap))) { fprintf(stderr, "Failed to load bitmap: %sn", GP_RetCodeName(ret)); return 1; }
- if ((ret = GP_SavePPM("ball2.ppm", bitmap, "b"))) { + bitmap = GP_ScaleDown(bitmap); + + if ((ret = GP_SavePPM("out.ppm", bitmap, "b"))) { fprintf(stderr, "Failed to load bitmap: %sn", GP_RetCodeName(ret)); return 1; }
http://repo.or.cz/w/gfxprim.git/commit/1fcb3cc5e9f943f00a4a724ddbc60f641a84a...
commit 1fcb3cc5e9f943f00a4a724ddbc60f641a84a93c Author: Cyril Hrubis metan@ucw.cz Date: Wed Sep 21 15:19:05 2011 +0200
Fix wrong order on PPM load.
diff --git a/libs/loaders/GP_PPM.c b/libs/loaders/GP_PPM.c index a14dbe3..de6877e 100644 --- a/libs/loaders/GP_PPM.c +++ b/libs/loaders/GP_PPM.c @@ -38,14 +38,14 @@
#include "GP_PNM.h"
-int load_binary_ppm(FILE *f, uint32_t w, uint32_t h, uint32_t depth __attribute__((unused)), +int load_binary_ppm(FILE *f, uint32_t depth __attribute__((unused)), GP_Context *res) { uint32_t x, y; int r, g, b;
- for (x = 0; x < w; x++) - for (y = 0; y < h; y++) { + for (y = 0; y < res->h; y++) + for (x = 0; x < res->w; x++) { r = fgetc(f); g = fgetc(f); b = fgetc(f); @@ -96,7 +96,7 @@ GP_RetCode GP_LoadPPM(const char *src_path, GP_Context **res) free(res); return GP_ENOIMPL; case '6': - if (load_binary_ppm(f, w, h, depth, *res)) + if (load_binary_ppm(f, depth, *res)) goto err2; break; }
http://repo.or.cz/w/gfxprim.git/commit/9ddbb807bfcc5cf721012761d7bfc1a9073a0...
commit 9ddbb807bfcc5cf721012761d7bfc1a9073a0a75 Author: Cyril Hrubis metan@ucw.cz Date: Wed Sep 21 15:14:51 2011 +0200
Add showimage test.
diff --git a/tests/SDL/Makefile b/tests/SDL/Makefile index 185a3ce..86108c0 100644 --- a/tests/SDL/Makefile +++ b/tests/SDL/Makefile @@ -6,7 +6,8 @@ INCLUDE=core gfx SDL backends LDLIBS+=-lGP -L$(TOPDIR)/build/ -lGP_SDL -lSDL
APPS=pixeltest fileview fonttest linetest randomshapetest shapetest sierpinsky- symbolstest textaligntest trianglefps input blittest subcontext ppm_test + symbolstest textaligntest trianglefps input blittest subcontext ppm_test+ showimage
include $(TOPDIR)/include.mk include $(TOPDIR)/app.mk diff --git a/tests/SDL/showimage.c b/tests/SDL/showimage.c new file mode 100644 index 0000000..1e0b356 --- /dev/null +++ b/tests/SDL/showimage.c @@ -0,0 +1,110 @@ +/***************************************************************************** + * 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 <SDL/SDL.h> + +#include "GP.h" +#include "GP_SDL.h" + +SDL_Surface *display = NULL; +GP_Context context, *bitmap; + +void event_loop(void) +{ + SDL_Event event; + + while (SDL_WaitEvent(&event) > 0) { + + switch (event.type) { + + case SDL_KEYDOWN: + switch (event.key.keysym.sym) { + case SDLK_ESCAPE: + return; + default: + break; + } + break; + case SDL_QUIT: + return; + default: + break; + } + } +} + +int main(int argc, char *argv[]) +{ + /* Bits per pixel to be set for the display surface. */ + int display_bpp = 0; + + int i; + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-16") == 0) { + display_bpp = 16; + } + else if (strcmp(argv[i], "-24") == 0) { + display_bpp = 24; + } + else if (strcmp(argv[i], "-32") == 0) { + display_bpp = 32; + } + } + + GP_SetDebugLevel(10); + + GP_RetCode ret; + + if ((ret = GP_LoadPPM(argv[1], &bitmap))) { + fprintf(stderr, "Failed to load bitmap: %sn", GP_RetCodeName(ret)); + return 1; + } + + /* Initialize SDL */ + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) { + fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError()); + return 1; + } + + /* Create a window with a software back surface */ + display = SDL_SetVideoMode(bitmap->w, bitmap->h, display_bpp, SDL_SWSURFACE); + if (display == NULL) { + fprintf(stderr, "Could not open display: %sn", SDL_GetError()); + goto fail; + } + + GP_SDL_ContextFromSurface(&context, display); + + GP_Blit_Naive(bitmap, 0, 0, bitmap->w, bitmap->h, &context, 0, 0); + SDL_Flip(display); + + event_loop(); + + SDL_Quit(); + return 0; +fail: + SDL_Quit(); + return 1; +} +
-----------------------------------------------------------------------
Summary of changes: include/filters/GP_Filters.h | 4 +- .../core/GP_Debug.c => include/filters/GP_Resize.h | 21 ++-- .../SDL/ppm_test.c => libs/filters/GP_ScaleDown.c | 41 +++++--- libs/filters/Makefile | 1 + libs/loaders/GP_PPM.c | 8 +- tests/SDL/Makefile | 3 +- tests/SDL/ppm_test.c | 6 +- tests/{common/GP_Tests.c => SDL/showimage.c} | 112 +++++++++++++------- 8 files changed, 122 insertions(+), 74 deletions(-) copy libs/core/GP_Debug.c => include/filters/GP_Resize.h (88%) copy tests/SDL/ppm_test.c => libs/filters/GP_ScaleDown.c (76%) copy tests/{common/GP_Tests.c => SDL/showimage.c} (52%)
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.