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

Annotation of /eyes/hologram_over_picture.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Sat Nov 12 21:31:09 2011 UTC (8 years, 3 months ago) by hib
Branch: MAIN
Changes since 1.1: +66 -0 lines
File MIME type: text/plain
I think I got kristie working

1 hib 1.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 hib 1.2
11    
12     #ifdef BEN
13    
14 hib 1.1 int main () {
15     FILE *base,*other,*alpha,*hologram;
16     base = fopen("base.txt","r");
17     hologram = fopen("l.txt","r"); /* optional */
18     if (hologram) {
19     fprintf(stderr,"hologram found and being used as a base\n");
20     }
21     char basebuf[10001];
22     char otherbuf[10001];
23     char alphabuf[10001];
24     char hologrambuf[10001];
25     srand(4);
26     /*printf("# ImageMagick pixel enumeration: 18000,18000,255,rgb\n");*/
27     /*printf("# ImageMagick pixel enumeration: 9450,12600,255,rgb\n");*/
28     printf("# ImageMagick pixel enumeration: 4725,6300,255,rgb\n");
29     while (fgets(basebuf,10000,base)) {
30     char *q;
31     if (hologram) q=fgets(hologrambuf,10000,hologram);
32     int xb,yb,rb,gb,bb;
33     int xo,yo,ro,go,bo;
34     int xa,ya,ra,ga,ba;
35     int hb;
36     xb = fieldi(basebuf,0);
37     yb = fieldi(basebuf,1);
38     rb = fieldi(basebuf,2);
39     gb = fieldi(basebuf,3);
40     bb = fieldi(basebuf,4);
41     hb = fieldi(hologrambuf,2);
42    
43     /* This section is for full color pixel transfer */
44     int rf,gf,bf;
45     int r;
46     r=hb;
47     #ifdef four_three
48     if (r<128) {
49     rf = rb * 4 / 3;
50     if (rf > 255) rf=255;
51     gf = gb * 4 / 3;
52     if (gf > 255) gf=255;
53     bf = bb * 4 / 3;
54     if (bf > 255) bf=255;
55     /*
56     rf = 255;
57     gf = 255;
58     bf = 255;
59     */
60     }
61     else {
62     rf = rb / 2;
63     gf = gb / 2;
64     bf = bb / 2;
65     }
66     #endif
67     rf = (rb * r * 2) / 255;
68     gf = (gb *r * 2) / 255;
69     bf = (bb * r * 2) / 255;
70     rf = (rf + rb) / 2;
71     gf = (gf + gb) / 2;
72     bf = (bf + bb) / 2;
73    
74     if (rf > 255) rf=255;
75     if (gf > 255) gf=255;
76     if (bf > 255) bf=255;
77    
78    
79     int total;
80     total = rf*65536+gf*256+bf;
81     printf("%d,%d: (%d,%d,%d) #%06x rgb(%d,%d,%d)\n",
82     xb,yb,rf,gf,bf,total,rf,gf,bf);
83     }
84     }
85 hib 1.2 #endif
86    
87    
88    
89    
90    
91    
92     int main () {
93     FILE *base,*hologram;
94     base = fopen("tilified_awaiting_hologram2.txt","r");
95     hologram = fopen("hologram.txt","r"); /* optional */
96     if (hologram) {
97     fprintf(stderr,"hologram found and being used as a base\n");
98     }
99     char basebuf[10001];
100     char hologrambuf[10001];
101     srand(4);
102     /*printf("# ImageMagick pixel enumeration: 18000,18000,255,rgb\n");*/
103     /*printf("# ImageMagick pixel enumeration: 9450,12600,255,rgb\n");*/
104     printf("# ImageMagick pixel enumeration: 63360,84480,255,rgb\n");
105     while (fgets(basebuf,10000,base)) {
106     char *q;
107     if (hologram) q=fgets(hologrambuf,10000,hologram);
108     int xb,yb,rb,gb,bb;
109     int xo,yo,ro,go,bo;
110     int xa,ya,ra,ga,ba;
111     int hb;
112     xb = fieldi(basebuf,0);
113     yb = fieldi(basebuf,1);
114     rb = fieldi(basebuf,2);
115     gb = fieldi(basebuf,3);
116     bb = fieldi(basebuf,4);
117     hb = fieldi(hologrambuf,2);
118    
119     /* This section is for full color pixel transfer */
120     int rf,gf,bf;
121     int r;
122     r=hb;
123     if (r ==127) {
124     rf=rb;gf=gb;bf=bb;
125     }
126     else {
127     find_the_two_colors(rb,gb,bb,50,&ro,&ra,&go,&ga,&bo,&ba);
128     if (r>127) {
129     rf=ra;
130     gf=ga;
131     bf=ba;
132     }
133     else {
134     rf=ro;
135     gf=go;
136     bf=bo;
137     }
138     }
139    
140    
141     int total;
142     total = rf*65536+gf*256+bf;
143     printf("%d,%d: (%d,%d,%d) #%06x rgb(%d,%d,%d)\n",
144     xb,yb,rf,gf,bf,total,rf,gf,bf);
145     }
146     }

  ViewVC Help
Powered by ViewVC 1.1.26