/[opencvs]/eyes/hologram_over_picture.c
ViewVC logotype

Contents of /eyes/hologram_over_picture.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sat Jul 23 02:21:07 2011 UTC (8 years, 7 months ago) by hib
Branch: MAIN
File MIME type: text/plain
few more

1 /* based on randomify - this reads the text for a base picture
2 and either will do a dark version of the pixel, or white
3 We might at some time make it porportional- but now is not that time */
4
5 #include <stdio.h>
6 #include <stdlib.h>
7
8 #include "util.h"
9
10 int main () {
11 FILE *base,*other,*alpha,*hologram;
12 base = fopen("base.txt","r");
13 hologram = fopen("l.txt","r"); /* optional */
14 if (hologram) {
15 fprintf(stderr,"hologram found and being used as a base\n");
16 }
17 char basebuf[10001];
18 char otherbuf[10001];
19 char alphabuf[10001];
20 char hologrambuf[10001];
21 srand(4);
22 /*printf("# ImageMagick pixel enumeration: 18000,18000,255,rgb\n");*/
23 /*printf("# ImageMagick pixel enumeration: 9450,12600,255,rgb\n");*/
24 printf("# ImageMagick pixel enumeration: 4725,6300,255,rgb\n");
25 while (fgets(basebuf,10000,base)) {
26 char *q;
27 if (hologram) q=fgets(hologrambuf,10000,hologram);
28 int xb,yb,rb,gb,bb;
29 int xo,yo,ro,go,bo;
30 int xa,ya,ra,ga,ba;
31 int hb;
32 xb = fieldi(basebuf,0);
33 yb = fieldi(basebuf,1);
34 rb = fieldi(basebuf,2);
35 gb = fieldi(basebuf,3);
36 bb = fieldi(basebuf,4);
37 hb = fieldi(hologrambuf,2);
38
39 /* This section is for full color pixel transfer */
40 int rf,gf,bf;
41 int r;
42 r=hb;
43 #ifdef four_three
44 if (r<128) {
45 rf = rb * 4 / 3;
46 if (rf > 255) rf=255;
47 gf = gb * 4 / 3;
48 if (gf > 255) gf=255;
49 bf = bb * 4 / 3;
50 if (bf > 255) bf=255;
51 /*
52 rf = 255;
53 gf = 255;
54 bf = 255;
55 */
56 }
57 else {
58 rf = rb / 2;
59 gf = gb / 2;
60 bf = bb / 2;
61 }
62 #endif
63 rf = (rb * r * 2) / 255;
64 gf = (gb *r * 2) / 255;
65 bf = (bb * r * 2) / 255;
66 rf = (rf + rb) / 2;
67 gf = (gf + gb) / 2;
68 bf = (bf + bb) / 2;
69
70 if (rf > 255) rf=255;
71 if (gf > 255) gf=255;
72 if (bf > 255) bf=255;
73
74
75 int total;
76 total = rf*65536+gf*256+bf;
77 printf("%d,%d: (%d,%d,%d) #%06x rgb(%d,%d,%d)\n",
78 xb,yb,rf,gf,bf,total,rf,gf,bf);
79 }
80 }

  ViewVC Help
Powered by ViewVC 1.1.26