-
Notifications
You must be signed in to change notification settings - Fork 0
/
71074.c
70 lines (48 loc) · 1.46 KB
/
71074.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <wand/MagickWand.h>
int main(int argc,char **argv) {
MagickWand *magick_wand;
MagickBooleanType status;
PixelWand *pixel_wand_input;
PixelWand *pixel_wand_output;
double hue, saturation, luminosity;
double red, green, blue, alpha;
char hslString[2028];
char *inputColor = "rgb(158, 146, 130)";
MagickWandGenesis();
pixel_wand_input = NewPixelWand();
if (PixelSetColor (pixel_wand_input, inputColor) == MagickFalse) {
printf("Failed to set color");
exit(-1);
}
PixelGetHSL(pixel_wand_input, &hue, &saturation, &luminosity);
printf("hsl values are %.4f, %.4f, %.4f\n", hue, saturation, luminosity);
sprintf(
hslString,
"hsl(%.4f, %.4f, %.4f)",
hue * 255,
saturation * 255,
luminosity * 255
);
pixel_wand_output = NewPixelWand();
if (PixelSetColor(pixel_wand_output, hslString) == MagickFalse) {
printf("Failed to set color");
exit(-1);
}
red = PixelGetRed(pixel_wand_output);
green = PixelGetGreen(pixel_wand_output);
blue = PixelGetBlue(pixel_wand_output);
printf("Input color: %s \n", inputColor);
printf(
"Final color: rgb(%.2f, %.2f, %.2f)\n",
red * 255,
green * 255,
blue * 255
);
MagickWandTerminus();
MagickWandTerminus();
return(0);
}