RazzorFlame
New Member
- Joined
- Jul 11, 2014
- Messages
- 4
- Reaction score
- 0
So, i have just created my simple program in C++ wich searches for same or nearly same image (must contains at least 76% pixels in the same place and have 75-125% filled area). Program written in 15 minutes. I needed it to search in tibia spr folder (unpacked using Tidus Spr Unpacker). I don't know other source that i would get id of items. Well, app is compiled in Windows 7 64Bit using MinGW x64 then it wouldn't run on some platforms.
Here is the source code of somebody want to compile it on another platform (Uses SFML 2.0)
Here is the source code of somebody want to compile it on another platform (Uses SFML 2.0)
C++:
#include <iostream>
#include <SFML/Graphics.hpp>
#include <sstream>
using namespace std;
double getFilled(sf::Image &img2)
{
double filledPx = 0;
for(int i = 0; i < 32; i++)
{
for(int j = 0; j < 32; j++)
{
sf::Color px2 = img2.getPixel(i,j);
if(px2.r == 255 && px2.g == 0 && px2.b == 255)
{
} else filledPx++;
}
}
return filledPx;
}
bool checkImage(sf::Image &img, sf::Image &img2, double &percentage, double &fpercentage, bool show = false)
{
double samePx = 0;
bool isTheSame = true;
double filledPx = getFilled(img2);
double filledPx2 = getFilled(img);
double fpercent = 0;
if(filledPx2 != 0) fpercent = (filledPx/filledPx2)*100;
fpercentage = fpercent;
for(int x = 0; x < 32; x++)
{
for(int y = 0; y < 32; y++)
{
sf::Color px1 = img.getPixel(x,y);
sf::Color px2 = img2.getPixel(x,y);
if(px1.r != px2.r || px1.g != px2.g || px1.b != px2.b)
{
isTheSame = false;
//return false;
}
else
{
if(px2.r == 255 && px2.g == 0 && px2.b == 255)
{
}
else
{
samePx++;
}
}
}
}
double percent = 0;
if(filledPx != 0)
{
percent = (double)(samePx/filledPx)*100;
}
percentage = percent;
if(percent > 95 && fpercent > 75 && fpercent < 125) return true;
else return false;
//return isTheSame;
}
class idp
{
public:
double id, percent, fpercent;
};
int main()
{
cout << "====================Welcome to Tibia Sprite Selector====================\n";
cout << "===============================RazzorFlame==============================\n\n\n";
string sprpath, folderpath;
sf::Image img, imgTemp;
cout<<"Write path to tibia sprite: \n";
getline(cin, sprpath);
cout<<"Write folder path: \n";
getline(cin, folderpath);
cout << "Would you like to tell you actual image progress? (y/n)"<<endl;
char c;
cin>>c;
idp most;
most.id = 0;
most.percent = -1;
cout<<"Wait...";
if(!img.loadFromFile(sprpath.c_str()))
{
cout<<"Failed to load tibia sprite."<<endl;
system("pause >> nul");
return 1;
} else cout<<"Starting. Wait until image is not found."<<endl;
ostringstream st;
for(int i = 1; ; i++)
{
st << i;
string n = folderpath + st.str() + ".bmp";
st.str("");
double percentage = 0, fpercentage = 0;
if(i == 35798) i = 35800;
if(!imgTemp.loadFromFile(n.c_str()))
{
cout<<"End of items."<<endl;
break;
}
else
{
bool s = false;
if(i == 507) s = true;
if(checkImage(img, imgTemp, percentage, fpercentage, s) == true)
{
/*if(percentage > most.percent)
{
most.id = i;
most.percent = percentage;
}*/
cout<<"Found with id: "<<i<<", percentage = "<<percentage<<endl;
break;
}
else
{
if(percentage > most.percent && fpercentage >= 75 && fpercentage <= 125)
{
most.id = i;
most.percent = percentage;
}
}
}
if(c == 'y' || c == 'Y')
{
cout <<"Progress: "<< i <<", percent same px = "<<percentage<<endl;
}
}
cout<<"Most: "<<most.id<<" with "<<most.percent<<" percent."<<endl;
system("pause");
return 0;
}
Attachments
-
TibiaSprSelector.zip405.3 KB · Views: 14 · VirusTotal
Last edited by a moderator: