Exemplo n.º 1
0
void dbgShow(Cluster *head, LPCLUSIMG clusImg){
	int i, j, pixCnt;
	Cluster *thisClus, *lastClus, **thisPx;
	writeConsoleFmt("\n\nhead: %08x. clusImg: %08x\n",head,clusImg);
	lastClus = thisClus = head;
	pixCnt = clusImg->width*clusImg->height;
	while(thisClus != (Cluster*)NULL){
		writeConsoleFmt("%08x->",thisClus);
		thisClus->testClusImg(clusImg);
		if(thisClus == thisClus->getNext()){
			writeConsole("SELF REFERENCE!\n");
			waitKeyPress(true);
			exit(-1);
			return;
		}
				
		if(thisClus->getCount() == 0 || thisClus->getCount() > pixCnt){
    		writeConsoleFmt("DAMMIT! %08x: CORRUPTED CLUSTER! PIXCNT: %d\n",thisClus,thisClus->getCount());
			waitKeyPress(true);
			exit(-1);
			return;
		}
		
		thisClus = thisClus->getNext();
		if(thisClus != (Cluster*)NULL && thisClus->getBefore() != lastClus){
			writeConsole("LIST IS NOT RIGTH LINKED!\n");
			waitKeyPress(true);
			exit(-1);
			return;
		}
		lastClus = thisClus;
	}
    writeConsole("NULL\n\n");
    
    thisPx = (Cluster**)clusImg->pixClus;
    for(i = 0; i < clusImg->height; i++){
    	for(j = 0; j < clusImg->width; j++){
	    	if(*thisPx != NULL && ((*thisPx)->getCount() == 0 || (*thisPx)->getCount() > pixCnt)){
	    		writeConsoleFmt("DAMMIT! ORPHAN PIXEL %dx%d! CLUS->PIXCNT %d\n",j+1,i+1,(*thisPx)->getCount());
				waitKeyPress(true);
				exit(-1);
				return;
			}
		}
	}
}
Exemplo n.º 2
0
void Cluster::mergeCluster(Cluster* c2, Cluster* head){
	int i;
	Cluster *clusBefore, **thisPx;
	if(c2 == this){
		writeConsole("SELF-MERGE????\n");
		waitKeyPress(true);
		exit(-1);
		return;
	}
	
	float newR = (avgTone.red*pixelCount + c2->avgTone.red*c2->pixelCount);
	float newG = (avgTone.green*pixelCount + c2->avgTone.green*c2->pixelCount);
	float newB = (avgTone.blue*pixelCount + c2->avgTone.blue*c2->pixelCount);
	
	pixelCount += c2->pixelCount;
	newR /= pixelCount;
	newG /= pixelCount;
	newB /= pixelCount;
	avgTone.red = (unsigned char)round(newR);
	avgTone.green = (unsigned char)round(newG);
	avgTone.blue = (unsigned char)round(newB);
		
	if(left > c2->left)
        left = c2->left;
    if(top > c2->top)
        top = c2->top;
    if(right < c2->right)
        right = c2->right;
    if(bottom < c2->bottom)
        bottom = c2->bottom;
	
	thisPx = (Cluster**)clustImage->pixClus;
	for(i = 0; i < clustImage->width*clustImage->height; i++){
		if(*thisPx == c2)
			*thisPx = this;
		thisPx++;
	}
	
    c2->avgTone = (COLOR){0,0,0};
    c2->pixelCount = 0;
    c2->left = 0;
    c2->top = 0;
    c2->right = 0;
    c2->bottom = 0;
    
    clusBefore = c2->before;
    clusBefore->next = c2->next;
    if(clusBefore->next != (Cluster*)NULL)
    	clusBefore->next->before = clusBefore;
    //writeConsoleFmt("List: %08x->%08x. Delete: %08x. Merged with %08x.\n",clusBefore,c2->next,c2,this);
    delete c2;
}
Exemplo n.º 3
0
uint8_t getPeople(void){
  char c;
  char buf[MAX_PEEPS];
  uint8_t buf_count = 0;
  while(1){
    displayMulti(atoi(buf),'P');
    if(c = waitKeyPress()){
      usb_debug_putchar(c);
      if(c == '*'){
        memset(buf, 0, MAX_PEEPS);
        buf_count = 0;
      } else if(c == '#'){
        return atoi(buf);
      } else {
        buf[buf_count] = c;
        buf_count++;
        if (buf_count == MAX_PEEPS){
          return atoi(buf);
        }
      }
    }
  }
}