| 1 | /* |
| 2 | test_pat_C |
| 3 | This frei0r plugin generates cross sections of color spaces |
| 4 | Version 0.1 aug 2010 |
| 5 | |
| 6 | Copyright (C) 2010 Marko Cebokli http://lea.hamradio.si/~s57uuu |
| 7 | |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or modify |
| 10 | it under the terms of the GNU General Public License as published by |
| 11 | the Free Software Foundation; either version 2 of the License, or |
| 12 | (at your option) any later version. |
| 13 | |
| 14 | This program is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with this program; if not, write to the Free Software |
| 21 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 | |
| 23 | */ |
| 24 | |
| 25 | /*********************************************************** |
| 26 | Test patterns: cross sections of color spaces |
| 27 | *************************************************************/ |
| 28 | |
| 29 | //compile: gcc -Wall -c -fPIC test_pat_C.c -o test_pat_C.o |
| 30 | |
| 31 | //link: gcc -lm -shared -o test_pat_C.so test_pat_C.o |
| 32 | |
| 33 | #include <stdlib.h> |
| 34 | #include <assert.h> |
| 35 | #include <math.h> |
| 36 | |
| 37 | #include "frei0r.h"cxx . . $ `<file>/include/frei0r.h`/ |
| 38 | |
| 39 | |
| 40 | |
| 41 | double PIcxx . . $ PI.=3.14159265358979; |
| 42 | |
| 43 | typedef structcxx . . $ $anonymous_type_35b3be2327d9ad43_0# |
| 44 | { |
| 45 | float rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.; |
| 46 | float gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.; |
| 47 | float bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.; |
| 48 | float acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.; |
| 49 | } float_rgbacxx . . $ float_rgba#; |
| 50 | |
| 51 | //-------------------------------------------------------------- |
| 52 | void draw_rectanglecxx . . $ draw_rectangle(bea8b81928a0543e).(float_rgbacxx . . $ float_rgba# *s, int w, int h, float x, float y, float wr, float hr, float_rgbacxx . . $ float_rgba# c) |
| 53 | { |
| 54 | int i,j; |
| 55 | int zx,kx,zy,ky; |
| 56 | |
| 57 | zx=x; if (zx<0) zx=0; |
| 58 | zy=y; if (zy<0) zy=0; |
| 59 | kx=x+wr; if (kx>w) kx=w; |
| 60 | ky=y+hr; if (ky>h) ky=h; |
| 61 | for (i=zy;i<ky;i++) |
| 62 | for (j=zx;j<kx;j++) |
| 63 | s[w*i+j]=c; |
| 64 | |
| 65 | } |
| 66 | |
| 67 | //------------------------------------------------------- |
| 68 | int insidecxx . . $ inside(30985c4a37e67a60).(float_rgbacxx . . $ float_rgba# c) |
| 69 | { |
| 70 | if (c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.<0.0) return 0; |
| 71 | if (c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.>1.0) return 0; |
| 72 | if (c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.<0.0) return 0; |
| 73 | if (c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.>1.0) return 0; |
| 74 | if (c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.<0.0) return 0; |
| 75 | if (c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.>1.0) return 0; |
| 76 | return 1; |
| 77 | } |
| 78 | |
| 79 | //----------------------------------------------------------- |
| 80 | //os: 0=RG(B) 1=GB(R) 2=BR(G) |
| 81 | //a: value on third axis |
| 82 | void risi_presek_rgbcxx . . $ risi_presek_rgb(a0aeb67ff6c0cb19).(float_rgbacxx . . $ float_rgba# *s, int w, int h, float x, float y, float wr, float hr, int os, float a) |
| 83 | { |
| 84 | int i,j; |
| 85 | int zx,kx,zy,ky; |
| 86 | float_rgbacxx . . $ float_rgba# c; |
| 87 | float d1,d2; |
| 88 | |
| 89 | zx=x; if (zx<0) zx=0; |
| 90 | zy=y; if (zy<0) zy=0; |
| 91 | kx=x+wr; if (kx>w) kx=w; |
| 92 | ky=y+hr; if (ky>h) ky=h; |
| 93 | switch (os) |
| 94 | { |
| 95 | case 0: |
| 96 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=a; |
| 97 | d1=1.0/hr; |
| 98 | d2=1.0/wr; |
| 99 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=0.0; |
| 100 | for (i=zy;i<ky;i++) |
| 101 | { |
| 102 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.+d1; |
| 103 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=0.0; |
| 104 | for (j=zx;j<kx;j++) |
| 105 | { |
| 106 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.+d2; |
| 107 | c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; |
| 108 | s[w*i+j]=c; |
| 109 | } |
| 110 | } |
| 111 | break; |
| 112 | case 1: |
| 113 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=a; |
| 114 | d1=1.0/hr; |
| 115 | d2=1.0/wr; |
| 116 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=0.0; |
| 117 | for (i=zy;i<ky;i++) |
| 118 | { |
| 119 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.+d1; |
| 120 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=0.0; |
| 121 | for (j=zx;j<kx;j++) |
| 122 | { |
| 123 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.+d2; |
| 124 | c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; |
| 125 | s[w*i+j]=c; |
| 126 | } |
| 127 | } |
| 128 | break; |
| 129 | case 2: |
| 130 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=a; |
| 131 | d1=1.0/hr; |
| 132 | d2=1.0/wr; |
| 133 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=0.0; |
| 134 | for (i=zy;i<ky;i++) |
| 135 | { |
| 136 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.+d1; |
| 137 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=0.0; |
| 138 | for (j=zx;j<kx;j++) |
| 139 | { |
| 140 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.+d2; |
| 141 | c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; |
| 142 | s[w*i+j]=c; |
| 143 | } |
| 144 | } |
| 145 | break; |
| 146 | default: |
| 147 | break; |
| 148 | } |
| 149 | |
| 150 | } |
| 151 | |
| 152 | //----------------------------------------------------------- |
| 153 | //PAZI!!!! ali so meje -0.5 do 0.5 za Pr in Pb prave? |
| 154 | //os: 0=Y'Pr(Pb) 1=PrPb(Y) 2=PbY'(Pr) |
| 155 | //a: value on third axis |
| 156 | void risi_presek_yprpb601cxx . . $ risi_presek_yprpb601(a0aeb67ff6c0cb19).(float_rgbacxx . . $ float_rgba# *s, int w, int h, float x, float y, float wr, float hr, int os, float a) |
| 157 | { |
| 158 | int i,j; |
| 159 | int zx,kx,zy,ky; |
| 160 | float_rgbacxx . . $ float_rgba# c; |
| 161 | float d1,d2,yy,pr,pb; |
| 162 | |
| 163 | zx=x; if (zx<0) zx=0; |
| 164 | zy=y; if (zy<0) zy=0; |
| 165 | kx=x+wr; if (kx>w) kx=w; |
| 166 | ky=y+hr; if (ky>h) ky=h; |
| 167 | switch (os) |
| 168 | { |
| 169 | case 0: |
| 170 | pb=a-0.5; |
| 171 | d1=1.0/hr; |
| 172 | d2=1.0/wr; |
| 173 | yy=0.0; |
| 174 | for (i=zy;i<ky;i++) |
| 175 | { |
| 176 | yy=yy+d1; |
| 177 | pr=-0.5; |
| 178 | for (j=zx;j<kx;j++) |
| 179 | { |
| 180 | pr=pr+d2; |
| 181 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=pr+yy; |
| 182 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=pb+yy; |
| 183 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=(yy-0.3*c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.-0.1*c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.)/0.6; |
| 184 | c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; |
| 185 | if (insidecxx . . $ inside(30985c4a37e67a60).(c)==1) s[w*i+j]=c; |
| 186 | } |
| 187 | } |
| 188 | break; |
| 189 | case 1: |
| 190 | yy=a; |
| 191 | d1=1.0/hr; |
| 192 | d2=1.0/wr; |
| 193 | pr=-0.5; |
| 194 | for (i=zy;i<ky;i++) |
| 195 | { |
| 196 | pr=pr+d1; |
| 197 | pb=-0.5; |
| 198 | for (j=zx;j<kx;j++) |
| 199 | { |
| 200 | pb=pb+d2; |
| 201 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=pr+yy; |
| 202 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=pb+yy; |
| 203 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=(yy-0.3*c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.-0.1*c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.)/0.6; |
| 204 | c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; |
| 205 | if (insidecxx . . $ inside(30985c4a37e67a60).(c)==1) s[w*i+j]=c; |
| 206 | } |
| 207 | } |
| 208 | break; |
| 209 | case 2: |
| 210 | pr=a-0.5; |
| 211 | d1=1.0/hr; |
| 212 | d2=1.0/wr; |
| 213 | pb=-0.5; |
| 214 | for (i=zy;i<ky;i++) |
| 215 | { |
| 216 | pb=pb+d1; |
| 217 | yy=0.0; |
| 218 | for (j=zx;j<kx;j++) |
| 219 | { |
| 220 | yy=yy+d2; |
| 221 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=pr+yy; |
| 222 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=pb+yy; |
| 223 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=(yy-0.3*c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.-0.1*c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.)/0.6; |
| 224 | c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; |
| 225 | if (insidecxx . . $ inside(30985c4a37e67a60).(c)==1) s[w*i+j]=c; |
| 226 | } |
| 227 | } |
| 228 | break; |
| 229 | default: |
| 230 | break; |
| 231 | } |
| 232 | |
| 233 | } |
| 234 | |
| 235 | //----------------------------------------------------------- |
| 236 | //PAZI!!!! ali so meje -1.0 do 1.0 za aa in bb prave? |
| 237 | //os: 0=AB(I) 1=BI(A) 2=IA(B) |
| 238 | //a: value on third axis |
| 239 | void risi_presek_abicxx . . $ risi_presek_abi(a0aeb67ff6c0cb19).(float_rgbacxx . . $ float_rgba# *s, int w, int h, float x, float y, float wr, float hr, int os, float a) |
| 240 | { |
| 241 | int i,j; |
| 242 | int zx,kx,zy,ky; |
| 243 | float_rgbacxx . . $ float_rgba# c; |
| 244 | float d1,d2,aa,bb,ii,k3,ik3; |
| 245 | |
| 246 | zx=x; if (zx<0) zx=0; |
| 247 | zy=y; if (zy<0) zy=0; |
| 248 | kx=x+wr; if (kx>w) kx=w; |
| 249 | ky=y+hr; if (ky>h) ky=h; |
| 250 | k3=sqrtf(3.0)/2.0; |
| 251 | ik3=0.5/k3; |
| 252 | |
| 253 | switch (os) |
| 254 | { |
| 255 | case 0: |
| 256 | ii=a; |
| 257 | d1=2.0/hr; |
| 258 | d2=2.0/wr; |
| 259 | aa=-1.0; |
| 260 | for (i=zy;i<ky;i++) |
| 261 | { |
| 262 | aa=aa+d1; |
| 263 | bb=-1.0; |
| 264 | for (j=zx;j<kx;j++) |
| 265 | { |
| 266 | bb=bb+d2; |
| 267 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=(aa+1.5*ii)*0.666666666; |
| 268 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=ii-0.333333*aa-ik3*bb; |
| 269 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=bb+k3*c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.; |
| 270 | c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; |
| 271 | if (insidecxx . . $ inside(30985c4a37e67a60).(c)==1) s[w*i+j]=c; |
| 272 | } |
| 273 | } |
| 274 | break; |
| 275 | case 1: |
| 276 | aa=2.0*a-1.0; |
| 277 | d1=2.0/hr; |
| 278 | d2=1.0/wr; |
| 279 | bb=-1.0; |
| 280 | for (i=zy;i<ky;i++) |
| 281 | { |
| 282 | bb=bb+d1; |
| 283 | ii=0.0; |
| 284 | for (j=zx;j<kx;j++) |
| 285 | { |
| 286 | ii=ii+d2; |
| 287 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=(aa+1.5*ii)*0.666666666; |
| 288 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=ii-0.333333*aa-ik3*bb; |
| 289 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=bb+k3*c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.; |
| 290 | c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; |
| 291 | if (insidecxx . . $ inside(30985c4a37e67a60).(c)==1) s[w*i+j]=c; |
| 292 | } |
| 293 | } |
| 294 | break; |
| 295 | case 2: |
| 296 | bb=2.0*a-1.0; |
| 297 | d1=1.0/hr; |
| 298 | d2=2.0/wr; |
| 299 | ii=0.0; |
| 300 | for (i=zy;i<ky;i++) |
| 301 | { |
| 302 | ii=ii+d1; |
| 303 | aa=-1.0; |
| 304 | for (j=zx;j<kx;j++) |
| 305 | { |
| 306 | aa=aa+d2; |
| 307 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=(aa+1.5*ii)*0.666666666; |
| 308 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=ii-0.333333*aa-ik3*bb; |
| 309 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=bb+k3*c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.; |
| 310 | c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; |
| 311 | if (insidecxx . . $ inside(30985c4a37e67a60).(c)==1) s[w*i+j]=c; |
| 312 | } |
| 313 | } |
| 314 | break; |
| 315 | default: |
| 316 | break; |
| 317 | } |
| 318 | |
| 319 | } |
| 320 | |
| 321 | //----------------------------------------------------------- |
| 322 | //os: 0=HC(I) 1=CI(H) 2=IH(C) |
| 323 | //a: value on third axis |
| 324 | void risi_presek_hcicxx . . $ risi_presek_hci(a0aeb67ff6c0cb19).(float_rgbacxx . . $ float_rgba# *s, int w, int h, float x, float y, float wr, float hr, int os, float a) |
| 325 | { |
| 326 | int i,j; |
| 327 | int zx,kx,zy,ky; |
| 328 | float_rgbacxx . . $ float_rgba# c; |
| 329 | float d1,d2,aa,bb,ii,k3,ik3,hh,cc; |
| 330 | |
| 331 | zx=x; if (zx<0) zx=0; |
| 332 | zy=y; if (zy<0) zy=0; |
| 333 | kx=x+wr; if (kx>w) kx=w; |
| 334 | ky=y+hr; if (ky>h) ky=h; |
| 335 | k3=sqrtf(3.0)/2.0; |
| 336 | ik3=0.5/k3; |
| 337 | |
| 338 | switch (os) |
| 339 | { |
| 340 | case 0: |
| 341 | ii=a; |
| 342 | d1=2.0*PIcxx . . $ PI./hr; |
| 343 | d2=1.0/wr; |
| 344 | hh=0.0; |
| 345 | for (i=zy;i<ky;i++) |
| 346 | { |
| 347 | hh=hh+d1; |
| 348 | cc=0.0; |
| 349 | for (j=zx;j<kx;j++) |
| 350 | { |
| 351 | cc=cc+d2; |
| 352 | aa=cc*cos(hh); |
| 353 | bb=cc*sin(hh); |
| 354 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=(aa+1.5*ii)*0.666666666; |
| 355 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=ii-0.333333*aa-ik3*bb; |
| 356 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=bb+k3*c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.; |
| 357 | c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; |
| 358 | if (insidecxx . . $ inside(30985c4a37e67a60).(c)==1) s[w*i+j]=c; |
| 359 | } |
| 360 | } |
| 361 | break; |
| 362 | case 1: |
| 363 | hh=a*2.0*PIcxx . . $ PI.; |
| 364 | d1=1.0/hr; |
| 365 | d2=1.0/wr; |
| 366 | cc=0.0; |
| 367 | for (i=zy;i<ky;i++) |
| 368 | { |
| 369 | cc=cc+d1; |
| 370 | ii=0.0; |
| 371 | for (j=zx;j<kx;j++) |
| 372 | { |
| 373 | ii=ii+d2; |
| 374 | aa=cc*cos(hh); |
| 375 | bb=cc*sin(hh); |
| 376 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=(aa+1.5*ii)*0.666666666; |
| 377 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=ii-0.333333*aa-ik3*bb; |
| 378 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=bb+k3*c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.; |
| 379 | c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; |
| 380 | if (insidecxx . . $ inside(30985c4a37e67a60).(c)==1) s[w*i+j]=c; |
| 381 | } |
| 382 | } |
| 383 | break; |
| 384 | case 2: |
| 385 | cc=a; |
| 386 | d1=1.0/hr; |
| 387 | d2=2.0*PIcxx . . $ PI./wr; |
| 388 | ii=0.0; |
| 389 | for (i=zy;i<ky;i++) |
| 390 | { |
| 391 | ii=ii+d1; |
| 392 | hh=0.0; |
| 393 | for (j=zx;j<kx;j++) |
| 394 | { |
| 395 | hh=hh+d2; |
| 396 | aa=cc*cos(hh); |
| 397 | bb=cc*sin(hh); |
| 398 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=(aa+1.5*ii)*0.666666666; |
| 399 | c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=ii-0.333333*aa-ik3*bb; |
| 400 | c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=bb+k3*c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.; |
| 401 | c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; |
| 402 | if (insidecxx . . $ inside(30985c4a37e67a60).(c)==1) s[w*i+j]=c; |
| 403 | } |
| 404 | } |
| 405 | break; |
| 406 | default: |
| 407 | break; |
| 408 | } |
| 409 | |
| 410 | } |
| 411 | |
| 412 | //----------------------------------------------------- |
| 413 | //converts the internal RGB float image into |
| 414 | //Frei0r rgba8888 color |
| 415 | //sets alpha to opaque |
| 416 | void floatrgba2colorcxx . . $ floatrgba2color(7e35642528ab9dd1).(float_rgbacxx . . $ float_rgba# *sl, uint32_tcxx . . $ uint32_t#* outframe, int w , int h) |
| 417 | { |
| 418 | int i; |
| 419 | uint32_tcxx . . $ uint32_t# p; |
| 420 | |
| 421 | for (i=0;i<w*h;i++) |
| 422 | { |
| 423 | p=(uint32_tcxx . . $ uint32_t#)(255.0*sl[i].bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.) & 0xFF; |
| 424 | p=(p<<8) + ((uint32_tcxx . . $ uint32_t#)(255.0*sl[i].gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.) & 0xFF); |
| 425 | p=(p<<8) + ((uint32_tcxx . . $ uint32_t#)(255.0*sl[i].rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.) & 0xFF); |
| 426 | outframe[i] = p + 0xFF000000; //no transparency |
| 427 | } |
| 428 | |
| 429 | } |
| 430 | |
| 431 | //----------------------------------------------------- |
| 432 | //stretch [0...1] to parameter range [min...max] linear |
| 433 | float map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(double v, float min, float max) |
| 434 | { |
| 435 | return min+(max-min)*v; |
| 436 | } |
| 437 | |
| 438 | //----------------------------------------------------- |
| 439 | //collapse from parameter range [min...max] to [0...1] linear |
| 440 | double map_value_backwardcxx . . $ map_value_backward(937b104db0ceee62).(float v, float min, float max) |
| 441 | { |
| 442 | return (v-min)/(max-min); |
| 443 | } |
| 444 | |
| 445 | //----------------------------------------------------- |
| 446 | //stretch [0...1] to parameter range [min...max] logarithmic |
| 447 | //min and max must be positive! |
| 448 | float map_value_forward_logcxx . . $ map_value_forward_log(1935fda23fc189b2).(double v, float min, float max) |
| 449 | { |
| 450 | float sr,k; |
| 451 | |
| 452 | sr=sqrtf(min*max); |
| 453 | k=2.0*log(max/sr); |
| 454 | return sr*expf(k*(v-0.5)); |
| 455 | } |
| 456 | |
| 457 | //----------------------------------------------------- |
| 458 | //collapse from parameter range [min...max] to [0...1] logarithmic |
| 459 | //min and max must be positive! |
| 460 | double map_value_backward_logcxx . . $ map_value_backward_log(937b104db0ceee62).(float v, float min, float max) |
| 461 | { |
| 462 | float sr,k; |
| 463 | |
| 464 | sr=sqrtf(min*max); |
| 465 | k=2.0*log(max/sr); |
| 466 | return logf(v/sr)/k+0.5; |
| 467 | } |
| 468 | |
| 469 | //************************************************** |
| 470 | //obligatory frei0r stuff follows |
| 471 | |
| 472 | //------------------------------------------------ |
| 473 | //this structure holds an instance of the test_pat_C plugin |
| 474 | typedef structcxx . . $ $anonymous_type_35b3be2327d9ad43_1# |
| 475 | { |
| 476 | unsigned int wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w.; |
| 477 | unsigned int hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h.; |
| 478 | |
| 479 | int spccxx . . $ $anonymous_type_35b3be2327d9ad43_1#spc.; |
| 480 | int cscxx . . $ $anonymous_type_35b3be2327d9ad43_1#cs.; |
| 481 | float thavcxx . . $ $anonymous_type_35b3be2327d9ad43_1#thav.; |
| 482 | int fscxx . . $ $anonymous_type_35b3be2327d9ad43_1#fs.; |
| 483 | |
| 484 | float_rgbacxx . . $ float_rgba# *slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl.; |
| 485 | |
| 486 | } tp_inst_tcxx . . $ tp_inst_t#; |
| 487 | |
| 488 | //---------------------------------------------------- |
| 489 | int f0r_initcxx . . $ f0r_init(b126dc7c1de90089).() |
| 490 | { |
| 491 | return 1; |
| 492 | } |
| 493 | |
| 494 | //-------------------------------------------------- |
| 495 | void f0r_deinitcxx . . $ f0r_deinit(49f6e7a06ebc5aa8).() |
| 496 | { /* no initialization required */ } |
| 497 | |
| 498 | //-------------------------------------------------- |
| 499 | void f0r_get_plugin_infocxx . . $ f0r_get_plugin_info(35d753456c0ea59c).(f0r_plugin_info_tcxx . . $ f0r_plugin_info_t#* tp_info) |
| 500 | { |
| 501 | tp_info->namecxx . . $ f0r_plugin_info#name. = "test_pat_C"; |
| 502 | tp_info->authorcxx . . $ f0r_plugin_info#author. = "Marko Cebokli"; |
| 503 | tp_info->plugin_typecxx . . $ f0r_plugin_info#plugin_type. = F0R_PLUGIN_TYPE_SOURCEcxx . . $ `include/frei0r.h:249:9`!; |
| 504 | // tp_info->plugin_type = F0R_PLUGIN_TYPE_FILTER; |
| 505 | tp_info->color_modelcxx . . $ f0r_plugin_info#color_model. = F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`!; |
| 506 | tp_info->frei0r_versioncxx . . $ f0r_plugin_info#frei0r_version. = FREI0R_MAJOR_VERSIONcxx . . $ `include/frei0r.h:217:9`!; |
| 507 | tp_info->major_versioncxx . . $ f0r_plugin_info#major_version. = 0; |
| 508 | tp_info->minor_versioncxx . . $ f0r_plugin_info#minor_version. = 1; |
| 509 | tp_info->num_paramscxx . . $ f0r_plugin_info#num_params. = 4; |
| 510 | tp_info->explanationcxx . . $ f0r_plugin_info#explanation. = "Generates cross sections of color spaces"; |
| 511 | } |
| 512 | |
| 513 | //-------------------------------------------------- |
| 514 | void f0r_get_param_infocxx . . $ f0r_get_param_info(a9f9aa7954cc4a37).(f0r_param_info_tcxx . . $ f0r_param_info_t#* info, int param_index) |
| 515 | { |
| 516 | switch (param_index) |
| 517 | { |
| 518 | case 0: |
| 519 | info->namecxx . . $ f0r_param_info#name. = "Color space"; |
| 520 | info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!; |
| 521 | info->explanationcxx . . $ f0r_param_info#explanation. = ""; |
| 522 | break; |
| 523 | case 1: |
| 524 | info->namecxx . . $ f0r_param_info#name. ="Cross section"; |
| 525 | info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!; |
| 526 | info->explanationcxx . . $ f0r_param_info#explanation. = ""; |
| 527 | break; |
| 528 | case 2: |
| 529 | info->namecxx . . $ f0r_param_info#name. = "Third axis value"; |
| 530 | info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_DOUBLEcxx . . $ `include/frei0r.h:383:9`!; |
| 531 | info->explanationcxx . . $ f0r_param_info#explanation. = ""; |
| 532 | break; |
| 533 | case 3: |
| 534 | info->namecxx . . $ f0r_param_info#name. = "Fullscreen"; |
| 535 | info->typecxx . . $ f0r_param_info#type. = F0R_PARAM_BOOLcxx . . $ `include/frei0r.h:377:9`!; |
| 536 | info->explanationcxx . . $ f0r_param_info#explanation. = ""; |
| 537 | break; |
| 538 | } |
| 539 | } |
| 540 | |
| 541 | //-------------------------------------------------- |
| 542 | f0r_instance_tcxx . . $ f0r_instance_t# f0r_constructcxx . . $ f0r_construct(da3f471cd007a696).(unsigned int width, unsigned int height) |
| 543 | { |
| 544 | int x0,y0,velx,vely; |
| 545 | float_rgbacxx . . $ float_rgba# c; |
| 546 | tp_inst_tcxx . . $ tp_inst_t#* inst = calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(*inst)); |
| 547 | inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w. = width; |
| 548 | inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h. = height; |
| 549 | |
| 550 | inst->spccxx . . $ $anonymous_type_35b3be2327d9ad43_1#spc.=0; |
| 551 | inst->cscxx . . $ $anonymous_type_35b3be2327d9ad43_1#cs.=0; |
| 552 | inst->thavcxx . . $ $anonymous_type_35b3be2327d9ad43_1#thav.=0.5; |
| 553 | inst->fscxx . . $ $anonymous_type_35b3be2327d9ad43_1#fs.=0; |
| 554 | |
| 555 | inst->slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl.=(float_rgbacxx . . $ float_rgba#*)calloccxx . . $ calloc(63a7bf2941bfcd7a).(width*height,sizeof(float_rgbacxx . . $ float_rgba#)); |
| 556 | |
| 557 | x0=(inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w.-3*inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h./4)/2; |
| 558 | y0=inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h./8; |
| 559 | velx=3*inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h./4; |
| 560 | vely=3*inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h./4; |
| 561 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=0.5;c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=0.5;c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=0.5;c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; //gray background |
| 562 | draw_rectanglecxx . . $ draw_rectangle(bea8b81928a0543e).(inst->slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl., inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w., inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h., 0.0, 0.0, (float)inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w., (float)inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h., c); |
| 563 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=0.4;c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=0.4;c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=0.4;c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; //darker gray background |
| 564 | draw_rectanglecxx . . $ draw_rectangle(bea8b81928a0543e).(inst->slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl., inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w., inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h., x0, y0, velx, vely, c); |
| 565 | risi_presek_rgbcxx . . $ risi_presek_rgb(a0aeb67ff6c0cb19).(inst->slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl., inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w., inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h., x0, y0, velx, vely, inst->cscxx . . $ $anonymous_type_35b3be2327d9ad43_1#cs., inst->thavcxx . . $ $anonymous_type_35b3be2327d9ad43_1#thav.); |
| 566 | |
| 567 | return (f0r_instance_tcxx . . $ f0r_instance_t#)inst; |
| 568 | } |
| 569 | |
| 570 | //-------------------------------------------------- |
| 571 | void f0r_destructcxx . . $ f0r_destruct(5d22bdacc48458e8).(f0r_instance_tcxx . . $ f0r_instance_t# instance) |
| 572 | { |
| 573 | tp_inst_tcxx . . $ tp_inst_t#* inst = (tp_inst_tcxx . . $ tp_inst_t#*)instance; |
| 574 | |
| 575 | freecxx . . $ free(5d22bdacc48458e8).(inst->slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl.); |
| 576 | freecxx . . $ free(5d22bdacc48458e8).(inst); |
| 577 | } |
| 578 | |
| 579 | //-------------------------------------------------- |
| 580 | void f0r_set_param_valuecxx . . $ f0r_set_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance, f0r_param_tcxx . . $ f0r_param_t# param, int param_index) |
| 581 | { |
| 582 | tp_inst_tcxx . . $ tp_inst_t#* inst = (tp_inst_tcxx . . $ tp_inst_t#*)instance; |
| 583 | f0r_param_doublecxx . . $ f0r_param_double#* p = (f0r_param_doublecxx . . $ f0r_param_double#*) param; |
| 584 | int chg,tmpi,x0,y0,velx,vely; |
| 585 | float tmpf; |
| 586 | float_rgbacxx . . $ float_rgba# c; |
| 587 | |
| 588 | chg=0; |
| 589 | switch (param_index) |
| 590 | { |
| 591 | case 0: //color space |
| 592 | tmpf=*((double*)p); |
| 593 | if (tmpf>=1.0) |
| 594 | tmpi=(int)tmpf; |
| 595 | else |
| 596 | tmpi = map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(tmpf, 0.0, 3.9999); |
| 597 | if ((tmpi<0)||(tmpi>3.0)) break; |
| 598 | if (inst->spccxx . . $ $anonymous_type_35b3be2327d9ad43_1#spc. != tmpi) chg=1; |
| 599 | inst->spccxx . . $ $anonymous_type_35b3be2327d9ad43_1#spc. = tmpi; |
| 600 | break; |
| 601 | case 1: //cross section |
| 602 | tmpf=*((double*)p); |
| 603 | if (tmpf>=1.0) |
| 604 | tmpi=(int)tmpf; |
| 605 | else |
| 606 | tmpi = map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(tmpf, 0.0, 2.9999); |
| 607 | if ((tmpi<0)||(tmpi>2.0)) break; |
| 608 | if (inst->cscxx . . $ $anonymous_type_35b3be2327d9ad43_1#cs. != tmpi) chg=1; |
| 609 | inst->cscxx . . $ $anonymous_type_35b3be2327d9ad43_1#cs. = tmpi; |
| 610 | break; |
| 611 | case 2: //third axis value |
| 612 | tmpf = map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(*((double*)p), 0.0, 1.0); |
| 613 | if (inst->thavcxx . . $ $anonymous_type_35b3be2327d9ad43_1#thav. != tmpf) chg=1; |
| 614 | inst->thavcxx . . $ $anonymous_type_35b3be2327d9ad43_1#thav. = tmpf; |
| 615 | break; |
| 616 | case 3: //fullscreen (BOOL) |
| 617 | tmpi = map_value_forwardcxx . . $ map_value_forward(1935fda23fc189b2).(*((double*)p), 0.0, 1.0); |
| 618 | if (inst->fscxx . . $ $anonymous_type_35b3be2327d9ad43_1#fs. != tmpi) chg=1; |
| 619 | inst->fscxx . . $ $anonymous_type_35b3be2327d9ad43_1#fs. = tmpi; |
| 620 | break; |
| 621 | } |
| 622 | |
| 623 | if (chg==0) return; |
| 624 | |
| 625 | if (inst->fscxx . . $ $anonymous_type_35b3be2327d9ad43_1#fs.==0) |
| 626 | { |
| 627 | x0=(inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w.-3*inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h./4)/2; |
| 628 | y0=inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h./8; |
| 629 | velx=3*inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h./4; |
| 630 | vely=3*inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h./4; |
| 631 | } |
| 632 | else |
| 633 | { |
| 634 | x0=0; |
| 635 | y0=0; |
| 636 | velx=inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w.; |
| 637 | vely=inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h.; |
| 638 | } |
| 639 | |
| 640 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=0.5;c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=0.5;c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=0.5;c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; //gray background |
| 641 | draw_rectanglecxx . . $ draw_rectangle(bea8b81928a0543e).(inst->slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl., inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w., inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h., 0.0, 0.0, (float)inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w., (float)inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h., c); |
| 642 | c.rcxx . . $ $anonymous_type_35b3be2327d9ad43_0#r.=0.4;c.gcxx . . $ $anonymous_type_35b3be2327d9ad43_0#g.=0.4;c.bcxx . . $ $anonymous_type_35b3be2327d9ad43_0#b.=0.4;c.acxx . . $ $anonymous_type_35b3be2327d9ad43_0#a.=1.0; //darker gray background |
| 643 | draw_rectanglecxx . . $ draw_rectangle(bea8b81928a0543e).(inst->slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl., inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w., inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h., x0, y0, velx, vely, c); |
| 644 | |
| 645 | switch (inst->spccxx . . $ $anonymous_type_35b3be2327d9ad43_1#spc.) |
| 646 | { |
| 647 | case 0: |
| 648 | risi_presek_rgbcxx . . $ risi_presek_rgb(a0aeb67ff6c0cb19).(inst->slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl., inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w., inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h., x0, y0, velx, vely, inst->cscxx . . $ $anonymous_type_35b3be2327d9ad43_1#cs., inst->thavcxx . . $ $anonymous_type_35b3be2327d9ad43_1#thav.); |
| 649 | break; |
| 650 | case 1: |
| 651 | risi_presek_yprpb601cxx . . $ risi_presek_yprpb601(a0aeb67ff6c0cb19).(inst->slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl., inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w., inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h., x0, y0, velx, vely, inst->cscxx . . $ $anonymous_type_35b3be2327d9ad43_1#cs., inst->thavcxx . . $ $anonymous_type_35b3be2327d9ad43_1#thav.); |
| 652 | break; |
| 653 | case 2: |
| 654 | risi_presek_abicxx . . $ risi_presek_abi(a0aeb67ff6c0cb19).(inst->slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl., inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w., inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h., x0, y0, velx, vely, inst->cscxx . . $ $anonymous_type_35b3be2327d9ad43_1#cs., inst->thavcxx . . $ $anonymous_type_35b3be2327d9ad43_1#thav.); |
| 655 | break; |
| 656 | case 3: |
| 657 | risi_presek_hcicxx . . $ risi_presek_hci(a0aeb67ff6c0cb19).(inst->slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl., inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w., inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h., x0, y0, velx, vely, inst->cscxx . . $ $anonymous_type_35b3be2327d9ad43_1#cs., inst->thavcxx . . $ $anonymous_type_35b3be2327d9ad43_1#thav.); |
| 658 | break; |
| 659 | default: |
| 660 | break; |
| 661 | } |
| 662 | |
| 663 | } |
| 664 | |
| 665 | //------------------------------------------------- |
| 666 | void f0r_get_param_valuecxx . . $ f0r_get_param_value(5be095a8278d2bf5).(f0r_instance_tcxx . . $ f0r_instance_t# instance, f0r_param_tcxx . . $ f0r_param_t# param, int param_index) |
| 667 | { |
| 668 | tp_inst_tcxx . . $ tp_inst_t#* inst = (tp_inst_tcxx . . $ tp_inst_t#*)instance; |
| 669 | |
| 670 | f0r_param_doublecxx . . $ f0r_param_double#* p = (f0r_param_doublecxx . . $ f0r_param_double#*) param; |
| 671 | |
| 672 | switch (param_index) |
| 673 | { |
| 674 | case 0: //color space |
| 675 | *p = map_value_backwardcxx . . $ map_value_backward(937b104db0ceee62).(inst->spccxx . . $ $anonymous_type_35b3be2327d9ad43_1#spc., 0.0, 3.9999); |
| 676 | break; |
| 677 | case 1: //cross section |
| 678 | *p = map_value_backwardcxx . . $ map_value_backward(937b104db0ceee62).(inst->cscxx . . $ $anonymous_type_35b3be2327d9ad43_1#cs., 0.0, 2.9999); |
| 679 | break; |
| 680 | case 2: //third axis value |
| 681 | *p = map_value_backwardcxx . . $ map_value_backward(937b104db0ceee62).(inst->thavcxx . . $ $anonymous_type_35b3be2327d9ad43_1#thav., 0.0, 1.0); |
| 682 | break; |
| 683 | case 3: //fullscreen (BOOL) |
| 684 | *p = map_value_backward_logcxx . . $ map_value_backward_log(937b104db0ceee62).(inst->fscxx . . $ $anonymous_type_35b3be2327d9ad43_1#fs., 0.0, 1.0); |
| 685 | break; |
| 686 | } |
| 687 | } |
| 688 | |
| 689 | //--------------------------------------------------- |
| 690 | void f0r_updatecxx . . $ f0r_update(96cd7b27f2fca8a7).(f0r_instance_tcxx . . $ f0r_instance_t# instance, double time, const uint32_tcxx . . $ uint32_t#* inframe, uint32_tcxx . . $ uint32_t#* outframe) |
| 691 | { |
| 692 | |
| 693 | assertcxx . . $ `<external>/4398592474888995393/assert.h:77:11`!(instance); |
| 694 | tp_inst_tcxx . . $ tp_inst_t#* inst = (tp_inst_tcxx . . $ tp_inst_t#*)instance; |
| 695 | |
| 696 | floatrgba2colorcxx . . $ floatrgba2color(7e35642528ab9dd1).(inst->slcxx . . $ $anonymous_type_35b3be2327d9ad43_1#sl., outframe, inst->wcxx . . $ $anonymous_type_35b3be2327d9ad43_1#w. , inst->hcxx . . $ $anonymous_type_35b3be2327d9ad43_1#h.); |
| 697 | |
| 698 | } |