Vuo  2.0.0
VuoThresholdType.c
Go to the documentation of this file.
1 
10 #include "type.h"
11 #include "VuoThresholdType.h"
13 
15 #ifdef VUO_COMPILER
17  "title" : "Brightness Type",
18  "description" : "How to determine the brightness of a color",
19  "keywords" : [ "mask", "color" ],
20  "version" : "1.0.0",
21  "dependencies" : [
22  "VuoList_VuoThresholdType"
23  ]
24  });
25 #endif
26 
33 {
34  const char *valueAsString = "";
35  if (json_object_get_type(js) == json_type_string)
36  valueAsString = json_object_get_string(js);
37 
38  VuoThresholdType value = VuoThresholdType_Rec601;
39 
40  if (!strcmp(valueAsString, "rec709"))
41  value = VuoThresholdType_Rec709;
42  else if (!strcmp(valueAsString, "desaturate"))
43  value = VuoThresholdType_Desaturate;
44  else if (!strcmp(valueAsString, "rgb"))
45  value = VuoThresholdType_RGB;
46  else if (!strcmp(valueAsString, "rgb-average"))
47  value = VuoThresholdType_RGBAverage;
48  else if (!strcmp(valueAsString, "rgb-maximum"))
49  value = VuoThresholdType_RGBMaximum;
50  else if (!strcmp(valueAsString, "rgb-minimum"))
51  value = VuoThresholdType_RGBMinimum;
52  else if( !strcmp(valueAsString, "red"))
53  value = VuoThresholdType_Red;
54  else if( !strcmp(valueAsString, "green"))
55  value = VuoThresholdType_Green;
56  else if (!strcmp(valueAsString, "blue"))
57  value = VuoThresholdType_Blue;
58  else if(!strcmp(valueAsString, "alpha"))
59  value = VuoThresholdType_Alpha;
60 
61  return value;
62 }
63 
69 {
70  char *valueAsString;
71 
72  switch (value)
73  {
74  case VuoThresholdType_Rec709:
75  valueAsString = "rec709";
76  break;
77 
78  case VuoThresholdType_Desaturate:
79  valueAsString = "desaturate";
80  break;
81 
82  case VuoThresholdType_RGB:
83  valueAsString = "rgb";
84  break;
85 
86  case VuoThresholdType_RGBAverage:
87  valueAsString = "rgb-average";
88  break;
89 
90  case VuoThresholdType_RGBMaximum:
91  valueAsString = "rgb-maximum";
92  break;
93 
94  case VuoThresholdType_RGBMinimum:
95  valueAsString = "rgb-minimum";
96  break;
97 
98  case VuoThresholdType_Red:
99  valueAsString = "red";
100  break;
101 
102  case VuoThresholdType_Green:
103  valueAsString = "green";
104  break;
105 
106  case VuoThresholdType_Blue:
107  valueAsString = "blue";
108  break;
109 
110  case VuoThresholdType_Alpha:
111  valueAsString = "alpha";
112  break;
113 
114  default:
115  valueAsString = "rec601";
116  }
117  return json_object_new_string(valueAsString);
118 }
119 
124 {
126  VuoListAppendValue_VuoThresholdType(l, VuoThresholdType_Rec601);
127  VuoListAppendValue_VuoThresholdType(l, VuoThresholdType_Rec709);
128  VuoListAppendValue_VuoThresholdType(l, VuoThresholdType_Desaturate);
129  VuoListAppendValue_VuoThresholdType(l, VuoThresholdType_RGB);
130  VuoListAppendValue_VuoThresholdType(l, VuoThresholdType_RGBAverage);
131  VuoListAppendValue_VuoThresholdType(l, VuoThresholdType_RGBMaximum);
132  VuoListAppendValue_VuoThresholdType(l, VuoThresholdType_RGBMinimum);
133  VuoListAppendValue_VuoThresholdType(l, VuoThresholdType_Red);
134  VuoListAppendValue_VuoThresholdType(l, VuoThresholdType_Green);
135  VuoListAppendValue_VuoThresholdType(l, VuoThresholdType_Blue);
136  VuoListAppendValue_VuoThresholdType(l, VuoThresholdType_Alpha);
137  return l;
138 }
144 {
145  char *valueAsString = "";
146 
147  switch (value)
148  {
149  case VuoThresholdType_Rec601:
150  valueAsString = "Perceptual (ITU Rec. 601 / NTSC CRT)";
151  break;
152 
153  case VuoThresholdType_Rec709:
154  valueAsString = "Perceptual (ITU Rec. 709 / HDTV)";
155  break;
156 
157  case VuoThresholdType_Desaturate:
158  valueAsString = "Desaturate (HSL)";
159  break;
160 
161  case VuoThresholdType_RGB:
162  valueAsString = "Individual Components (RGB)";
163  break;
164 
165  case VuoThresholdType_RGBAverage:
166  valueAsString = "Average Components (RGB)";
167  break;
168 
169  case VuoThresholdType_RGBMaximum:
170  valueAsString = "Lightest Components (RGB)";
171  break;
172 
173  case VuoThresholdType_RGBMinimum:
174  valueAsString = "Darkest Components (RGB)";
175  break;
176 
177  case VuoThresholdType_Red:
178  valueAsString = "Red";
179  break;
180 
181  case VuoThresholdType_Green:
182  valueAsString = "Green";
183  break;
184 
185  case VuoThresholdType_Blue:
186  valueAsString = "Blue";
187  break;
188 
189  case VuoThresholdType_Alpha:
190  valueAsString = "Opacity";
191  break;
192  }
193 
194  return strdup(valueAsString);
195 }