예제 #1
0
int StartMenu(char selection) // Menu
{
	do{
		clrscr();
		DrawBoundary();
		DrawLogo();
		gotoxy(10,5);
		printf("1. 게임 시작");
		gotoxy(10,8);
		printf("2. Ranking 확인");
		gotoxy(10,11);
		printf("3. 도움말");
		gotoxy(10,14);
		printf("4. 게임 종료");
		gotoxy(10,20);
		printf(" 번호 입력: ");
		selection=getch();
		if(selection!='1'&&selection!='2'&&selection!='3'&&selection!='4'){
			printf("#    잘못 입력하셨습니다. 다시 입력하세요.\n");
			printf("#    ");
			system("PAUSE");
		} // if
	} while(selection!='1'&&selection!='2'&&selection!='3'&&selection!='4'); // while
	return selection;
}
예제 #2
0
bool inpainting::Process(void) {
  char path[200];
  char temp[30];
  Convert2Gray();
  DrawBoundary();
  DrawSource();
  memset(m_pri, 0, m_width*m_height*sizeof(double));
  for(int j= m_top; j <= m_bottom; ++j) {
      for(int i = m_left; i <= m_right; ++i) {
        if(m_mark[j * m_width + i] ==  SOURCE) {
            number_to_fill_y[j] += 1;
            number_to_fill_x[i] += 1;
          if(number_to_fill_y[j]>max_width) {
             max_width=number_to_fill_y[j];
          }
          if(number_to_fill_x[i]>max_height) {
             max_height=number_to_fill_x[i];
          }
         }
        if(m_mark[j * m_width + i] == BOUNDARY) {
            m_pri[j * m_width + i] = ComputePriority(i,j);
            number_to_fill_y[j] += 1;
            number_to_fill_x[i] += 1;
        }
    }
  }
  int count=0;
  while(TargetExist()) {
    count++;
    double max_pri = 0;
    int pri_x,pri_y;
    for(int j= m_top; j <= m_bottom; ++j) {
                for(int i = m_left; i <= m_right; ++i) {
                  if(m_mark[j * m_width + i] == BOUNDARY&&m_pri[j * m_width + i]>max_pri) {
                    pri_x = i;
                    pri_y = j;
                    max_pri = m_pri[j * m_width + i];
                  }
                }
    }
    int patch_x, patch_y;
    PatchTexture(pri_x, pri_y, patch_x, patch_y);
    FillTarget(pri_x, pri_y, patch_x,patch_y, ComputeConfidence(pri_x,pri_y));
    UpdateBoundary(pri_x, pri_y);
    UpdatePriority(pri_x, pri_y);
  }
  strcpy(path, save_path);
  strcat(path, ".bmp");
  Image->Save(path);
  return true;
}
예제 #3
0
void DrawLabel(const struct zzLabel* label)
{
	short state = GetControlState(label);

	DrawBackground(&label->ctrl, state);
	DrawBoundary(&label->ctrl, state);	
	
	if(label->link)
	{
		PutString(GetXPositoinText(&label->ctrl, label->link) + 1,
						GetYPositoinText(&label->ctrl, label->link) + 1,
						label->ctrl.font,
						label->link,
						label->ctrl.color,
						label->ctrl.bgColor,
						&label->ctrl.rect,
						FLG_TEXT);
	
	}
}
예제 #4
0
void DrawTextField(const struct zzTextField* textField)
{
	unsigned short state = GetControlState(textField);

	DrawBackground(&textField->ctrl,state);
	DrawBoundary(&textField->ctrl, state);

	if(textField->link)
	{
		PutString(GetXPositoinText(&textField->ctrl, textField->link) + 1,
						GetYPositoinText(&textField->ctrl, textField->link) + 1,
						textField->ctrl.font,
						textField->link,
						textField->ctrl.color,
						textField->ctrl.bgColor,
						&textField->ctrl.rect,
						FLG_TEXT);
	
	}
	
}
예제 #5
0
void DrawButton(const struct zzButton* button) {

	short state = GetControlState(button);
	
	struct rectangle rect;

	DrawBackground(&button->ctrl, state);
	DrawBoundary(&button->ctrl, state);	

	if(button->link)
	{
		PutString(GetXPositoinText(&button->ctrl,button->link) + ((state & STATE_CLICKED) && (state & STATE_FOCUSED)),
				GetYPositoinText(&button->ctrl,button->link) + ((state & STATE_CLICKED)  && (state & STATE_FOCUSED)),
				button->ctrl.font,
				button->link,
				(button->ctrl.style & STYLE_TRANSPARENT) ? button->ctrl.color + (state & STATE_FOCUSED) : 0,
				button->ctrl.color,
				&button->ctrl.rect,
				FLG_TEXT);
	}
}
예제 #6
0
void CountRanking() // 랭킹을 파일로부터 불러오는 함수
{
	int i=0;
	FILE *rank=NULL;
	while(i==0){
		rank=fopen("1945rk.dat", "r");
		if(rank!=NULL) // 파일이 존재한다
			i=1;
		else if(rank==NULL){ // 파일이 존재하지 않거나 에러가 있다
			
			clrscr();

			DrawBoundary();
			DrawLogo();

			gotoxy(5,5);
			printf("Error to open file!\n");
			gotoxy(5,6);
			printf("File open error! 랭킹파일을 새로 작성합니다.");
			gotoxy(5,7);
			system("PAUSE");
		
			// 랭킹 파일 작성
			rank=fopen("1945rk.dat", "w");
			fprintf(rank, "COa 500 ");
			fprintf(rank, "COb 200 ");
			fprintf(rank, "COc 100 ");
		
			fclose(rank);
		} // else if
	} // while
	// 랭킹 파일에 있는 데이타들을 불러오는 함수
	fscanf(rank, "%s", first_name);
	fscanf(rank, "%d", &first_score);
	fscanf(rank, "%s", second_name);
	fscanf(rank, "%d", &second_score);
	fscanf(rank, "%s", third_name);
	fscanf(rank, "%d", &third_score);
	fclose(rank);
}
예제 #7
0
std::string inpainting::Process(void) {
  char path[200];
  char temp[30];
  pix_to_inpaint = 0;
  pix_been_inpainted = 0;
  Convert2Gray();
  DrawBoundary();
  DrawSource();
  memset(m_pri, 0, m_width*m_height*sizeof(double));
  for (int j= m_top; j <= m_bottom; ++j) {
      for (int i = m_left; i <= m_right; ++i) {
        if (m_mark[j * m_width + i] == BOUNDARY) {
          m_pri[j * m_width + i] = ComputePriority(i, j);
        }
    }
  }
  int count = 0;
  count_pic =1;
  int temp_color = 0;
  int temp_color2 = 0;
  int *temp_colors = new int[LOOKUP];
  int *temp_colors_2 = new int[LOOKUP];
  int **most_similar_patch = new int*[LOOKUP];
  for (int o = 0; o < LOOKUP; ++o) {
      most_similar_patch[o] = new int[2];
  }
  int **most_similar_patch_2 = new int*[LOOKUP];
  for (int o = 0; o < LOOKUP; ++o) {
      most_similar_patch_2[o] = new int[2];
  }
  int start = clock();
  int *colum_in_height = new int[m_height];
  for (int i = 0; i < m_height; ++i) {
    colum_in_height[i] = 0;
  }
  int *colum_in_width = new int[m_width];
  for (int i = 0; i < m_width; ++i) {
    colum_in_width[i] = 0;
  }
  double max_pri = 0;
  int pri_x, pri_y;
  int patch_x, patch_y;
  while (TargetExist()) {
    count++;
    count_pic++;
    max_pri = 0;
    for (int j= 0; j < m_height; ++j) {
      for (int i = 0; i < m_width; ++i) {
        colum_in_height[j]++;
        colum_in_width[i]++;
        if (m_mark[j * m_width + i] == BOUNDARY && m_pri[j * m_width + i] > max_pri) {
            pri_x = i;
            pri_y = j;
            max_pri = m_pri[j * m_width + i];
            colum_in_height[j]--;
            colum_in_width[i]--;
        }
        if (m_mark[j * m_width + i] == TARGET) {
            colum_in_height[j]--;
            colum_in_width[i]--;
        }
      }
    }
  height_diff = m_bottom - m_top + 1;
  width_diff = m_right - m_left + 1;
  //  缩小搜索框
  for (int i = m_top; i <= m_bottom; ++i) {
    if (colum_in_height[i] == width_diff) {
      m_top++;
    } else {
      break;
    }
  }
  for (int i = m_bottom-1; i >= m_top; --i) {
     if (colum_in_height[i] == width_diff) {
       m_bottom--;
     } else {
       break;
     }
  }
  for (int i = m_left; i <= m_right; ++i) {
    if (colum_in_width[i] == height_diff) {
      m_left++;
    } else {
      break;
    }
  }
  for (int i = m_right; i >= m_left; --i) {
    if (colum_in_width[i] == height_diff) {
      m_right--;
    } else {
      break;
    }
  }
    PatchTexture(pri_x, pri_y, patch_x, patch_y, most_similar_patch, most_similar_patch_2);
    FillTarget(pri_x, pri_y, patch_x, patch_y, ComputeConfidence(pri_x, pri_y));
    UpdateBoundary(pri_x, pri_y);
    UpdatePriority(pri_x, pri_y);
    char str[10];
    sprintf(str, "%d", count);
    strcpy(path, save_path);
    strcat(path, str);
    strcat(path, ".bmp");
    //  cout<<" path = "<<path<<endl;
    //  Image -> save(path);

    //  下面的是为了画出最匹配的20个点的图片的中间步骤
    /*temp_color = Image->pixel(pri_x,pri_y);
    temp_color2 = Image->pixel(patch_x,patch_y);
    for(int o=0;o<LOOKUP;++o) {
        temp_colors[o]=Image->pixel(most_similar_patch[o][0],most_similar_patch[o][1]);
       // temp_colors_2[o]=Image->pixel(most_similar_patch_2[o][0],most_similar_patch_2[o][1]);
        Image -> setPixel(most_similar_patch[o][0],most_similar_patch[o][1],MARK);
       // Image -> setPixel(most_similar_patch_2[o][0],most_similar_patch_2[o][1],MARK2);

    }
    Image -> setPixel(pri_x,pri_y,RED);
    Image -> setPixel(patch_x,patch_y,BLUE);
    //cout<<" patch_x = "<<patch_x<<endl;
    //cout<<" patch_y = "<<patch_y<<endl;
    Image -> save(path);

    for(int o=0;o<LOOKUP;++o) {
        Image -> setPixel(most_similar_patch[o][0],most_similar_patch[o][1],temp_colors[o]);
      //  Image -> setPixel(most_similar_patch_2[o][0],most_similar_patch_2[o][1],temp_colors_2[o]);

    }
    Image -> setPixel(pri_x,pri_y,temp_color);
    Image -> setPixel(patch_x,patch_y,temp_color2);*/
  }
  int end = clock();
  strcpy(path, save_path);
  strcat(path, ".bmp");
  //  Image->Save(path);
  std::string res = path;
  return res;
}