aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gamma-w32gdi.c36
-rw-r--r--src/gamma-w32gdi.h1
2 files changed, 30 insertions, 7 deletions
diff --git a/src/gamma-w32gdi.c b/src/gamma-w32gdi.c
index c07ce91..c518fe6 100644
--- a/src/gamma-w32gdi.c
+++ b/src/gamma-w32gdi.c
@@ -43,6 +43,7 @@ int
w32gdi_init(w32gdi_state_t *state)
{
state->saved_ramps = NULL;
+ state->preserve = 0;
return 0;
}
@@ -102,12 +103,26 @@ w32gdi_print_help(FILE *f)
{
fputs(_("Adjust gamma ramps with the Windows GDI.\n"), f);
fputs("\n", f);
+
+ /* TRANSLATORS: Windows GDI help output
+ left column must not be translated */
+ fputs(_(" preserve={0,1}\tWhether existing gamma should be"
+ " preserved\n"),
+ f);
+ fputs("\n", f);
}
int
w32gdi_set_option(w32gdi_state_t *state, const char *key, const char *value)
{
- return -1;
+ if (strcasecmp(key, "preserve") == 0) {
+ state->preserve = atoi(value);
+ } else {
+ fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key);
+ return -1;
+ }
+
+ return 0;
}
void
@@ -153,12 +168,19 @@ w32gdi_set_temperature(w32gdi_state_t *state,
WORD *gamma_g = &gamma_ramps[1*GAMMA_RAMP_SIZE];
WORD *gamma_b = &gamma_ramps[2*GAMMA_RAMP_SIZE];
- /* Initialize gamma ramps to pure state */
- for (int i = 0; i < GAMMA_RAMP_SIZE; i++) {
- WORD value = (double)i/GAMMA_RAMP_SIZE * (UINT16_MAX+1);
- gamma_r[i] = value;
- gamma_g[i] = value;
- gamma_b[i] = value;
+ if (state->preserve) {
+ /* Initialize gamma ramps from saved state */
+ memcpy(gamma_ramps, state->saved_ramps,
+ 3*GAMMA_RAMP_SIZE*sizeof(WORD));
+ } else {
+ /* Initialize gamma ramps to pure state */
+ for (int i = 0; i < GAMMA_RAMP_SIZE; i++) {
+ WORD value = (double)i/GAMMA_RAMP_SIZE *
+ (UINT16_MAX+1);
+ gamma_r[i] = value;
+ gamma_g[i] = value;
+ gamma_b[i] = value;
+ }
}
colorramp_fill(gamma_r, gamma_g, gamma_b, GAMMA_RAMP_SIZE,
diff --git a/src/gamma-w32gdi.h b/src/gamma-w32gdi.h
index 1f985c8..6e73cd1 100644
--- a/src/gamma-w32gdi.h
+++ b/src/gamma-w32gdi.h
@@ -28,6 +28,7 @@
typedef struct {
WORD *saved_ramps;
+ int preserve;
} w32gdi_state_t;