Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #ifndef QPPF_DEBUG_H_
00009 #define QPPF_DEBUG_H_
00010 
00011 
00012 namespace QQPF_Debug
00013 {
00014 
00015   
00016 
00017 
00018   void ppm(const char *fn, const int w, const int h, const int *ch) {
00019     
00020     FILE *fp = fopen(fn,"w");
00021 
00022     char buffer[128];
00023     sprintf(buffer,"P3\n%d %d\n255\n",h,w);
00024     fputs(buffer,fp);
00025 
00026     for(int x=0; x<w; x++) {
00027       for(int y=0; y<h; y++) {
00028         int v=0;
00029         if(ch[(x+w*y)])
00030           v=255;
00031 
00032         if(ch[(x+w*y)]<-1) {
00033           sprintf(buffer,"%d %d %d  ",0,255,0);
00034         }
00035         else if(ch[(x+w*y)]<0) {
00036           sprintf(buffer,"%d %d %d  ",255,0,0);
00037         }
00038         else
00039           sprintf(buffer,"%d %d %d  ",v,v,v);
00040         fputs(buffer,fp);
00041       }
00042     }
00043     fclose(fp);
00044   }
00045 
00046 }
00047 
00048 #endif