libgphoto2 photo camera library (libgphoto2) Internals  2.5.26
gamma.c
Go to the documentation of this file.
1 
24 #include "config.h"
25 #include "gamma.h"
26 
27 #include <math.h>
28 
29 #include <gphoto2/gphoto2-result.h>
30 
31 static int
32 gp_gamma_correct_triple (unsigned char *table_red,
33  unsigned char *table_green,
34  unsigned char *table_blue,
35  unsigned char *data, unsigned int size)
36 {
37  unsigned int x;
38 
39  for (x = 0; x < (size * 3); x += 3) {
40  data[x + 0] = table_red [data[x + 0]];
41  data[x + 1] = table_green[data[x + 1]];
42  data[x + 2] = table_blue [data[x + 2]];
43  }
44 
45  return (GP_OK);
46 }
47 
60 int
61 gp_gamma_correct_single (unsigned char *table, unsigned char *data,
62  unsigned int size)
63 {
64  return (gp_gamma_correct_triple (table, table, table, data, size));
65 }
66 
77 int
78 gp_gamma_fill_table (unsigned char *table, double g)
79 {
80  unsigned int x;
81 
82  for (x = 0; x < 256; x++)
83  table[x] = 255 * pow ((double) x/255., g);
84 
85  return (GP_OK);
86 }
int gp_gamma_fill_table(unsigned char *table, double g)
Initialize a Gamma conversion table.
Definition: gamma.c:78
static int gp_gamma_correct_triple(unsigned char *table_red, unsigned char *table_green, unsigned char *table_blue, unsigned char *data, unsigned int size)
Definition: gamma.c:32
int gp_gamma_correct_single(unsigned char *table, unsigned char *data, unsigned int size)
Gamma correction.
Definition: gamma.c:61
#define GP_OK
Everything is OK.