Vuo  2.0.2
VuoImageFormat.c
Go to the documentation of this file.
1 
10 #include "type.h"
11 #include "VuoImageFormat.h"
12 #include "VuoList_VuoImageFormat.h"
13 
15 #ifdef VUO_COMPILER
17  "title" : "Image Format",
18  "description" : "Available formats when exporting images from Vuo.",
19  "keywords" : [ ],
20  "version" : "1.0.0",
21  "dependencies" : [
22  "VuoList_VuoImageFormat"
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  VuoImageFormat value = VuoImageFormat_PNG;
39 
40  if (! strcmp(valueAsString, "PNG")) {
41  value = VuoImageFormat_PNG;
42  } else if (! strcmp(valueAsString, "JPEG")) {
43  value = VuoImageFormat_JPEG;
44  } else if (! strcmp(valueAsString, "TIFF")) {
45  value = VuoImageFormat_TIFF;
46  } else if (! strcmp(valueAsString, "BMP")) {
47  value = VuoImageFormat_BMP;
48  } else if (! strcmp(valueAsString, "HDR")) {
49  value = VuoImageFormat_HDR;
50  } else if (! strcmp(valueAsString, "EXR")) {
51  value = VuoImageFormat_EXR;
52  } else if (! strcmp(valueAsString, "GIF")) {
53  value = VuoImageFormat_GIF;
54  } else if (! strcmp(valueAsString, "TARGA")) {
55  value = VuoImageFormat_TARGA;
56  }
57  else if (! strcmp(valueAsString, "WEBP"))
58  value = VuoImageFormat_WEBP;
59 
60  return value;
61 }
62 
68 {
69  char *valueAsString = "";
70 
71  switch (value) {
72  case VuoImageFormat_PNG:
73  valueAsString = "PNG";
74  break;
75  case VuoImageFormat_JPEG:
76  valueAsString = "JPEG";
77  break;
78  case VuoImageFormat_TIFF:
79  valueAsString = "TIFF";
80  break;
81  case VuoImageFormat_BMP:
82  valueAsString = "BMP";
83  break;
84  case VuoImageFormat_HDR:
85  valueAsString = "HDR";
86  break;
87  case VuoImageFormat_EXR:
88  valueAsString = "EXR";
89  break;
90  case VuoImageFormat_GIF:
91  valueAsString = "GIF";
92  break;
93  case VuoImageFormat_TARGA:
94  valueAsString = "TARGA";
95  break;
96  case VuoImageFormat_WEBP:
97  valueAsString = "WEBP";
98  break;
99  }
100 
101  return json_object_new_string(valueAsString);
102 }
103 
108 {
110  VuoListAppendValue_VuoImageFormat(l, VuoImageFormat_PNG);
111  VuoListAppendValue_VuoImageFormat(l, VuoImageFormat_JPEG);
112  VuoListAppendValue_VuoImageFormat(l, VuoImageFormat_TIFF);
113  VuoListAppendValue_VuoImageFormat(l, VuoImageFormat_BMP);
114  VuoListAppendValue_VuoImageFormat(l, VuoImageFormat_HDR);
115  VuoListAppendValue_VuoImageFormat(l, VuoImageFormat_EXR);
116  VuoListAppendValue_VuoImageFormat(l, VuoImageFormat_GIF);
117  VuoListAppendValue_VuoImageFormat(l, VuoImageFormat_TARGA);
118  VuoListAppendValue_VuoImageFormat(l, VuoImageFormat_WEBP);
119  return l;
120 }
121 
127 {
128  char *valueAsString = "";
129 
130  switch (value) {
131  case VuoImageFormat_PNG:
132  valueAsString = "PNG";
133  break;
134  case VuoImageFormat_JPEG:
135  valueAsString = "JPEG";
136  break;
137  case VuoImageFormat_TIFF:
138  valueAsString = "TIFF";
139  break;
140  case VuoImageFormat_BMP:
141  valueAsString = "BMP";
142  break;
143  case VuoImageFormat_HDR:
144  valueAsString = "HDR";
145  break;
146  case VuoImageFormat_EXR:
147  valueAsString = "EXR";
148  break;
149  case VuoImageFormat_GIF:
150  valueAsString = "GIF";
151  break;
152  case VuoImageFormat_TARGA:
153  valueAsString = "TARGA";
154  break;
155  case VuoImageFormat_WEBP:
156  valueAsString = "WEBP";
157  break;
158  }
159 
160  return strdup(valueAsString);
161 }
162 
168 {
169  struct json_object *js = json_object_new_array();
170 
171  if (format == VuoImageFormat_PNG)
172  json_object_array_add(js, json_object_new_string("png"));
173  else if (format == VuoImageFormat_JPEG)
174  {
175  json_object_array_add(js, json_object_new_string("jpg"));
176  json_object_array_add(js, json_object_new_string("jpeg"));
177  }
178  else if (format == VuoImageFormat_TIFF)
179  {
180  json_object_array_add(js, json_object_new_string("tif"));
181  json_object_array_add(js, json_object_new_string("tiff"));
182  }
183  else if (format == VuoImageFormat_BMP)
184  json_object_array_add(js, json_object_new_string("bmp"));
185  else if (format == VuoImageFormat_HDR)
186  json_object_array_add(js, json_object_new_string("hdr"));
187  else if (format == VuoImageFormat_EXR)
188  json_object_array_add(js, json_object_new_string("exr"));
189  else if (format == VuoImageFormat_GIF)
190  json_object_array_add(js, json_object_new_string("gif"));
191  else if (format == VuoImageFormat_TARGA)
192  {
193  json_object_array_add(js, json_object_new_string("tga"));
194  json_object_array_add(js, json_object_new_string("targa"));
195  }
196  else if (format == VuoImageFormat_WEBP)
197  json_object_array_add(js, json_object_new_string("webp"));
198 
199  return js;
200 }
201 
207 {
208  char *valueAsString = "";
209 
210  switch (value) {
211  case VuoImageFormat_PNG:
212  valueAsString = "png";
213  break;
214  case VuoImageFormat_JPEG:
215  valueAsString = "jpeg";
216  break;
217  case VuoImageFormat_TIFF:
218  valueAsString = "tiff";
219  break;
220  case VuoImageFormat_BMP:
221  valueAsString = "bmp";
222  break;
223  case VuoImageFormat_HDR:
224  valueAsString = "hdr";
225  break;
226  case VuoImageFormat_EXR:
227  valueAsString = "exr";
228  break;
229  case VuoImageFormat_GIF:
230  valueAsString = "gif";
231  break;
232  case VuoImageFormat_TARGA:
233  valueAsString = "tga";
234  break;
235  case VuoImageFormat_WEBP:
236  valueAsString = "webp";
237  break;
238  }
239 
240  return strdup(valueAsString);
241 }
242 
246 bool VuoImageFormat_areEqual(const VuoImageFormat value1, const VuoImageFormat value2)
247 {
248  return value1 == value2;
249 }
250 
255 {
256  return value1 < value2;
257 }