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 631cb441b16c00328d2659334528d341d582fad6 (commit) from cc83288477bc668c5e5705521c816eb595341ec3 (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/631cb441b16c00328d2659334528d341d582f...
commit 631cb441b16c00328d2659334528d341d582fad6 Author: Cyril Hrubis metan@ucw.cz Date: Tue Jan 1 00:37:27 2013 +0100
core: Gamma: Prepare for sRGB correction.
diff --git a/include/core/GP_Gamma.h b/include/core/GP_Gamma.h index 9a93587..53e217e 100644 --- a/include/core/GP_Gamma.h +++ b/include/core/GP_Gamma.h @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -115,11 +115,24 @@
#include "GP_Context.h"
+typedef enum GP_CorrectionType { + /* + * Classical gamma correction + */ + GP_CORRECTION_GAMMA, + /* + * Standard RGB + */ + GP_CORRECTION_sRGB, +} GP_CorrectionType; + + /* * Gamma table. */ typedef struct GP_GammaTable { /* Table description */ + enum GP_CorrectionType type; float gamma; uint8_t in_bits; uint8_t out_bits; @@ -161,6 +174,11 @@ typedef struct GP_Gamma { GP_Gamma *GP_GammaAcquire(GP_PixelType pixel_type, float gamma);
/* + * Returns pointer to the sRGB translation table. + */ +GP_Gamma *GP_sRGBAcquire(GP_PixelType pixel_type); + +/* * Copies Gamma table (actually increases ref_count) so it's fast and can't * fail. */ @@ -171,4 +189,9 @@ GP_Gamma *GP_GammaCopy(GP_Gamma *gamma); */ void GP_GammaRelease(GP_Gamma *self);
+/* + * Prints info about gamma table into the stdout. + */ +void GP_GammaPrint(const GP_Gamma *self); + #endif /* CORE_GP_GAMMA_H */ diff --git a/include/core/GP_Pixel.h b/include/core/GP_Pixel.h index c171413..c0b13f3 100644 --- a/include/core/GP_Pixel.h +++ b/include/core/GP_Pixel.h @@ -19,14 +19,14 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * * Copyright (C) 2011 Tomas Gavenciak gavento@ucw.cz * * * *****************************************************************************/
-#ifndef GP_PIXEL_H -#define GP_PIXEL_H +#ifndef CORE_GP_PIXEL_H +#define CORE_GP_PIXEL_H
#include <stdbool.h> #include <stdint.h> @@ -79,7 +79,7 @@ typedef enum { * A - opacity (0=transparent) * P - palette (index) */ -typedef struct { +typedef struct GP_PixelTypeChannel { char name[8]; /* Channel name */ uint8_t offset; /* Offset in bits */ uint8_t size; /* Bit-size */ @@ -95,7 +95,7 @@ typedef struct { * Assumes name with at most 15 chars * Assumes at most 8 channels */ -typedef struct { +typedef struct GP_PixelTypeDescription { GP_PixelType type; /* Number of the type */ const char name[16]; /* Name */ uint8_t size; /* Size in bits */ @@ -133,6 +133,12 @@ static inline uint32_t GP_PixelSize(GP_PixelType type) return GP_PixelTypes[type].size; }
+static inline const GP_PixelTypeDescription *GP_PixelTypeDesc(GP_PixelType type) +{ + GP_CHECK_VALID_PIXELTYPE(type); + return &GP_PixelTypes[type]; +} + /* * Print a human-readable representation of a pixel value to a string. * Arguments as for snprintf(). @@ -178,4 +184,4 @@ GP_PixelType GP_PixelRGBLookup(uint32_t rsize, uint32_t roff, uint32_t asize, uint32_t aoff, uint8_t bits_per_pixel);
-#endif /* GP_PIXEL_H */ +#endif /* CORE_GP_PIXEL_H */ diff --git a/libs/core/GP_Context.c b/libs/core/GP_Context.c index c082c53..a2f10d3 100644 --- a/libs/core/GP_Context.c +++ b/libs/core/GP_Context.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2011 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -276,7 +276,9 @@ void GP_ContextPrintInfo(const GP_Context *self) printf("Offsett%u (only unaligned pixel types)n", self->offset); printf("Flagstaxes_swap=%u x_swap=%u y_swap=%u free_pixels=%un", self->axes_swap, self->x_swap, self->y_swap, self->free_pixels); - printf("Gamma table %pn", self->gamma); + + if (self->gamma) + GP_GammaPrint(self->gamma); }
/* diff --git a/libs/core/GP_Gamma.c b/libs/core/GP_Gamma.c index b1f113c..6268b91 100644 --- a/libs/core/GP_Gamma.c +++ b/libs/core/GP_Gamma.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -86,6 +86,7 @@ static GP_GammaTable *get_table(float gamma, uint8_t in_bits, uint8_t out_bits) i->in_bits = in_bits; i->out_bits = out_bits; i->ref_count = 1; + i->type = GP_CORRECTION_GAMMA; if (out_bits > 8) fill_table16(i, gamma, in_bits, out_bits); @@ -197,3 +198,37 @@ void GP_GammaRelease(GP_Gamma *self) free(self); } } + +static const char *correction_type_names[] = { + "Gamma", + "sRGB", +}; + +static const char *correction_type_name(enum GP_CorrectionType type) +{ + if (type > GP_CORRECTION_sRGB) + return "Invalid"; + + return correction_type_names[type]; +} + +void GP_GammaPrint(const GP_Gamma *self) +{ + printf("Correction tables:n"); + + const GP_PixelTypeDescription *desc = GP_PixelTypeDesc(self->pixel_type); + + unsigned int i; + + for (i = 0; i < desc->numchannels; i++) { + enum GP_CorrectionType type = self->tables[i]->type; + + printf(" %s: %s", desc->channels[i].name, + correction_type_name(type)); + + if (type == GP_CORRECTION_GAMMA) + printf(" gamma = %.2f", self->tables[i]->gamma); + + printf("n"); + } +}
-----------------------------------------------------------------------
Summary of changes: include/core/GP_Gamma.h | 25 ++++++++++++++++++++++++- include/core/GP_Pixel.h | 18 ++++++++++++------ libs/core/GP_Context.c | 6 ++++-- libs/core/GP_Gamma.c | 37 ++++++++++++++++++++++++++++++++++++- 4 files changed, 76 insertions(+), 10 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.