ucw.cz
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
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
List overview
Download
Gfxprim
October 2017
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
gfxprim@ucw.cz
1 participants
1 discussions
Start a n
N
ew thread
[repo.or.cz] gfxprim.git branch master updated: 1.0.0-rc1-194-g302953014e10
by metan
23 Oct '17
23 Oct '17
This is an automated email generated because a ref change occurred in the git repository for project gfxprim.git. The branch, master has been updated via 302953014e10dcef71b369e495dfb91b0fed705e (commit) via afb3d2823c56ff76b757359c589c449252757303 (commit) via b10281ba4c6ef9ade39e86b8c3aa42878fdff59f (commit) via 5375aac799b568e58846b992e69de3193378f904 (commit) via 2b4e84bec2aa6e1fa027e8e4142e42f3f2b7f3da (commit) via 4b85b2f8355a32e7c9b150a9a451aff558694a88 (commit) via 8037a5517128c97aeaedaba084c158d3f3f37935 (commit) via 97cdacf0adedaba34769631b8f506924d61b3e36 (commit) via 55369a6db09675043a60fe95c2b0f010143de78e (commit) via 852fad1c42dbd29205b14d721deff3439c8af635 (commit) via 31709183a28656764eb165da6f8492d67102f556 (commit) from da4d05501970c57531ab9243239873c733993690 (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 ----------------------------------------------------------------- commit 302953014e10dcef71b369e495dfb91b0fed705e Author: Cyril Hrubis <metan(a)ucw.cz> Date: Mon, 23 Oct 2017 18:26:46 +0200 URL: <
http://repo.or.cz/gfxprim.git/302953014e10dcef
> spiv: Fix image list counter We have to add cur_file only and only if we are inside of a directory, otherwise we end up with random position. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- demos/spiv/image_list.c | 3 +++ demos/spiv/spiv.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/demos/spiv/image_list.c b/demos/spiv/image_list.c index be6532c0763e..cf1d18c09a21 100644 --- a/demos/spiv/image_list.c +++ b/demos/spiv/image_list.c @@ -360,6 +360,9 @@ unsigned int image_list_count(struct image_list *self) unsigned int image_list_pos(struct image_list *self) { + if (!self->in_dir) + return count_img_to(self, self->cur_arg); + return count_img_to(self, self->cur_arg) + self->cur_file; } diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index 947390c964be..586cc54deb60 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -277,7 +277,7 @@ static void show_info(struct loader_params *params, GP_Pixmap *img, unsigned int count = image_loader_count(); unsigned int pos = image_loader_pos() + 1; - + printf("pos %u\n", pos); info_printf(pixmap, 10, y, "%u of %u", pos, count); y += th + 2; commit afb3d2823c56ff76b757359c589c449252757303 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Mon, 23 Oct 2017 14:15:48 +0200 URL: <
http://repo.or.cz/gfxprim.git/afb3d2823c56ff76
> loaders: PNG: Wire up gamma tables. Now the loader at least tries to set the gamma value for the pixmap, which is later used by some of the resampling functions, etc. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- libs/loaders/GP_PNG.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c index fa01db1c5939..d0191cf5f103 100644 --- a/libs/loaders/GP_PNG.c +++ b/libs/loaders/GP_PNG.c @@ -196,6 +196,9 @@ static int read_convert_bitmap(GP_Pixmap *res, GP_ProgressCallback *callback, unsigned int y; + if (gamma < 0.01) + GP_PixmapSetGamma(res, 2.2); + for (y = 0; y < res->h; y++) { png_read_row(png, (void*)row, NULL); uint8_t *rrow = GP_PIXEL_ADDR(res, 0, y); @@ -385,6 +388,9 @@ int GP_ReadPNGEx(GP_IO *io, GP_Pixmap **img, goto err2; } + if (gamma > 0.1) + GP_PixmapSetGamma(res, 1/gamma); + if (color_type == PNG_COLOR_TYPE_GRAY && depth < 8) png_set_packswap(png); commit b10281ba4c6ef9ade39e86b8c3aa42878fdff59f Author: Cyril Hrubis <metan(a)ucw.cz> Date: Mon, 23 Oct 2017 13:52:39 +0200 URL: <
http://repo.or.cz/gfxprim.git/b10281ba4c6ef9ad
> core: GP_Pixmap: Add GP_PixmapSetGamma() function Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- build/syms/Core_symbols.txt | 1 + include/core/GP_Pixmap.h | 5 +++++ libs/core/GP_Gamma.c | 7 ++++++- libs/core/GP_Pixmap.c | 9 +++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/build/syms/Core_symbols.txt b/build/syms/Core_symbols.txt index 7ee4ff213aff..b49ab7670191 100644 --- a/build/syms/Core_symbols.txt +++ b/build/syms/Core_symbols.txt @@ -2,6 +2,7 @@ GP_PixelTypes GP_PixelHasFlags GP_PixmapAlloc +GP_PixmapSetGamma GP_PixmapResize GP_PixmapConvertAlloc GP_PixmapPrintInfo diff --git a/include/core/GP_Pixmap.h b/include/core/GP_Pixmap.h index f67e6ec2f9d6..d599fbe792eb 100644 --- a/include/core/GP_Pixmap.h +++ b/include/core/GP_Pixmap.h @@ -111,6 +111,11 @@ typedef struct GP_Pixmap { GP_Pixmap *GP_PixmapAlloc(GP_Size w, GP_Size h, GP_PixelType type); /* + * Sets gamma for the pixmap. + */ +int GP_PixmapSetGamma(GP_Pixmap *self, float gamma); + +/* * Free pixmap. * * If pixmap->free_pixels, also free pixel data. diff --git a/libs/core/GP_Gamma.c b/libs/core/GP_Gamma.c index 05500f9a0c36..afde6fa5e4e9 100644 --- a/libs/core/GP_Gamma.c +++ b/libs/core/GP_Gamma.c @@ -186,7 +186,12 @@ GP_Gamma *GP_GammaCopy(GP_Gamma *self) void GP_GammaRelease(GP_Gamma *self) { - int channels = GP_PixelTypes[self->pixel_type].numchannels, i; + int channels; + + if (!self) + return; + + channels = GP_PixelTypes[self->pixel_type].numchannels, i; GP_DEBUG(1, "Releasing Gamma table %s gamma %f", GP_PixelTypeName(self->pixel_type), self->tables[0]->gamma); diff --git a/libs/core/GP_Pixmap.c b/libs/core/GP_Pixmap.c index 53c289e1c007..72dbae21fd13 100644 --- a/libs/core/GP_Pixmap.c +++ b/libs/core/GP_Pixmap.c @@ -114,6 +114,15 @@ GP_Pixmap *GP_PixmapAlloc(GP_Size w, GP_Size h, GP_PixelType type) return pixmap; } +int GP_PixmapSetGamma(GP_Pixmap *self, float gamma) +{ + GP_GammaRelease(self->gamma); + + self->gamma = GP_GammaAcquire(self->pixel_type, gamma); + + return !self->gamma; +} + void GP_PixmapFree(GP_Pixmap *pixmap) { GP_DEBUG(1, "Freeing pixmap (%p)", pixmap); commit 5375aac799b568e58846b992e69de3193378f904 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Mon, 23 Oct 2017 13:46:50 +0200 URL: <
http://repo.or.cz/gfxprim.git/5375aac799b568e5
> core: Rename GP_Context.c -> GP_Pixmap.c This is leftover from the previous rename. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- libs/core/{GP_Context.c => GP_Pixmap.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename libs/core/{GP_Context.c => GP_Pixmap.c} (100%) diff --git a/libs/core/GP_Context.c b/libs/core/GP_Pixmap.c similarity index 100% rename from libs/core/GP_Context.c rename to libs/core/GP_Pixmap.c commit 2b4e84bec2aa6e1fa027e8e4142e42f3f2b7f3da Author: Cyril Hrubis <metan(a)ucw.cz> Date: Mon, 23 Oct 2017 13:31:12 +0200 URL: <
http://repo.or.cz/gfxprim.git/2b4e84bec2aa6e1f
> gfx: Remove PartialElipse Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- build/syms/GFX_symbols.txt | 7 --- include/gfx/GP_AngleUtils.h | 30 ------------- libs/gfx/GP_AngleUtils.c | 49 -------------------- libs/gfx/GP_PartialEllipse.c | 55 ----------------------- libs/gfx/algo/PartialEllipse.algo.h | 69 ----------------------------- 5 files changed, 210 deletions(-) delete mode 100644 include/gfx/GP_AngleUtils.h delete mode 100644 libs/gfx/GP_AngleUtils.c delete mode 100644 libs/gfx/GP_PartialEllipse.c delete mode 100644 libs/gfx/algo/PartialEllipse.algo.h diff --git a/build/syms/GFX_symbols.txt b/build/syms/GFX_symbols.txt index 3ffccdca6c63..58326502f2ee 100644 --- a/build/syms/GFX_symbols.txt +++ b/build/syms/GFX_symbols.txt @@ -70,9 +70,6 @@ GP_Ellipse_Raw GP_FillEllipse GP_FillEllipse_Raw -GP_PartialEllipse -GP_PartialEllipse_Raw - GP_RectXYXY GP_RectXYXY_Raw GP_RectXYWH @@ -108,7 +105,3 @@ GP_PutPixelAA_Raw_Clipped GP_ArcSegment GP_ArcSegment_Raw - -GP_AngleInRange -GP_NormalizeAngle - diff --git a/include/gfx/GP_AngleUtils.h b/include/gfx/GP_AngleUtils.h deleted file mode 100644 index 6d8bd67c99c0..000000000000 --- a/include/gfx/GP_AngleUtils.h +++ /dev/null @@ -1,30 +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(a)ucw.cz> * - * Copyright (c) 2012 Jiri Dluhos <jiri.bluebear.dluhos(a)gmail.com> * - * * - *****************************************************************************/ - -#ifndef GP_ANGLE_UTILS_H -#define GP_ANGLE_UTILS_H - -double GP_NormalizeAngle(double phi); -int GP_AngleInRange(double angle, double start, double end); - -#endif diff --git a/libs/gfx/GP_AngleUtils.c b/libs/gfx/GP_AngleUtils.c deleted file mode 100644 index 67911b41626d..000000000000 --- a/libs/gfx/GP_AngleUtils.c +++ /dev/null @@ -1,49 +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(a)ucw.cz> * - * Copyright (C) 2012 Cyril Hrubis <metan(a)ucw.cz> * - * Copyright (C) 2012 Jiri Dluhos <jiri.bluebear.dluhos(a)gmail.com> * - * * - *****************************************************************************/ - -#include "GP_AngleUtils.h" - -#include <math.h> - -double GP_NormalizeAngle(double phi) -{ - // clamp angle to <-2*pi, 2*pi> - double phi2 = fmod(phi, 2*M_PI); - - // clamp angle to <0, 2*pi> - if (phi2 < 0) - phi2 += 2*M_PI; - - return phi2; -} - -int GP_AngleInRange(double angle, double start, double end) -{ - if (start < end) { - return (angle >= start && angle <= end); - } else { - return (angle >= start && angle <= 2*M_PI) - || (angle >= 0 && angle <= end); - } -} diff --git a/libs/gfx/GP_PartialEllipse.c b/libs/gfx/GP_PartialEllipse.c deleted file mode 100644 index 0cfd1c9d2072..000000000000 --- a/libs/gfx/GP_PartialEllipse.c +++ /dev/null @@ -1,55 +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-2012 Jiri "BlueBear" Dluhos * - * <jiri.bluebear.dluhos(a)gmail.com> * - * * - * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> * - * * - *****************************************************************************/ - -#include "core/GP_GetPutPixel.h" -#include "core/GP_FnPerBpp.h" - -#include "gfx/GP_Ellipse.h" - -#include "algo/PartialEllipse.algo.h" - -/* Generate drawing functions for various bit depths. */ -GP_DEF_DRAW_FN_PER_BPP(GP_PartialEllipse_Raw, DEF_PARTIAL_ELLIPSE_FN) - -void GP_PartialEllipse_Raw(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, - GP_Size a, GP_Size b, int start, int end, GP_Pixel pixel) -{ - GP_CHECK_PIXMAP(pixmap); - - GP_FN_PER_BPP_PIXMAP(GP_PartialEllipse_Raw, pixmap, pixmap, - xcenter, ycenter, a, b, start, end, pixel); -} - -void GP_PartialEllipse(GP_Pixmap *pixmap, GP_Coord xcenter, GP_Coord ycenter, - GP_Size a, GP_Size b, int start, int end, GP_Pixel pixel) -{ - GP_CHECK_PIXMAP(pixmap); - - /* recalculate center point and swap a and b when axes are swapped */ - GP_TRANSFORM_POINT(pixmap, xcenter, ycenter); - GP_TRANSFORM_SWAP(pixmap, a, b); - - GP_PartialEllipse_Raw(pixmap, xcenter, ycenter, a, b, start, end, pixel); -} diff --git a/libs/gfx/algo/PartialEllipse.algo.h b/libs/gfx/algo/PartialEllipse.algo.h deleted file mode 100644 index 6bf4385e7b25..000000000000 --- a/libs/gfx/algo/PartialEllipse.algo.h +++ /dev/null @@ -1,69 +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-2010 Jiri "BlueBear" Dluhos * - * <jiri.bluebear.dluhos(a)gmail.com> * - * * - * Copyright (C) 2009-2012 Cyril Hrubis <metan(a)ucw.cz> * - * * - *****************************************************************************/ - -#include "GP_AngleUtils.h" - -#include <math.h> - -/* - * This macro defines a partial ellipse drawing function. - * Arguments: - * PIXMAP_T - user-defined type of drawing pixmap (passed to PUTPIXEL) - * PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL) - * PUTPIXEL - a pixel drawing function f(pixmap, x, y, pixval) - * FN_NAME - name of the function to be defined - */ -#define DEF_PARTIAL_ELLIPSE_FN(FN_NAME, PIXMAP_T, PIXVAL_T, PUTPIXEL) \ -static void FN_NAME(PIXMAP_T pixmap, int xcenter, int ycenter, int a, int b, \ - int start, int end, PIXVAL_T pixval) \ -{ \ - double startAngle = GP_NormalizeAngle(2*M_PI*(start / 360000.0)); \ - double endAngle = GP_NormalizeAngle(2*M_PI*(end / 360000.0)); \ -\ - int x; \ - for (x = -a; x <= a; x++) { \ - double angle = acos(((double) x) / a); \ - double y = floor(b*sin(angle)); \ - if (GP_AngleInRange(angle, startAngle, endAngle)) { \ - PUTPIXEL(pixmap, xcenter+x, ycenter-y, pixval); \ - } \ - if (GP_AngleInRange(2*M_PI - angle, startAngle, endAngle)) { \ - PUTPIXEL(pixmap, xcenter+x, ycenter+y, pixval); \ - } \ - } \ -\ - int y; \ - for (y = -b; y <= b; y++) { \ - double angle = asin(((double) y) / b); \ - double x = floor(a*cos(angle)); \ - if (GP_AngleInRange(angle, startAngle, endAngle)) { \ - PUTPIXEL(pixmap, xcenter+x, ycenter-y, pixval); \ - } \ - if (GP_AngleInRange(M_PI - angle, startAngle, endAngle)) { \ - PUTPIXEL(pixmap, xcenter-x, ycenter-y, pixval); \ - } \ - } \ -} - commit 4b85b2f8355a32e7c9b150a9a451aff558694a88 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Mon, 23 Oct 2017 13:17:55 +0200 URL: <
http://repo.or.cz/gfxprim.git/4b85b2f8355a32e7
> demos: py_simple: Remove *_AA.py Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- demos/py_simple/gravplots_AA.py | 112 -------------------------------- demos/py_simple/sinplots_AA.py | 59 ----------------- 2 files changed, 171 deletions(-) delete mode 100755 demos/py_simple/gravplots_AA.py delete mode 100755 demos/py_simple/sinplots_AA.py diff --git a/demos/py_simple/gravplots_AA.py b/demos/py_simple/gravplots_AA.py deleted file mode 100755 index 5de7bcc6a0a7..000000000000 --- a/demos/py_simple/gravplots_AA.py +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/env python -import gfxprim.core as core -import gfxprim.backends as backends -import gfxprim.loaders as loaders -import gfxprim.gfx as gfx -import random -from math import sqrt - -AA = True -W = 320*2 -H = 240*2 -BPP = 24 -N = 8 # Try 5 or 42 - -# Gravity, brake factor and desired total speeds (in dir. X and total) -G = 0.1 # Adjust: 0.1 for N<20, 0.01 for N=100 -BRAKE = 0.001 -VX0 = 0.6 -V0 = 0.9 - -# Try one max and other ~50 : -MAXR = 255 -MAXG = 255 -MAXB = 255 - -# timeout in moves, -1 for none -TIMEOUT = -1 -# after timeout save to this file, None for none -SAVETO = "gravplot.png" - -class elem(object): - def __init__(self): - #self.x = random.uniform(0.0 * W, 0.6 * W) - self.x = 0 - self.y = random.uniform(0.2 * H, 0.8 * H) - self.vx = random.uniform(VX0 - 0.5, VX0 + 0.5) - self.vy = random.uniform(-0.5, 0.5) - self.r = random.randint(MAXR / 5, MAXR) - self.g = random.randint(MAXG / 5, MAXG) - self.b = random.randint(MAXB / 5, MAXB) - - def grav(self, other, t): - dx = other.x - self.x - dy = other.y - self.y - # Minimal distance is bounded - d2 = max(dx ** 2 + dy ** 2, 0.1 ** 2) - f = G / d2 - self.vx += dx * f * t - self.vy += dy * f * t - - def move(self, t): - self.x += self.vx * t - self.y += self.vy * t - # "Gravity" to y=H/2 - if self.y > 0.6 * H: - self.vy -= V0 * t * BRAKE - if self.y < 0.4 * H: - self.vy += V0 * t * BRAKE - # Magic to adjust speed - v = sqrt(self.vx ** 2 + self.vy ** 2) - self.vx *= (1.0 - BRAKE) + (BRAKE * V0 / v) - self.vy *= (1.0 - BRAKE) + (BRAKE * V0 / v) - self.vx = (1.0 - BRAKE) * self.vx + BRAKE * VX0 - # Bound speed - self.vx = max(min(self.vx, 4.0), -4.0) - self.vy = max(min(self.vy, 4.0), -4.0) - - -def main(): - bk = backends.BackendSDLInit(W, H, BPP, 0, "Gravplots AA") - assert bk - print(bk) - print("Modify source for parameters,") - print("Kill to terminate ;-)") - black = bk.pixmap.RGBToPixel(0, 0, 0) - - es = [elem() for i in range(N)] - while True: - for e in es: - for e2 in es: - if not (e is e2): - e.grav(e2, 1.0) - for e in es: - e.move(1.0) - if AA: - x = int((e.x % W) * 0x100) - y = int(e.y * 0x100) - if e.vx > 0.2: - bk.pixmap.gfx.VLineAA(x + 0x100, y - 0x300, y + 0x300, black) - if e.vx < -0.2: - bk.pixmap.gfx.VLineAA(x - 0x100, y - 0x300, y + 0x300, black) - bk.pixmap.gfx.PutPixelAA(x, y, bk.pixmap.RGBToPixel(e.r, e.g, e.b)) - else: - x = int(e.x % W) - y = int(e.y) - if e.vx > 0.2: - bk.pixmap.gfx.VLine(x + 1, y - 2, y + 2, black) - if e.vx < -0.2: - bk.pixmap.gfx.VLine(x - 1, y - 2, y + 2, black) - bk.pixmap.core.PutPixel(x, y, bk.pixmap.RGBToPixel(e.r, e.g, e.b)) - bk.Poll() - bk.Flip() - global TIMEOUT - if TIMEOUT > 0: - TIMEOUT -= 1 - if TIMEOUT == 0: - break - if SAVETO: - bk.pixmap.Save(SAVETO) - -if __name__ == '__main__': - main() diff --git a/demos/py_simple/sinplots_AA.py b/demos/py_simple/sinplots_AA.py deleted file mode 100755 index 44afd21ecb7c..000000000000 --- a/demos/py_simple/sinplots_AA.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -import gfxprim.core as core -import gfxprim.backends as backends -import gfxprim.gfx as gfx -import random -from math import sin - -AA = True -W = 320 -H = 240 -N = 10 - -class plotter(object): - def __init__(self): - self.x0 = random.uniform(0, W) - self.y0 = random.uniform(H*0.2, H*0.8) - self.a = H * (0.06 + random.uniform(0, 0.1) + random.uniform(0, 0.2)) - self.period = 4.0 + random.expovariate(4.0/W) - self.speed = random.uniform(0.04, min(max(0.05, 0.5 * self.period / self.a), 1.0)) - def pos(self, t): - x = self.x0 + self.speed * t - y = self.y0 + sin(x / self.period) * self.a - return (x % W, y) - def color(self, t): - return ( - 128 + 120 * sin(t / (self.a + 10.0)), - 128 + 120 * sin(t / (self.y0 + 3.0)), - 128 + 120 * sin(t / (self.x0 + 5.0))) - - -def main(): - bk = backends.BackendSDLInit(W, H, 16, 0, "Sinplots AA") - assert bk - print(bk) - print("Modify source for parameters,") - print("Kill to terminate ;-)") - black = bk.pixmap.RGBToPixel(0, 0, 0) - - ps = [plotter() for i in range(N)] - t = random.uniform(0.0, 10.0 * W) - while True: - t += 1.0 - for p in ps: - (x, y) = p.pos(t) - (r, g, b) = p.color(t) - if AA: - x = int(x * 0x100) - y = int(y * 0x100) - bk.pixmap.gfx.VLineAA(x + 0x100, y - 0x200, y + 0x200, black) - bk.pixmap.gfx.PutPixelAA(x, y, bk.pixmap.RGBToPixel(int(r), int(g), int(b))) - else: - x = int(x) - y = int(y) - bk.pixmap.gfx.VLine(x + 1, y - 2, y + 2, black) - bk.pixmap.core.PutPixel(x, y, bk.pixmap.RGBToPixel(int(r), int(g), int(b))) - bk.Flip() - -if __name__ == '__main__': - main() commit 8037a5517128c97aeaedaba084c158d3f3f37935 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Mon, 23 Oct 2017 13:15:38 +0200 URL: <
http://repo.or.cz/gfxprim.git/8037a5517128c97a
> demos: c_simple: Remove sin_AA Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- demos/c_simple/Makefile | 3 +- demos/c_simple/sin_AA.c | 126 ---------------------------------------- 2 files changed, 1 insertion(+), 128 deletions(-) delete mode 100644 demos/c_simple/sin_AA.c diff --git a/demos/c_simple/Makefile b/demos/c_simple/Makefile index 0525e72131e5..f12f491b7fcf 100644 --- a/demos/c_simple/Makefile +++ b/demos/c_simple/Makefile @@ -16,7 +16,7 @@ APPS=backend_example loaders_example loaders filters_symmetry gfx_koch\ virtual_backend_example meta_data showimage\ v4l2_show v4l2_grab convolution weighted_median shapetest koch \ input_example fileview linetest randomshapetest fonttest\ - loaders_register blittest textaligntest sin_AA x11_windows\ + loaders_register blittest textaligntest x11_windows\ debug_handler gaussian_noise version pretty_print timers\ zip_container backend_timers_example memory_io data_storage @@ -50,7 +50,6 @@ textaligntest: LDLIBS+=-lgfxprim-backends loaders_register: LDLIBS+=-lgfxprim-loaders gaussian_noise: LDLIBS+=-lgfxprim-loaders blittest: LDLIBS+=-lgfxprim-backends -lgfxprim-loaders -sin_AA: LDLIBS+=-lgfxprim-backends -lm x11_windows: LDLIBS+=-lgfxprim-backends zip_container: LDLIBS+=-lgfxprim-loaders -lgfxprim-backends memory_io: LDLIBS+=-lgfxprim-backends -lgfxprim-loaders diff --git a/demos/c_simple/sin_AA.c b/demos/c_simple/sin_AA.c deleted file mode 100644 index 0191918a2e80..000000000000 --- a/demos/c_simple/sin_AA.c +++ /dev/null @@ -1,126 +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-2013 Cyril Hrubis <metan(a)ucw.cz> * - * * - *****************************************************************************/ - -/* - - Simple example that shows HLineAA() usage. - - */ - -#include <stdio.h> -#include <errno.h> -#include <string.h> - -#include <GP.h> - -static void redraw(GP_Pixmap *pixmap) -{ - static float param = 1; - static float param2 = 0.01; - static int flag = 1; - GP_Pixel b = GP_RGBToPixmapPixel(0xbe, 0xbe, 0x9e, pixmap); - unsigned int y; - - GP_Fill(pixmap, b); - - for (y = 0; y < pixmap->w; y++) { - GP_Coord x0, x1, l1, l2; - - x0 = (pixmap->w)<<7; - x1 = (pixmap->w)<<7; - - l1 = (pixmap->w)<<5; - l2 = (pixmap->w)<<3; - - GP_Pixel p = GP_RGBToPixmapPixel(120 - 3 * param, abs(40 * param), 0, pixmap); - - l2 *= 4.00 * y / pixmap->h; - - l1 *= param; - - x0 += l1 * sin(param2 * y) + l2; - x1 -= l1 * cos(param2 * y) + l2; - - GP_HLineAA(pixmap, x0, x1, y<<8, p); - } - - if (flag) { - param -= 0.02; - - if (param <= -2.40) { - flag = 0; - param2 += 0.01; - - if (param2 > 0.02) - param2 = 0.01; - } - } else { - param += 0.02; - - if (param >= 2.40) - flag = 1; - } -} - -int main(void) -{ - GP_Backend *backend; - static int pause_flag = 0; - - /* Initalize backend */ - backend = GP_BackendX11Init(NULL, 0, 0, 800, 600, "sin AA", 0); - - if (backend == NULL) { - fprintf(stderr, "Failed to initalize backend\n"); - return 1; - } - - /* Wait for events */ - for (;;) { - if (!pause_flag) { - redraw(backend->pixmap); - GP_BackendFlip(backend); - } - - GP_BackendPoll(backend); - - GP_Event ev; - - while (GP_BackendGetEvent(backend, &ev)) { - if (ev.type == GP_EV_KEY && ev.code == GP_EV_KEY_DOWN) { - switch (ev.val.val) { - case GP_KEY_ESC: - case GP_KEY_Q: - GP_BackendExit(backend); - return 0; - case GP_KEY_P: - pause_flag = !pause_flag; - break; - } - } - } - - usleep(10000); - } - - return 0; -} commit 97cdacf0adedaba34769631b8f506924d61b3e36 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Mon, 23 Oct 2017 12:53:07 +0200 URL: <
http://repo.or.cz/gfxprim.git/97cdacf0adedaba3
> loaders: PNG: Handle gamma on 16bpp conversion Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- libs/loaders/GP_PNG.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c index 21b5b133fc71..fa01db1c5939 100644 --- a/libs/loaders/GP_PNG.c +++ b/libs/loaders/GP_PNG.c @@ -35,6 +35,7 @@ #include "../../config.h" #include "core/GP_ByteOrder.h" #include "core/GP_Debug.h" +#include "core/GP_GammaCorrection.h" #include "GP_PNG.h" @@ -178,7 +179,7 @@ static int read_bitmap(GP_Pixmap *res, GP_ProgressCallback *callback, } static int read_convert_bitmap(GP_Pixmap *res, GP_ProgressCallback *callback, - png_structp png, int passes) + png_structp png, int passes, double gamma) { uint16_t *row; @@ -200,11 +201,19 @@ static int read_convert_bitmap(GP_Pixmap *res, GP_ProgressCallback *callback, uint8_t *rrow = GP_PIXEL_ADDR(res, 0, y); unsigned int x = 0; - //TODO: Gamma - for (x = 0; x < res->w; x++) { - rrow[3*x] = row[3 * x]>>8; - rrow[3*x + 1] = row[3 * x + 1]>>8; - rrow[3*x + 2] = row[3 * x + 2]>>8; + + if (gamma > 0.1) { + for (x = 0; x < res->w; x++) { + rrow[3*x] = row[3 * x]>>8; + rrow[3*x + 1] = row[3 * x + 1]>>8; + rrow[3*x + 2] = row[3 * x + 2]>>8; + } + } else { + for (x = 0; x < res->w; x++) { + rrow[3*x] = GP_Linear16ToGamma8(row[3 * x]); + rrow[3*x + 1] = GP_Linear16ToGamma8(row[3 * x + 1]); + rrow[3*x + 2] = GP_Linear16ToGamma8(row[3 * x + 2]); + } } if (GP_ProgressCallbackReport(callback, y, res->h, res->w)) { @@ -390,7 +399,7 @@ int GP_ReadPNGEx(GP_IO *io, GP_Pixmap **img, } #endif if (convert_16_to_8) { - if ((err = read_convert_bitmap(res, callback, png, passes))) + if ((err = read_convert_bitmap(res, callback, png, passes, gamma))) goto err3; } else { if ((err = read_bitmap(res, callback, png, passes))) commit 55369a6db09675043a60fe95c2b0f010143de78e Author: Cyril Hrubis <metan(a)ucw.cz> Date: Mon, 23 Oct 2017 12:32:44 +0200 URL: <
http://repo.or.cz/gfxprim.git/55369a6db0967504
> core: GP_GammaCorrection.gen.h.t: Add 16bpp helpers Add 16bpp linear to gamma helpers. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- include/core/GP_GammaCorrection.gen.h.t | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/core/GP_GammaCorrection.gen.h.t b/include/core/GP_GammaCorrection.gen.h.t index 59610665c186..593324b966b6 100644 --- a/include/core/GP_GammaCorrection.gen.h.t +++ b/include/core/GP_GammaCorrection.gen.h.t @@ -21,4 +21,9 @@ static inline uint8_t GP_Linear10ToGamma{{ i }}(uint16_t val) return (GP_Linear10_Gamma8[val] + {{ int(2 ** (7 - i))}})>>{{8 - i}}; } +static inline uint8_t GP_Linear16ToGamma{{ i }}(uint16_t val) +{ + return (GP_Linear10_Gamma8[val>>6] + {{ int(2 ** (7 - i))}})>>{{8 - i}}; +} + @ end commit 852fad1c42dbd29205b14d721deff3439c8af635 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Mon, 23 Oct 2017 12:23:29 +0200 URL: <
http://repo.or.cz/gfxprim.git/852fad1c42dbd292
> loaders: PNG: Add support for loading 16bpp RGB The data are converted to 8bpp RGB at this point. Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- libs/loaders/GP_PNG.c | 96 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 76 insertions(+), 20 deletions(-) diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c index ce8f650074a0..21b5b133fc71 100644 --- a/libs/loaders/GP_PNG.c +++ b/libs/loaders/GP_PNG.c @@ -153,6 +153,71 @@ static void load_meta_data(png_structp png, png_infop png_info, } } +static int read_bitmap(GP_Pixmap *res, GP_ProgressCallback *callback, + png_structp png, int passes) +{ + uint32_t y; + int p; + + /* + * The passes are needed for adam7 interlacing. + */ + for (p = 0; p < passes; p++) { + for (y = 0; y < res->h; y++) { + png_bytep row = GP_PIXEL_ADDR(res, 0, y); + png_read_row(png, row, NULL); + + if (GP_ProgressCallbackReport(callback, y + res->h * p, res->h * passes, res->w)) { + GP_DEBUG(1, "Operation aborted"); + return ECANCELED; + } + } + } + + return 0; +} + +static int read_convert_bitmap(GP_Pixmap *res, GP_ProgressCallback *callback, + png_structp png, int passes) +{ + uint16_t *row; + + if (passes > 1) { + GP_DEBUG(1, "Interlaced 16 bit PNG not supported"); + return ENOSYS; + } + + row = malloc(6 * res->w); + if (!row) { + GP_DEBUG(1, "Malloc failed :("); + return ENOMEM; + } + + unsigned int y; + + for (y = 0; y < res->h; y++) { + png_read_row(png, (void*)row, NULL); + uint8_t *rrow = GP_PIXEL_ADDR(res, 0, y); + unsigned int x = 0; + + //TODO: Gamma + for (x = 0; x < res->w; x++) { + rrow[3*x] = row[3 * x]>>8; + rrow[3*x + 1] = row[3 * x + 1]>>8; + rrow[3*x + 2] = row[3 * x + 2]>>8; + } + + if (GP_ProgressCallbackReport(callback, y, res->h, res->w)) { + GP_DEBUG(1, "Operation aborted"); + free(row); + return ECANCELED; + } + } + + free(row); + return 0; +} + int GP_ReadPNGEx(GP_IO *io, GP_Pixmap **img, GP_DataStorage *storage, GP_ProgressCallback *callback) { @@ -164,6 +229,7 @@ int GP_ReadPNGEx(GP_IO *io, GP_Pixmap **img, GP_Pixmap *res = NULL; int err, passes = 1; double gamma; + int convert_16_to_8 = 0; png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); @@ -250,6 +316,10 @@ int GP_ReadPNGEx(GP_IO *io, GP_Pixmap **img, case 8: pixel_type = GP_PIXEL_RGB888; break; + case 16: + pixel_type = GP_PIXEL_RGB888; + convert_16_to_8 = 1; + break; } break; case PNG_COLOR_TYPE_RGB | PNG_COLOR_MASK_ALPHA: @@ -319,26 +389,12 @@ int GP_ReadPNGEx(GP_IO *io, GP_Pixmap **img, png_set_swap(png); } #endif - - uint32_t y; - int p; - - /* - * Do the actuall reading. - * - * The passes are needed for adam7 interlacing. - */ - for (p = 0; p < passes; p++) { - for (y = 0; y < h; y++) { - png_bytep row = GP_PIXEL_ADDR(res, 0, y); - png_read_row(png, row, NULL); - - if (GP_ProgressCallbackReport(callback, y + h * p, h * passes, w)) { - GP_DEBUG(1, "Operation aborted"); - err = ECANCELED; - goto err3; - } - } + if (convert_16_to_8) { + if ((err = read_convert_bitmap(res, callback, png, passes))) + goto err3; + } else { + if ((err = read_bitmap(res, callback, png, passes))) + goto err3; } exit: commit 31709183a28656764eb165da6f8492d67102f556 Author: Cyril Hrubis <metan(a)ucw.cz> Date: Mon, 23 Oct 2017 11:55:47 +0200 URL: <
http://repo.or.cz/gfxprim.git/31709183a2865676
> demos/loaders_register: Fix progress callback Signed-off-by: Cyril Hrubis <metan(a)ucw.cz> --- demos/c_simple/loaders_register.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/c_simple/loaders_register.c b/demos/c_simple/loaders_register.c index 4279c51f1014..cc2c0a15adba 100644 --- a/demos/c_simple/loaders_register.c +++ b/demos/c_simple/loaders_register.c @@ -82,7 +82,7 @@ static int write_data(const GP_Pixmap *img, GP_IO *io, if (GP_IOFlush(bio, "\n", 1)) return 1; - if (GP_ProgressCallbackReport(callback, img->h, j, img->w)) { + if (GP_ProgressCallbackReport(callback, j, img->h, img->w)) { errno = ECANCELED; return 1; } ----------------------------------------------------------------------- Summary of changes: build/syms/Core_symbols.txt | 1 + build/syms/GFX_symbols.txt | 7 -- demos/c_simple/Makefile | 3 +- demos/c_simple/loaders_register.c | 2 +- demos/c_simple/sin_AA.c | 126 ------------------------ demos/py_simple/gravplots_AA.py | 112 --------------------- demos/py_simple/sinplots_AA.py | 59 ----------- demos/spiv/image_list.c | 3 + demos/spiv/spiv.c | 2 +- include/core/GP_GammaCorrection.gen.h.t | 5 + include/core/GP_Pixmap.h | 5 + include/gfx/GP_AngleUtils.h | 30 ------ libs/core/GP_Gamma.c | 7 +- libs/core/{GP_Context.c => GP_Pixmap.c} | 9 ++ libs/gfx/GP_AngleUtils.c | 49 --------- libs/gfx/GP_PartialEllipse.c | 55 ----------- libs/gfx/algo/PartialEllipse.algo.h | 69 ------------- libs/loaders/GP_PNG.c | 111 +++++++++++++++++---- 18 files changed, 123 insertions(+), 532 deletions(-) delete mode 100644 demos/c_simple/sin_AA.c delete mode 100755 demos/py_simple/gravplots_AA.py delete mode 100755 demos/py_simple/sinplots_AA.py delete mode 100644 include/gfx/GP_AngleUtils.h rename libs/core/{GP_Context.c => GP_Pixmap.c} (98%) delete mode 100644 libs/gfx/GP_AngleUtils.c delete mode 100644 libs/gfx/GP_PartialEllipse.c delete mode 100644 libs/gfx/algo/PartialEllipse.algo.h 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
0
0
Results per page:
10
25
50
100
200