int namcos3d_Init( int width, int height, void *pTilemapROM, void *pTextureROM ) { int i; if( !gUseOpenGL ) { namco_zbuffer = auto_malloc( width*height*sizeof(*namco_zbuffer) ); } if( pTilemapROM && pTextureROM ) { /* following setup is Namco System 22 specific */ const UINT8 *pPackedTileAttr = 0x200000 + (UINT8 *)pTilemapROM; UINT8 *pUnpackedTileAttr = auto_malloc(0x080000*2); InitXYAttrToPixel(); mpTextureTileMapAttr = pUnpackedTileAttr; for( i=0; i<0x80000; i++ ) { *pUnpackedTileAttr++ = (*pPackedTileAttr)>>4; *pUnpackedTileAttr++ = (*pPackedTileAttr)&0xf; pPackedTileAttr++; } mpTextureTileMap16 = pTilemapROM; mpTextureTileData = pTextureROM; PatchTexture(); /* HACK! */ } return 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; }
//----------------------------------------------------------------------- // Notifications //----------------------------------------------------------------------- void CFuiTBROS::NotifyChildEvent(Tag idm,Tag itm,EFuiEvents evn) { int gnd = globals->tcm->GetGroundType(); bool nok = (0 == Type) || (lock); switch (idm) { case 'sysb': SystemHandler(evn); return; case 'xlst': if (nok) return; sel = 1; aBOX->VScrollHandler((U_INT)itm,evn); GetSelection(); return; case 'wlok': lock ^= 1; RefreshOPT(); return; case 'wbt1': if (1 == state) ChangeTile(gnd); if (2 == state) PatchTexture(); return; case 'zbtn': RestoreTile(gnd); return; case 'obtn': obtn ^= 1; gBox->SetChildText('obtn',ObjBTN[obtn]); globals->noOBJ += btnLOK[obtn]; return; case 'abtn': abtn ^= 1; gBox->SetChildText('abtn',AptBTN[abtn]); globals->noAPT += btnLOK[abtn]; return; } return; }
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; }