2
* Gamma Correction Plugin (RGB Version) 0.01
4
* Copyright (c) 2005 Peter Schlaile
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
22
char name[]= "Gamma Correction";
25
{ NUMSLI|FLO, "St M:", 0.0, -1.0, 1.0, "Setup Main"},
26
{ NUMSLI|FLO, "Gn M:", 1.0, 0.0, 10.0,"Gain Main"},
27
{ NUMSLI|FLO, "Ga M:", 1.0, 0.0, 10.0, "Gamma Main"},
29
{ NUMSLI|FLO, "St R:", 0.0, -1.0, 1.0, "Setup Red"},
30
{ NUMSLI|FLO, "Gn R:", 1.0, 0.0, 10.0,"Gain Red"},
31
{ NUMSLI|FLO, "Ga R:", 1.0, 0.0, 10.0, "Gamma Red"},
33
{ NUMSLI|FLO, "St G:", 0.0, -1.0, 1.0, "Setup Green"},
34
{ NUMSLI|FLO, "Gn G:", 1.0, 0.0, 10.0,"Gain Green"},
35
{ NUMSLI|FLO, "Ga G:", 1.0, 0.0, 10.0, "Gamma Green"},
37
{ NUMSLI|FLO, "St B:", 0.0, -1.0, 1.0, "Setup Blue"},
38
{ NUMSLI|FLO, "Gn B:", 1.0, 0.0, 10.0,"Gain Blue"},
39
{ NUMSLI|FLO, "Ga B:", 1.0, 0.0, 10.0, "Gamma Blue"},
62
void plugin_seq_doit(Cast *, float, float, int, int, ImBuf *, ImBuf *, ImBuf *, ImBuf *);
64
int plugin_seq_getversion(void) { return B_PLUGIN_VERSION;}
65
void plugin_but_changed(int but) {}
68
void plugin_getinfo(PluginInfo *info) {
70
info->nvars= sizeof(varstr)/sizeof(VarStruct);
75
info->init= plugin_init;
76
info->seq_doit= (SeqDoit) plugin_seq_doit;
77
info->callback= plugin_but_changed;
80
static void make_gamma_table(float setup, float gain, float gamma,
81
unsigned char * table)
85
for (y = 0; y < 256; y++) {
86
float v = 1.0 * y / 255;
100
void plugin_seq_doit(Cast *cast, float facf0, float facf1, int width,
101
int height, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *out, ImBuf *use) {
102
unsigned char *dest, *src1, *src2;
104
unsigned char gamma_table_m[256];
105
unsigned char gamma_table_r[256];
106
unsigned char gamma_table_g[256];
107
unsigned char gamma_table_b[256];
111
dest= (unsigned char *) out->rect;
112
src1= (unsigned char *) ibuf1->rect;
114
make_gamma_table(cast->setup_m, cast->gain_m, cast->gamma_m,
116
make_gamma_table(cast->setup_r, cast->gain_r, cast->gamma_r,
118
make_gamma_table(cast->setup_g, cast->gain_g, cast->gamma_g,
120
make_gamma_table(cast->setup_b, cast->gain_b, cast->gamma_b,
123
for (y = 0; y < height; y++) {
124
for (x = 0; x < width; x++) {
125
*dest++ = gamma_table_r[gamma_table_m[*src1++]];
126
*dest++ = gamma_table_g[gamma_table_m[*src1++]];
127
*dest++ = gamma_table_b[gamma_table_m[*src1++]];