[repo.or.cz] gfxprim.git branch master updated: 4337959cd59402d875d9e155659602c1c549676b
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, master has been updated via 4337959cd59402d875d9e155659602c1c549676b (commit) via a7ef27e782e440e2c0c0e215e5180d16b4a07b84 (commit) from c7be9d64e221992b3205a65b1007653b408ba574 (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/4337959cd59402d875d9e155659602c1c5496... commit 4337959cd59402d875d9e155659602c1c549676b Author: Cyril Hrubis <metan@ucw.cz> Date: Fri Aug 10 17:16:49 2012 +0200 core,loaders: Continue on removing the GP_RetCode. diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h index 8fb84a2..f40c8a6 100644 --- a/include/core/GP_Pixel.h +++ b/include/core/GP_Pixel.h @@ -32,7 +32,6 @@ #include <stdint.h> #include "GP_Common.h" -#include "GP_RetCode.h" #include "GP_FnPerBpp.h" struct GP_Context; diff --git a/include/loaders/GP_Loaders.h b/include/loaders/GP_Loaders.h index ab0f4ef..286e372 100644 --- a/include/loaders/GP_Loaders.h +++ b/include/loaders/GP_Loaders.h @@ -34,6 +34,7 @@ #include "core/GP_Context.h" #include "core/GP_ProgressCallback.h" +#include "core/GP_RetCode.h" #include "GP_PBM.h" #include "GP_PGM.h" diff --git a/include/loaders/GP_PBM.h b/include/loaders/GP_PBM.h index 46b8c3e..82cd45b 100644 --- a/include/loaders/GP_PBM.h +++ b/include/loaders/GP_PBM.h @@ -19,17 +19,31 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * <jiri.bluebear.dluhos@gmail.com> * * * - * Copyright (C) 2009-2011 Cyril Hrubis <metan@ucw.cz> * + * Copyright (C) 2009-2012 Cyril Hrubis <metan@ucw.cz> * * * *****************************************************************************/ -#ifndef GP_PBM_H -#define GP_PBM_H +#ifndef LOADERS_GP_PBM_H +#define LOADERS_GP_PBM_H #include "core/GP_Context.h" +#include "core/GP_ProgressCallback.h" -GP_RetCode GP_LoadPBM(const char *src_path, GP_Context **res); +/* + * Loads 1-bit Grayscale image from portable bitmap format. + */ +GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback); -GP_RetCode GP_SavePBM(const char *res_path, GP_Context *src); +/* + * Save 1-bit Grayscale image into portable bitmap format. + * + * On success zero is returned, otherwise non-zero is returned and errno is + * filled: + * + * EINVAL - context pixel type was not 1 bit grayscale. + * + */ +int GP_SavePBM(const char *res_path, GP_Context *src, + GP_ProgressCallback *callback); -#endif /* GP_PBM_H */ +#endif /* LOADERS_GP_PBM_H */ diff --git a/include/loaders/GP_PGM.h b/include/loaders/GP_PGM.h index e3420f9..54fd546 100644 --- a/include/loaders/GP_PGM.h +++ b/include/loaders/GP_PGM.h @@ -27,6 +27,7 @@ #define GP_PGM_H #include "core/GP_Context.h" +#include "core/GP_RetCode.h" GP_RetCode GP_LoadPGM(const char *src_path, GP_Context **res); diff --git a/include/loaders/GP_PPM.h b/include/loaders/GP_PPM.h index 8b57e61..b7d71d7 100644 --- a/include/loaders/GP_PPM.h +++ b/include/loaders/GP_PPM.h @@ -24,6 +24,7 @@ #define GP_PPM_H #include "core/GP_Context.h" +#include "core/GP_RetCode.h" GP_RetCode GP_LoadPPM(const char *src_path, GP_Context **res); diff --git a/libs/loaders/GP_Loaders.c b/libs/loaders/GP_Loaders.c index f298983..3d19e1a 100644 --- a/libs/loaders/GP_Loaders.c +++ b/libs/loaders/GP_Loaders.c @@ -89,11 +89,9 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback) switch (src_path[len - 2]) { case 'b': case 'B': - //TODO: Fix this!!! if (src_path[len - 3] == 'p' || src_path[len - 3] == 'P') { - GP_LoadPBM(src_path, &res); - return res; + return GP_LoadPBM(src_path, callback); } break; case 'g': diff --git a/libs/loaders/GP_PBM.c b/libs/loaders/GP_PBM.c index 5b09153..ac7dc30 100644 --- a/libs/loaders/GP_PBM.c +++ b/libs/loaders/GP_PBM.c @@ -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-2012 Cyril Hrubis <metan@ucw.cz> * * * *****************************************************************************/ @@ -44,17 +44,21 @@ #include <stdio.h> #include <stdint.h> #include <inttypes.h> +#include <errno.h> #include "GP_PXMCommon.h" #include "GP_PBM.h" -GP_RetCode GP_LoadPBM(const char *src_path, GP_Context **res) +GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback) { - FILE *f = fopen(src_path, "r"); + FILE *f; + GP_Context *ret; uint32_t w, h; + f = fopen(src_path, "r"); + if (f == NULL) - return GP_EBADFILE; + return NULL; if (fgetc(f) != 'P' || fgetc(f) != '1') goto err1; @@ -62,36 +66,40 @@ GP_RetCode GP_LoadPBM(const char *src_path, GP_Context **res) if (fscanf(f, "%"PRIu32"%"PRIu32, &w, &h) < 2) goto err1; - *res = GP_ContextAlloc(w, h, GP_PIXEL_G1); + ret = GP_ContextAlloc(w, h, GP_PIXEL_G1); - if (*res == NULL) { + if (ret == NULL) { fclose(f); - return GP_ENOMEM; + errno = ENOMEM; + return NULL; } - if (GP_PXMLoad1bpp(f, *res)) + if (GP_PXMLoad1bpp(f, ret)) goto err2; fclose(f); - return GP_ESUCCESS; + return ret; err2: - free(*res); + free(ret); err1: fclose(f); - return GP_EBADFILE; + return NULL; } -GP_RetCode GP_SavePBM(const char *res_path, GP_Context *src) +int GP_SavePBM(const char *res_path, GP_Context *src, + GP_ProgressCallback *callback) { FILE *f; - if (src->pixel_type != GP_PIXEL_G1) - return GP_ENOIMPL; + if (src->pixel_type != GP_PIXEL_G1) { + errno = EINVAL; + return 1; + } f = fopen(res_path, "w"); if (f == NULL) - return GP_EBADFILE; + return 1; if (fprintf(f, "P1n%u %un# Generated by gfxprimn", (unsigned int) src->w, (unsigned int) src->h) < 2) @@ -101,10 +109,12 @@ GP_RetCode GP_SavePBM(const char *res_path, GP_Context *src) goto err; if (fclose(f)) - return GP_EBADFILE; + return 1; - return GP_ESUCCESS; + return 0; err: fclose(f); - return GP_EBADFILE; + //TODO: better errors + errno = EIO; + return 1; } diff --git a/libs/loaders/GP_PPM.c b/libs/loaders/GP_PPM.c index e84b71b..13a0fa3 100644 --- a/libs/loaders/GP_PPM.c +++ b/libs/loaders/GP_PPM.c @@ -37,6 +37,7 @@ #include <GP_GetPutPixel.h> #include "GP_PNM.h" +#include "GP_PPM.h" int load_binary_ppm(FILE *f, uint32_t depth __attribute__((unused)), GP_Context *res) diff --git a/libs/loaders/GP_PXMCommon.h b/libs/loaders/GP_PXMCommon.h index 1a3fc04..39e7d02 100644 --- a/libs/loaders/GP_PXMCommon.h +++ b/libs/loaders/GP_PXMCommon.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-2012 Cyril Hrubis <metan@ucw.cz> * * * *****************************************************************************/ @@ -34,6 +34,7 @@ #include <stdio.h> #include "core/GP_Core.h" +#include "core/GP_RetCode.h" /* * Save context to ascii file. diff --git a/pylib/gfxprim/core/core.i b/pylib/gfxprim/core/core.i index bfd4649..67777dd 100644 --- a/pylib/gfxprim/core/core.i +++ b/pylib/gfxprim/core/core.i @@ -20,7 +20,6 @@ ERROR_ON_NULL(GP_GetCounter); %include "GP_GetSetBits.h" %include "GP_Transform.h" %include "GP_ProgressCallback.h" -%include "GP_RetCode.h" /* http://repo.or.cz/w/gfxprim.git/commit/a7ef27e782e440e2c0c0e215e5180d16b4a07... commit a7ef27e782e440e2c0c0e215e5180d16b4a07b84 Author: Cyril Hrubis <metan@ucw.cz> Date: Fri Aug 10 14:33:55 2012 +0200 tests: Remove obsolete font test. diff --git a/tests/text/font.test.c b/tests/text/font.test.c deleted file mode 100644 index 7775ab8..0000000 --- a/tests/text/font.test.c +++ /dev/null @@ -1,58 +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) 2011 Tomas Gavenciak <gavento@ucw.cz> * - * * - *****************************************************************************/ - -/* - - Font load/save tests. - - */ - -#include <stdlib.h> -#include <string.h> -#include <GP.h> - -#include "GP_Tests.h" - -#define FONT_FILE "test_font.tmp" - -GP_SUITE(font) - -GP_TEST(load_save) -{ - GP_Font *loaded; - int dd_size, ld_size; - - fail_unless(GP_FontSave(&GP_default_console_font, FONT_FILE) == GP_ESUCCESS); - fail_unless(GP_FontLoad(&loaded, FONT_FILE) == GP_ESUCCESS); - - dd_size = GP_GetFontDataSize(&GP_default_console_font); - ld_size = GP_GetFontDataSize(loaded); - - fail_unless(dd_size == ld_size); - - fail_unless(memcmp(GP_default_console_font.data, loaded->data, dd_size) == 0); - - /* cleanup */ - fail_unless(unlink(FONT_FILE) == 0); -} -GP_ENDTEST - ----------------------------------------------------------------------- Summary of changes: include/core/GP_Pixel.h | 1 - include/loaders/GP_Loaders.h | 1 + include/loaders/GP_PBM.h | 26 ++++++++++++++---- include/loaders/GP_PGM.h | 1 + include/loaders/GP_PPM.h | 1 + libs/loaders/GP_Loaders.c | 4 +-- libs/loaders/GP_PBM.c | 46 ++++++++++++++++++++------------- libs/loaders/GP_PPM.c | 1 + libs/loaders/GP_PXMCommon.h | 3 +- pylib/gfxprim/core/core.i | 1 - tests/text/font.test.c | 58 ------------------------------------------ 11 files changed, 55 insertions(+), 88 deletions(-) delete mode 100644 tests/text/font.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. -- gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
participants (1)
-
metan