Gfxprim
Threads by month
- ----- 2026 -----
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
September 2013
- 1 participants
- 14 discussions
18 Sep '13
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 8d2ecb32294836112e300b456b2d620f1b033b31 (commit)
via 68bf70ebf964f8c18fd9c6236bed90635bba33aa (commit)
via 7bf591aaf8c469582e3f0ad66a09f4de9d9141c7 (commit)
via 3d75c6b108284ae15bd94f5741023d92b87225b9 (commit)
from 2af0fde79674ad30155948d78316c5dfa3df83c4 (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/8d2ecb32294836112e300b456b2d620f1b03…
commit 8d2ecb32294836112e300b456b2d620f1b033b31
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Sep 18 00:14:24 2013 +0200
text: fonts: Add C64 like monospace font.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/demos/c_simple/fileview.c b/demos/c_simple/fileview.c
index 5091ffa..f0608c7 100644
--- a/demos/c_simple/fileview.c
+++ b/demos/c_simple/fileview.c
@@ -72,6 +72,9 @@ void redraw_screen(void)
style.font = GP_FontTiny;
break;
case 4:
+ style.font = GP_FontC64;
+ break;
+ case 5:
style.font = font;
break;
}
@@ -133,9 +136,9 @@ void event_loop(void)
switch (ev.val.key.key) {
case GP_KEY_SPACE:
if (font)
- font_flag = (font_flag + 1) % 5;
+ font_flag = (font_flag + 1) % 6;
else
- font_flag = (font_flag + 1) % 4;
+ font_flag = (font_flag + 1) % 5;
redraw_screen();
GP_BackendFlip(backend);
diff --git a/demos/c_simple/fonttest.c b/demos/c_simple/fonttest.c
index 4c35110..2ecfa05 100644
--- a/demos/c_simple/fonttest.c
+++ b/demos/c_simple/fonttest.c
@@ -119,6 +119,9 @@ void redraw_screen(void)
style.font = GP_FontTinyMono;
break;
case 4:
+ style.font = GP_FontC64;
+ break;
+ case 5:
style.font = font;
break;
}
@@ -201,9 +204,9 @@ void event_loop(void)
switch (ev.val.key.key) {
case GP_KEY_SPACE:
if (font)
- font_flag = (font_flag + 1) % 5;
+ font_flag = (font_flag + 1) % 6;
else
- font_flag = (font_flag + 1) % 4;
+ font_flag = (font_flag + 1) % 5;
redraw_screen();
GP_BackendFlip(win);
diff --git a/include/text/GP_Fonts.h b/include/text/GP_Fonts.h
index d05dfc3..3a54da3 100644
--- a/include/text/GP_Fonts.h
+++ b/include/text/GP_Fonts.h
@@ -39,4 +39,9 @@ extern const GP_FontFace *GP_FontTinyMono;
*/
extern const GP_FontFace *GP_FontTiny;
+/*
+ * Monospace 8x8 Commodore 64 like font.
+ */
+extern const GP_FontFace *GP_FontC64;
+
#endif /* TEXT_GP_FONTS_H */
diff --git a/libs/text/GP_FontC64.c b/libs/text/GP_FontC64.c
new file mode 100644
index 0000000..4d476de
--- /dev/null
+++ b/libs/text/GP_FontC64.c
@@ -0,0 +1,231 @@
+/*****************************************************************************
+ * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include "GP_Font.h"
+
+static int8_t c64_glyphs[] = {
+ /* ' ' */ 8, 7, 0, 7, 8,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ /* '!' */ 8, 7, 0, 7, 8,
+ 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x30,
+ /* '"' */ 8, 7, 0, 7, 8,
+ 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0x00, 0x00,
+ /* '#' */ 8, 7, -1, 7, 8,
+ 0x66, 0x66, 0xff, 0x66, 0xff, 0x66, 0x66,
+ /* '$' */ 8, 7, 0, 7, 8,
+ 0x30, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x30,
+ /* '%' */ 8, 7, 0, 7, 8,
+ 0xc4, 0xcc, 0x18, 0x30, 0x60, 0xcc, 0x8c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8, 7, 0, 7, 8,
+ 0x00, 0x00, 0xf8, 0xcc, 0xc0, 0xc0, 0xc0,
+ /* 's' */ 8, 7, 0, 7, 8,
+ 0x00, 0x00, 0x7c, 0xc0, 0x78, 0x0c, 0xf8,
+ /* 't' */ 8, 7, 0, 7, 8,
+ 0x00, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x1c,
+ /* 'u' */ 8, 7, 0, 7, 8,
+ 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x7c,
+ /* 'v' */ 8, 7, 0, 7, 8,
+ 0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30,
+ /* 'w' */ 8, 7, 0, 7, 8,
+ 0x00, 0x00, 0xc6, 0xd6, 0xfe, 0x7c, 0x6c,
+ /* 'x' */ 8, 7, 0, 7, 8,
+ 0x00, 0x00, 0xcc, 0x78, 0x30, 0x78, 0xcc,
+ /* 'y' */ 8, 7, 0, 6, 8,
+ 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x18, 0xf0,
+ /* 'z' */ 8, 7, 0, 7, 8,
+ 0x00, 0x00, 0xfc, 0x18, 0x30, 0x60, 0xfc,
+ /* '{' */ 8, 7, 0, 7, 8,
+ 0x30, 0x60, 0x60, 0xc0, 0x60, 0x60, 0x30,
+ /* '|' */ 8, 7, 0, 7, 8,
+ 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
+ /* '}' */ 8, 7, 0, 7, 8,
+ 0x30, 0x18, 0x18, 0x0c, 0x18, 0x18, 0x30,
+ /* '~' */ 8, 7, 0, 7, 8,
+ 0x6c, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+static struct GP_FontFace c64 = {
+ .family_name = "C64",
+ .style_name = "Mono",
+ .charset = GP_CHARSET_7BIT,
+ .ascend = 7,
+ .descend = 2,
+ .max_glyph_width = 8,
+ .max_glyph_advance = 9,
+ .glyph_bitmap_format = GP_FONT_BITMAP_1BPP,
+ .glyphs = c64_glyphs,
+ .glyph_offsets = {12},
+};
+
+const struct GP_FontFace *GP_FontC64 = &c64;
http://repo.or.cz/w/gfxprim.git/commit/68bf70ebf964f8c18fd9c6236bed90635bba…
commit 68bf70ebf964f8c18fd9c6236bed90635bba33aa
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Sep 18 00:11:24 2013 +0200
libs: text: Small enhancements for default monospace font.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/text/GP_DefaultFont.c b/libs/text/GP_DefaultFont.c
index 52b6608..d67fa99 100644
--- a/libs/text/GP_DefaultFont.c
+++ b/libs/text/GP_DefaultFont.c
@@ -19,7 +19,7 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
@@ -58,25 +58,25 @@ static int8_t default_console_glyphs[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
/* '/' */ 7, 11, 0, 9, 8,
0x00, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x00, 0x00,
- /* '0' */ 7, 11, 0, 9, 8,
+ /* '0' */ 7, 11, 1, 9, 8,
0x78, 0x84, 0x8c, 0x94, 0xb4, 0xa4, 0xc4, 0x84, 0x78, 0x00, 0x00,
- /* '1' */ 7, 11, 0, 9, 8,
+ /* '1' */ 7, 11, 1, 9, 8,
0x10, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00,
- /* '2' */ 7, 11, 0, 9, 8,
+ /* '2' */ 7, 11, 1, 9, 8,
0x78, 0x84, 0x84, 0x04, 0x18, 0x60, 0x80, 0x80, 0xfc, 0x00, 0x00,
- /* '3' */ 7, 11, 0, 9, 8,
+ /* '3' */ 7, 11, 1, 9, 8,
0x78, 0x84, 0x84, 0x04, 0x18, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00,
- /* '4' */ 7, 11, 0, 9, 8,
+ /* '4' */ 7, 11, 1, 9, 8,
0x18, 0x28, 0x48, 0x48, 0x88, 0xfc, 0x08, 0x08, 0x08, 0x00, 0x00,
- /* '5' */ 7, 11, 0, 9, 8,
+ /* '5' */ 7, 11, 1, 9, 8,
0xfc, 0x80, 0x80, 0xf8, 0x04, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00,
- /* '6' */ 7, 11, 0, 9, 8,
+ /* '6' */ 7, 11, 1, 9, 8,
0x78, 0x80, 0x80, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00,
- /* '7' */ 7, 11, 0, 9, 8,
+ /* '7' */ 7, 11, 1, 9, 8,
0xfc, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00,
- /* '8' */ 7, 11, 0, 9, 8,
+ /* '8' */ 7, 11, 1, 9, 8,
0x78, 0x84, 0x84, 0x84, 0x78, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00,
- /* '9' */ 7, 11, 0, 9, 8,
+ /* '9' */ 7, 11, 1, 9, 8,
0x78, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x04, 0x04, 0x78, 0x00, 0x00,
/* ':' */ 7, 11, 0, 9, 8,
0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00,
@@ -100,7 +100,7 @@ static int8_t default_console_glyphs[] = {
0x7c, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x82, 0x7c, 0x00, 0x00,
/* 'D' */ 7, 11, 0, 9, 8,
0xf8, 0x84, 0x82, 0x82, 0x82, 0x82, 0x82, 0x84, 0xf8, 0x00, 0x00,
- /* 'E' */ 7, 11, 0, 9, 8,
+ /* 'E' */ 7, 11, 0, 9, 8,
0xfe, 0x80, 0x80, 0x80, 0xfc, 0x80, 0x80, 0x80, 0xfe, 0x00, 0x00,
/* 'F' */ 7, 11, 0, 9, 8,
0xfe, 0x80, 0x80, 0x80, 0xf8, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00,
@@ -149,7 +149,7 @@ static int8_t default_console_glyphs[] = {
/* '' */ 7, 11, 0, 9, 8,
0x00, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x00, 0x00,
/* ']' */ 7, 11, 0, 9, 8,
- 0x1e, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x1e, 0x00, 0x00,
+ 0x3c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x3c, 0x00, 0x00,
/* '^' */ 7, 11, 0, 9, 8,
0x08, 0x14, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* '_' */ 7, 11, 0, 9, 8,
http://repo.or.cz/w/gfxprim.git/commit/7bf591aaf8c469582e3f0ad66a09f4de9d91…
commit 7bf591aaf8c469582e3f0ad66a09f4de9d9141c7
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Sep 18 00:02:59 2013 +0200
loaders: ZIP: Load PNG images from stored records
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c
index 83fe617..794d794 100644
--- a/libs/loaders/GP_ZIP.c
+++ b/libs/loaders/GP_ZIP.c
@@ -343,8 +343,15 @@ static GP_Context *zip_next_file(FILE *f, GP_ProgressCallback *callback)
if (header.uncomp_size == 0)
goto out;
+ off_t cur_off = ftell(f);
+
ret = GP_ReadJPG(f, callback);
+ if (!ret) {
+ fseek(f, cur_off, SEEK_SET);
+ ret = GP_ReadPNG(f, callback);
+ }
+
goto out;
break;
case COMPRESS_DEFLATE:
http://repo.or.cz/w/gfxprim.git/commit/3d75c6b108284ae15bd94f5741023d92b872…
commit 3d75c6b108284ae15bd94f5741023d92b87225b9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Sep 15 20:58:10 2013 +0200
core: GP_Pixel: Fix segfault.
This fixes segfault in GP_PixelRGBMatch() and GP_PixelRGBLookup() when
currently matched pixel in table is not RGB (by skipping all pixels that
aren't).
NOTE: This was found on paletted framebuffer where (for obvious reasons) correct
pixel wasn't found and the framebuffer backend initialization segfaulted
while trying to match pixel type (on GP_PIXEL_G8 on NULL dereference).
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/core/GP_Pixel.c b/libs/core/GP_Pixel.c
index 4fb13fb..6bb59ea 100644
--- a/libs/core/GP_Pixel.c
+++ b/libs/core/GP_Pixel.c
@@ -19,14 +19,14 @@
* Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos *
* <jiri.bluebear.dluhos(a)gmail.com> *
* *
- * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2013 Cyril Hrubis <metan(a)ucw.cz> *
* *
*****************************************************************************/
#include <string.h>
#include "GP_Debug.h"
-#include "GP_Pixel.h"
+#include "GP_Pixel.h"
static const GP_PixelTypeChannel *
get_channel(const GP_PixelTypeDescription *desc, const char *name)
@@ -78,9 +78,11 @@ GP_PixelType GP_PixelRGBMatch(GP_Pixel rmask, GP_Pixel gmask,
for (i = 0; i < GP_PIXEL_MAX; i++) {
int res;
-
const GP_PixelTypeChannel *r, *g, *b, *a;
+ if (!GP_PixelHasFlags(i, GP_PIXEL_IS_RGB))
+ continue;
+
if (GP_PixelTypes[i].size != bits_per_pixel)
continue;
@@ -133,6 +135,9 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff,
for (i = 0; i < GP_PIXEL_MAX; i++) {
const GP_PixelTypeChannel *r, *g, *b, *a;
+ if (!GP_PixelHasFlags(i, GP_PIXEL_IS_RGB))
+ continue;
+
if (GP_PixelTypes[i].size != bits_per_pixel)
continue;
-----------------------------------------------------------------------
Summary of changes:
demos/c_simple/fileview.c | 7 +-
demos/c_simple/fonttest.c | 7 +-
include/text/GP_Fonts.h | 5 +
libs/core/GP_Pixel.c | 11 ++-
libs/loaders/GP_ZIP.c | 7 ++
libs/text/GP_DefaultFont.c | 26 +++---
libs/text/GP_FontC64.c | 231 ++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 274 insertions(+), 20 deletions(-)
create mode 100644 libs/text/GP_FontC64.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
12 Sep '13
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 2af0fde79674ad30155948d78316c5dfa3df83c4 (commit)
via 28e75fadc2c5e65e41fdbba3c868739a9c6b74cc (commit)
via e13ec4c6eb8e16ba3d44dfe6f0ff717c73a90552 (commit)
from 17fe2ed28b93515ca3cf486e1af6aff088a7d8bd (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/2af0fde79674ad30155948d78316c5dfa3df…
commit 2af0fde79674ad30155948d78316c5dfa3df83c4
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 12 22:48:17 2013 +0200
tests: core: GetPutPixel: Fix warnings.
Fix "This decimal constant is unsigned only in ISO C90" warnings.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/core/GetPutPixel.gen.c.t b/tests/core/GetPutPixel.gen.c.t
index a843509..1e8bccd 100644
--- a/tests/core/GetPutPixel.gen.c.t
+++ b/tests/core/GetPutPixel.gen.c.t
@@ -55,7 +55,7 @@ static int check_filled(GP_Context *c)
tst_msg("Pixels different %i %i", x, y);
return 1;
}
-
+
return 0;
}
@@ -85,16 +85,16 @@ static int GetPutPixel_{{ pt.name }}(void)
return TST_UNTESTED;
}
- if (try_pattern(c, 0x55555555 & {{ 2 ** pt.pixelsize.size - 1}}))
+ if (try_pattern(c, 0x55555555 & {{ 2 ** pt.pixelsize.size - 1}}U))
err++;
-
- if (try_pattern(c, 0xaaaaaaaa & {{ 2 ** pt.pixelsize.size - 1}}))
+
+ if (try_pattern(c, 0xaaaaaaaa & {{ 2 ** pt.pixelsize.size - 1}}U))
err++;
-
- if (try_pattern(c, 0x0f0f0f0f & {{ 2 ** pt.pixelsize.size - 1}}))
+
+ if (try_pattern(c, 0x0f0f0f0f & {{ 2 ** pt.pixelsize.size - 1}}U))
err++;
-
- if (try_pattern(c, 0xf0f0f0f0 & {{ 2 ** pt.pixelsize.size - 1}}))
+
+ if (try_pattern(c, 0xf0f0f0f0 & {{ 2 ** pt.pixelsize.size - 1}}U))
err++;
GP_ContextFree(c);
@@ -112,7 +112,7 @@ static int GetPutPixel_{{ pt.name }}(void)
static int GetPutPixel_Clipping_{{ pt.name }}(void)
{
GP_Context *c;
-
+
c = GP_ContextAlloc(100, 100, GP_PIXEL_{{ pt.name }});
if (c == NULL) {
@@ -129,7 +129,7 @@ static int GetPutPixel_Clipping_{{ pt.name }}(void)
for (y = -1000; y < 200; y++) {
if (x > 0 && x < 100 && y > 0 && y < 100)
continue;
-
+
/* Must be no-op */
GP_PutPixel(c, x, y, 0);
@@ -141,9 +141,9 @@ static int GetPutPixel_Clipping_{{ pt.name }}(void)
}
}
}
-
+
GP_ContextFree(c);
-
+
if (err)
return TST_FAILED;
@@ -157,18 +157,18 @@ const struct tst_suite tst_suite = {
.tests = {
%% for pt in pixeltypes
%% if not pt.is_unknown()
- {.name = "GetPutPixel {{ pt.name }}",
+ {.name = "GetPutPixel {{ pt.name }}",
.tst_fn = GetPutPixel_{{ pt.name }}},
%% endif
%% endfor
%% for pt in pixeltypes
%% if not pt.is_unknown()
- {.name = "GetPutPixel Clipping {{ pt.name }}",
+ {.name = "GetPutPixel Clipping {{ pt.name }}",
.tst_fn = GetPutPixel_Clipping_{{ pt.name }}},
%% endif
%% endfor
-
+
{.name = NULL}
}
};
http://repo.or.cz/w/gfxprim.git/commit/28e75fadc2c5e65e41fdbba3c868739a9c6b…
commit 28e75fadc2c5e65e41fdbba3c868739a9c6b74cc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Sep 11 19:28:51 2013 +0200
tests: framework: Use $(CC) instead of gcc
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/tests/framework/Makefile b/tests/framework/Makefile
index bc04fc1..f7ceb2e 100644
--- a/tests/framework/Makefile
+++ b/tests/framework/Makefile
@@ -15,10 +15,10 @@ APPS=test
ALL+=libtst_preload.so libtst.a
libtst_preload.so: tst_preload.o tst_alloc_barriers.o tst_preload_FILE.o
- gcc -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@
+ $(CC) -Wl,-soname -Wl,tst_preload.so --shared -ldl -fPIC $^ -o $@
libtst.a: tst_suite.o tst_job.o tst_msg.o tst_log.o tst_main.o tst_timespec.o
- ar rcs $@ $^
+ $(AR) rcs $@ $^
CLEAN+=libtst_preload.so libtst.a log.json
http://repo.or.cz/w/gfxprim.git/commit/e13ec4c6eb8e16ba3d44dfe6f0ff717c73a9…
commit e13ec4c6eb8e16ba3d44dfe6f0ff717c73a90552
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Wed Sep 11 19:19:57 2013 +0200
build: Makefile: include config.mk
So that CC and friends are set correctly.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/Makefile b/build/Makefile
index d21da7a..075c19d 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -2,7 +2,9 @@ LIB_OBJECTS=$(shell ./get_objs.sh)
.SUFFIXES:
-include ../libver.mk
+TOPDIR=../
+include $(TOPDIR)/config.mk
+include $(TOPDIR)/libver.mk
LIB_NAME=libGP
-----------------------------------------------------------------------
Summary of changes:
build/Makefile | 4 +++-
tests/core/GetPutPixel.gen.c.t | 30 +++++++++++++++---------------
tests/framework/Makefile | 4 ++--
3 files changed, 20 insertions(+), 18 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
08 Sep '13
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 17fe2ed28b93515ca3cf486e1af6aff088a7d8bd (commit)
via 023357e5ae4971313f9a579e5b426039c0e5fb46 (commit)
from 62f3b9db48fe5159efdfd4dd01d51242d37e4375 (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/17fe2ed28b93515ca3cf486e1af6aff088a7…
commit 17fe2ed28b93515ca3cf486e1af6aff088a7d8bd
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Sep 8 22:53:35 2013 +0200
loaders: Add LineConvert.
Adds LineConvert API for trivial pixel conversions
(i.e. RGB888 to BGR888 and so).
Make use of it in BMP and JPG loaders.
(more to come)
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/build/syms/Loaders_symbols.txt b/build/syms/Loaders_symbols.txt
index 9a933e7..e424e98 100644
--- a/build/syms/Loaders_symbols.txt
+++ b/build/syms/Loaders_symbols.txt
@@ -91,3 +91,6 @@ GP_ContainerSeek
GP_MatchZip
GP_OpenZip
+
+GP_LineConvertible
+GP_LineConvertGet
diff --git a/include/loaders/GP_LineConvert.h b/include/loaders/GP_LineConvert.h
new file mode 100644
index 0000000..c880aad
--- /dev/null
+++ b/include/loaders/GP_LineConvert.h
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+/*
+
+ Converts a continuous line of pixels from buffer A to a line of pixels in
+ buffer B.
+
+ Supports only trivial conversions i.e. RGB888 to BGR888 and G1_LE to G1_BE,
+ etc.
+
+ The code is mainly used in image loaders when saving image from memory buffer
+ that has exactly same channels (in size and names) but placed differently in
+ buffer of pixel.
+
+ */
+
+
+#ifndef LOADERS_LINE_CONVERT_H
+#define LOADERS_LINE_CONVERT_H
+
+#include "core/GP_Pixel.h"
+
+typedef void (*GP_LineConvert)(const uint8_t *in, uint8_t *out, unsigned int len);
+
+/*
+ * The out array is terminated by GP_PIXEL_UNKNOWN.
+ *
+ * Returns output pixel type given input pixel type and table of posible output
+ * types.
+ *
+ * Returns GP_PIXEL_UNKNOWN if no conversion is posible.
+ */
+GP_PixelType GP_LineConvertible(GP_PixelType in, GP_PixelType out[]);
+
+/*
+ * Returns pointer to conversion function or NULL if there is none.
+ */
+GP_LineConvert GP_LineConvertGet(GP_PixelType in, GP_PixelType out);
+
+#endif /* LOADERS_LINE_CONVERT_H */
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c
index 430e9d7..b6f3a50 100644
--- a/libs/loaders/GP_BMP.c
+++ b/libs/loaders/GP_BMP.c
@@ -41,6 +41,7 @@
#include "core/GP_GetPutPixel.h"
#include "loaders/GP_ByteUtils.h"
+#include "loaders/GP_LineConvert.h"
#include "loaders/GP_BMP.h"
#define BMP_HEADER_OFFSET 0x0a /* info header offset - 4 bytes */
@@ -51,7 +52,6 @@
#define BUF_TO_2(buf, off) (buf[off] + (buf[off+1]<<8))
-
struct bitmap_info_header {
/*
* Offset to image data.
@@ -771,17 +771,27 @@ static int bmp_write_header(struct bitmap_info_header *header, FILE *f)
return 0;
}
+static GP_PixelType out_pixel_types[] = {
+ GP_PIXEL_RGB888,
+ GP_PIXEL_UNKNOWN,
+};
+
static int bmp_fill_header(const GP_Context *src, struct bitmap_info_header *header)
{
+ GP_PixelType out_pix;
+
switch (src->pixel_type) {
case GP_PIXEL_RGB888:
- case GP_PIXEL_BGR888:
header->bpp = 24;
break;
default:
- GP_DEBUG(1, "Unsupported pixel type (%s)",
- GP_PixelTypeName(src->pixel_type));
- return ENOSYS;
+ out_pix = GP_LineConvertible(src->pixel_type, out_pixel_types);
+
+ if (out_pix == GP_PIXEL_UNKNOWN) {
+ GP_DEBUG(1, "Unsupported pixel type %s",
+ GP_PixelTypeName(src->pixel_type));
+ return ENOSYS;
+ }
}
header->w = src->w;
@@ -803,9 +813,12 @@ static int bmp_fill_header(const GP_Context *src, struct bitmap_info_header *hea
static int bmp_write_data(FILE *f, const GP_Context *src, GP_ProgressCallback *callback)
{
int y;
- uint32_t padd_len = 0, x;
+ uint32_t padd_len = 0;
char padd[3] = {0};
uint8_t tmp[3 * src->w];
+ GP_LineConvert Convert;
+
+ Convert = GP_LineConvertGet(src->pixel_type, GP_PIXEL_RGB888);
if (src->bytes_per_row%4)
padd_len = 4 - src->bytes_per_row%4;
@@ -813,14 +826,8 @@ static int bmp_write_data(FILE *f, const GP_Context *src, GP_ProgressCallback *c
for (y = src->h - 1; y >= 0; y--) {
void *row = GP_PIXEL_ADDR(src, 0, y);
- if (src->pixel_type == GP_PIXEL_BGR888) {
- memcpy(tmp, row, 3 * src->w);
-
- for (x = 0; x < src->w; x++) {
- uint8_t *pix = tmp + 3 * x;
- GP_SWAP(pix[0], pix[2]);
- }
-
+ if (src->pixel_type != GP_PIXEL_RGB888) {
+ Convert(row, tmp, src->w);
row = tmp;
}
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index e48c864..3b52821 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -37,7 +37,8 @@
#include "../../config.h"
#include "core/GP_Debug.h"
-#include "GP_JPG.h"
+#include "loaders/GP_LineConvert.h"
+#include "loaders/GP_JPG.h"
#ifdef HAVE_JPEG
@@ -345,22 +346,21 @@ int GP_LoadJPGMetaData(const char *src_path, GP_MetaData *data)
return ret;
}
-static int save_rgb888(struct jpeg_compress_struct *cinfo,
- const GP_Context *src,
- GP_ProgressCallback *callback)
+static int save_convert(struct jpeg_compress_struct *cinfo,
+ const GP_Context *src,
+ GP_PixelType out_pix,
+ GP_ProgressCallback *callback)
{
- unsigned int x;
- uint8_t tmp[3 * src->w];
+ uint8_t tmp[(src->w * GP_PixelSize(out_pix)) / 8 + 1];
+ GP_LineConvert Convert;
+
+ Convert = GP_LineConvertGet(src->pixel_type, out_pix);
while (cinfo->next_scanline < cinfo->image_height) {
uint32_t y = cinfo->next_scanline;
+ void *in = GP_PIXEL_ADDR(src, 0, y);
- memcpy(tmp, GP_PIXEL_ADDR(src, 0, y), 3 * src->w);
-
- for (x = 0; x < src->w; x++) {
- uint8_t *pix = tmp + 3 * x;
- GP_SWAP(pix[0], pix[2]);
- }
+ Convert(in, tmp, src->w);
JSAMPROW row = (void*)tmp;
jpeg_write_scanlines(cinfo, &row, 1);
@@ -393,26 +393,37 @@ static int save(struct jpeg_compress_struct *cinfo,
return 0;
}
+static GP_PixelType out_pixel_types[] = {
+ GP_PIXEL_BGR888,
+ GP_PIXEL_G8,
+ GP_PIXEL_UNKNOWN
+};
+
int GP_SaveJPG(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
FILE *f;
struct jpeg_compress_struct cinfo;
+ GP_PixelType out_pix;
struct my_jpg_err my_err;
int err;
GP_DEBUG(1, "Saving JPG Image '%s'", dst_path);
switch (src->pixel_type) {
- case GP_PIXEL_RGB888:
case GP_PIXEL_BGR888:
case GP_PIXEL_G8:
+ out_pix = src->pixel_type;
break;
default:
- GP_DEBUG(1, "Unsupported pixel type %s",
- GP_PixelTypeName(src->pixel_type));
- errno = ENOSYS;
- return 1;
+ out_pix = GP_LineConvertible(src->pixel_type, out_pixel_types);
+
+ if (out_pix == GP_PIXEL_UNKNOWN) {
+ GP_DEBUG(1, "Unsupported pixel type %s",
+ GP_PixelTypeName(src->pixel_type));
+ errno = ENOSYS;
+ return 1;
+ }
}
f = fopen(dst_path, "wb");
@@ -440,8 +451,7 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
cinfo.image_width = src->w;
cinfo.image_height = src->h;
- switch (src->pixel_type) {
- case GP_PIXEL_RGB888:
+ switch (out_pix) {
case GP_PIXEL_BGR888:
cinfo.input_components = 3;
cinfo.in_color_space = JCS_RGB;
@@ -458,13 +468,10 @@ int GP_SaveJPG(const GP_Context *src, const char *dst_path,
jpeg_start_compress(&cinfo, TRUE);
- switch (src->pixel_type) {
- case GP_PIXEL_RGB888:
- err = save_rgb888(&cinfo, src, callback);
- break;
- default:
+ if (out_pix != src->pixel_type)
+ err = save_convert(&cinfo, src, out_pix, callback);
+ else
err = save(&cinfo, src, callback);
- }
if (err)
goto err3;
diff --git a/libs/loaders/GP_LineConvert.c b/libs/loaders/GP_LineConvert.c
new file mode 100644
index 0000000..9f3b70c
--- /dev/null
+++ b/libs/loaders/GP_LineConvert.c
@@ -0,0 +1,85 @@
+/*****************************************************************************
+ * 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-2013 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include "core/GP_Debug.h"
+#include "GP_LineConvert.h"
+
+static void xyz888_to_zyx888(const uint8_t *inbuf, uint8_t *outbuf, unsigned int len)
+{
+ unsigned int i;
+
+ for (i = 0; i < len; i++) {
+ outbuf[2] = inbuf[0];
+ outbuf[0] = inbuf[2];
+ outbuf[1] = inbuf[1];
+
+ outbuf+=3;
+ inbuf+=3;
+ }
+}
+
+GP_LineConvert GP_LineConvertGet(GP_PixelType in, GP_PixelType out)
+{
+ switch (in) {
+ case GP_PIXEL_RGB888:
+ switch (out) {
+ case GP_PIXEL_BGR888:
+ return xyz888_to_zyx888;
+ break;
+ default:
+ break;
+ }
+ break;
+ case GP_PIXEL_BGR888:
+ switch (out) {
+ case GP_PIXEL_RGB888:
+ return xyz888_to_zyx888;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+
+ return NULL;
+}
+
+GP_PixelType GP_LineConvertible(GP_PixelType in, GP_PixelType out[])
+{
+ unsigned int i;
+
+ GP_DEBUG(1, "Trying to find conversion for %s", GP_PixelTypeName(in));
+
+ for (i = 0; out[i] != GP_PIXEL_UNKNOWN; i++) {
+ if (GP_LineConvertGet(in, out[i])) {
+ GP_DEBUG(1, "Found %s -> %s", GP_PixelTypeName(in),
+ GP_PixelTypeName(out[i]));
+ return out[i];
+ }
+ }
+
+ GP_DEBUG(1, "Not found");
+
+ return GP_PIXEL_UNKNOWN;
+}
http://repo.or.cz/w/gfxprim.git/commit/023357e5ae4971313f9a579e5b426039c0e5…
commit 023357e5ae4971313f9a579e5b426039c0e5fb46
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Sep 8 18:27:15 2013 +0200
backends: Linux FB: Declare local function as static.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/backends/GP_LinuxFB.c b/libs/backends/GP_LinuxFB.c
index 2849a7a..c14195f 100644
--- a/libs/backends/GP_LinuxFB.c
+++ b/libs/backends/GP_LinuxFB.c
@@ -202,7 +202,7 @@ static int allocate_console(struct fb_priv *fb, int flags)
return 0;
}
-void free_console(struct fb_priv *fb)
+static void free_console(struct fb_priv *fb)
{
/* restore blinking cursor */
if (ioctl(fb->con_fd, KDSETMODE, KD_TEXT))
-----------------------------------------------------------------------
Summary of changes:
build/syms/Loaders_symbols.txt | 3 +
.../{gfx/GP_HLineAA.h => loaders/GP_LineConvert.h} | 39 +++++----
libs/backends/GP_LinuxFB.c | 2 +-
libs/loaders/GP_BMP.c | 35 +++++---
libs/loaders/GP_JPG.c | 57 +++++++------
.../loaders/GP_LineConvert.c | 90 ++++++++++----------
6 files changed, 125 insertions(+), 101 deletions(-)
copy include/{gfx/GP_HLineAA.h => loaders/GP_LineConvert.h} (63%)
copy demos/c_simple/gaussian_noise.c => libs/loaders/GP_LineConvert.c (61%)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
02 Sep '13
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 62f3b9db48fe5159efdfd4dd01d51242d37e4375 (commit)
via 3f78c26fead7c7c20057735c752c841f754010a9 (commit)
via 5f3a2c0ec123ae0b6db9994fa948b1b032204acc (commit)
from cb3020fdd8ac170c98633ace520842f3c7d72896 (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/62f3b9db48fe5159efdfd4dd01d51242d37e…
commit 62f3b9db48fe5159efdfd4dd01d51242d37e4375
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Sep 2 21:21:08 2013 +0200
loaders: ZIP: Silence unused warning.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_ZIP.c b/libs/loaders/GP_ZIP.c
index 42d08d5..83fe617 100644
--- a/libs/loaders/GP_ZIP.c
+++ b/libs/loaders/GP_ZIP.c
@@ -709,6 +709,7 @@ err0:
GP_Container *GP_OpenZip(const char *path)
{
+ (void) path;
GP_FATAL("zlib support not compiled in");
errno = ENOSYS;
return NULL;
http://repo.or.cz/w/gfxprim.git/commit/3f78c26fead7c7c20057735c752c841f7540…
commit 3f78c26fead7c7c20057735c752c841f754010a9
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Mon Sep 2 23:00:40 2013 +0200
backends: Linux FB: Fix error codepath.
Correctly uninitialize keyboard and console on failure.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/backends/GP_LinuxFB.c b/libs/backends/GP_LinuxFB.c
index 8e96684..2849a7a 100644
--- a/libs/backends/GP_LinuxFB.c
+++ b/libs/backends/GP_LinuxFB.c
@@ -202,6 +202,19 @@ static int allocate_console(struct fb_priv *fb, int flags)
return 0;
}
+void free_console(struct fb_priv *fb)
+{
+ /* restore blinking cursor */
+ if (ioctl(fb->con_fd, KDSETMODE, KD_TEXT))
+ GP_WARN("Failed to ioctl KDSETMODE (restore KDMODE)");
+
+ /* switch back console */
+ if (fb->last_con_nr != -1)
+ ioctl(fb->con_fd, VT_ACTIVATE, fb->last_con_nr);
+
+ close(fb->con_fd);
+}
+
/* Backend API callbacks */
static void fb_poll(GP_Backend *self)
@@ -239,19 +252,11 @@ static void fb_exit(GP_Backend *self)
munmap(fb->fb_mem, fb->bsize);
close(fb->fb_fd);
- /* restore blinking cursor */
- if (ioctl(fb->con_fd, KDSETMODE, KD_TEXT))
- GP_WARN("Failed to ioctl KDSETMODE (restore KDMODE)");
-
- /* restore keyboard mode */
if (fb->flags & GP_FB_INPUT_KBD)
exit_kbd(fb);
- /* switch back console */
- if (fb->last_con_nr != -1)
- ioctl(fb->con_fd, VT_ACTIVATE, fb->last_con_nr);
+ free_console(fb);
- close(fb->con_fd);
free(self);
}
@@ -298,8 +303,8 @@ GP_Backend *GP_BackendLinuxFBInit(const char *path, int flags)
fb = GP_BACKEND_PRIV(backend);
- if (allocate_console(fb, flags & GP_FB_INPUT_KBD))
- goto err1;
+ if (allocate_console(fb, flags))
+ goto err0;
if (flags & GP_FB_INPUT_KBD) {
if (init_kbd(fb))
@@ -412,15 +417,11 @@ err4:
err3:
close(fd);
err2:
- close(fb->con_fd);
-
- /* reset keyboard */
- ioctl(fb->con_fd, KDSETMODE, KD_TEXT);
-
- /* switch back console */
- if (fb->last_con_nr != -1)
- ioctl(fb->con_fd, VT_ACTIVATE, fb->last_con_nr);
+ if (flags & GP_FB_INPUT_KBD)
+ exit_kbd(fb);
err1:
+ free_console(fb);
+err0:
free(backend);
return NULL;
}
http://repo.or.cz/w/gfxprim.git/commit/5f3a2c0ec123ae0b6db9994fa948b1b03220…
commit 5f3a2c0ec123ae0b6db9994fa948b1b032204acc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Aug 27 00:54:09 2013 +0200
loaders: BMP: Implement BGR888 Save.
Signed-off-by: Cyril Hrubis <metan(a)ucw.cz>
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c
index effb301..430e9d7 100644
--- a/libs/loaders/GP_BMP.c
+++ b/libs/loaders/GP_BMP.c
@@ -182,7 +182,7 @@ static int read_alphabitfields(FILE *f, struct bitmap_info_header *header)
int ret;
ret = GP_FRead(f, "L4 L4 L4 L4",
- &header->R_mask,
+ &header->R_mask,
&header->G_mask,
&header->B_mask,
&header->A_mask);
@@ -467,7 +467,7 @@ static uint8_t get_idx(struct bitmap_info_header *header,
{
switch (header->bpp) {
case 1:
- return !!(row[x/8] & (1<<(7 - x%8)));
+ return !!(row[x/8] & (1<<(7 - x%8)));
case 2:
return (row[x/4] >> (2*(3 - x%4))) & 0x03;
case 4:
@@ -653,7 +653,7 @@ int GP_OpenBMP(const char *src_path, FILE **f,
*h = header.h;
if (pixel_type != NULL)
- *pixel_type = match_pixel_type(&header);
+ *pixel_type = match_pixel_type(&header);
}
return 0;
@@ -775,6 +775,7 @@ static int bmp_fill_header(const GP_Context *src, struct bitmap_info_header *hea
{
switch (src->pixel_type) {
case GP_PIXEL_RGB888:
+ case GP_PIXEL_BGR888:
header->bpp = 24;
break;
default:
@@ -802,8 +803,9 @@ static int bmp_fill_header(const GP_Context *src, struct bitmap_info_header *hea
static int bmp_write_data(FILE *f, const GP_Context *src, GP_ProgressCallback *callback)
{
int y;
- uint32_t padd_len = 0;
+ uint32_t padd_len = 0, x;
char padd[3] = {0};
+ uint8_t tmp[3 * src->w];
if (src->bytes_per_row%4)
padd_len = 4 - src->bytes_per_row%4;
@@ -811,6 +813,17 @@ static int bmp_write_data(FILE *f, const GP_Context *src, GP_ProgressCallback *c
for (y = src->h - 1; y >= 0; y--) {
void *row = GP_PIXEL_ADDR(src, 0, y);
+ if (src->pixel_type == GP_PIXEL_BGR888) {
+ memcpy(tmp, row, 3 * src->w);
+
+ for (x = 0; x < src->w; x++) {
+ uint8_t *pix = tmp + 3 * x;
+ GP_SWAP(pix[0], pix[2]);
+ }
+
+ row = tmp;
+ }
+
if (fwrite(row, src->bytes_per_row, 1, f) != 1)
return EIO;
-----------------------------------------------------------------------
Summary of changes:
libs/backends/GP_LinuxFB.c | 39 ++++++++++++++++++++-------------------
libs/loaders/GP_BMP.c | 21 +++++++++++++++++----
libs/loaders/GP_ZIP.c | 1 +
3 files changed, 38 insertions(+), 23 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0