Commit 10b7eef7aa456adb7cf174cbeae10ab96da05b4c

Authored by henyxia
1 parent 262d40e6

Separated color allocation

A pic take now about 17s to pop
Showing 1 changed file with 16 additions and 3 deletions   Show diff stats
@@ -178,6 +178,21 @@ int main(int argc, char* argv[]) @@ -178,6 +178,21 @@ int main(int argc, char* argv[])
178 178
179 if(XAllocColor(display, screen_colormap, &col) == 0) 179 if(XAllocColor(display, screen_colormap, &col) == 0)
180 printf("Failed to allocate color\n"); 180 printf("Failed to allocate color\n");
  181 + buffer[0] = getc(home);
  182 + buffer[1] = getc(home);
  183 + buffer[2] = getc(home);
  184 + printf("Alloc X %03d Y %03d R %02x G %02x B %02x\n", i%width, i/width, buffer[0], buffer[1], buffer[2]);
  185 + }
  186 +
  187 +
  188 + fseek(home, initOffsetBMP, SEEK_SET);
  189 +
  190 + for(i=0; i<76800; i++)
  191 + {
  192 + col.red = buffer[2] * 257;
  193 + col.green = buffer[1] * 257;
  194 + col.blue = buffer[0] * 257;
  195 +
181 if(XSetForeground(display, gc, col.pixel) == 0) 196 if(XSetForeground(display, gc, col.pixel) == 0)
182 printf("Failed to set foreground\n"); 197 printf("Failed to set foreground\n");
183 if(XDrawPoint(display,win,gc,i%width,height-1-(i/width)) == 0) 198 if(XDrawPoint(display,win,gc,i%width,height-1-(i/width)) == 0)
@@ -185,13 +200,11 @@ int main(int argc, char* argv[]) @@ -185,13 +200,11 @@ int main(int argc, char* argv[])
185 buffer[0] = getc(home); 200 buffer[0] = getc(home);
186 buffer[1] = getc(home); 201 buffer[1] = getc(home);
187 buffer[2] = getc(home); 202 buffer[2] = getc(home);
188 - //printf("X %03d Y %03d R %02x G %02x B %02x\n", i%width, i/width, buffer[0], buffer[1], buffer[2]); 203 + printf("Disp X %03d Y %03d R %02x G %02x B %02x\n", i%width, i/width, buffer[0], buffer[1], buffer[2]);
189 } 204 }
190 205
191 206
192 207
193 -  
194 -  
195 /* draw two intersecting lines, one horizontal and one vertical, */ 208 /* draw two intersecting lines, one horizontal and one vertical, */
196 /* which intersect at point "50,100". */ 209 /* which intersect at point "50,100". */
197 /* draw the line in a brown color. */ 210 /* draw the line in a brown color. */