#include <Imagine/Images.h>
using namespace std;
void images() {
cout << "Testing Image functions!" << endl;
byte t1[]={1,2,3,4,5,6};
byte *t2=new byte[6];
for(
int i=0; i<Jb.
height(); i++)
for(
int j=0; j<Jb.
width(); j++)
Jb(j,i) = byte(rand()%256);
for(
int i=0; i<Jcb.
height(); i++)
for(
int j=0; j<Jcb.
width(); j++)
Jcb(j,i)=
Color(byte(rand()%256),byte(rand()%256),byte(rand()%256));
A=E;
Jd=Jb;
Jcd=Jcb;
byte a,b,c,d;
a=b=c=d=a;
cout << sum(Jd) << ' ' << sum(Jcd) << endl;
cout << norm2(Jd) << ' ' << norm2(Jcd) << endl;
cout << norm(Jd) << ' ' << norm(Jcd) << endl;
O=-O;
O=O+P;
O+=P;
O=O-P;
O-=P;
O=RGB<double>(1.,2.,3.)+P;
O+=RGB<double>(1.,2.,3.);
O=P-RGB<double>(1.,2.,3.);
O=RGB<double>(1.,2.,3.)-P;
O-=RGB<double>(1.,2.,3.);
O=P*2.;
O=2*P;
O*=2.;
O=P/2.;
O/=2.;
O=P*Q;
O*=Q;
O=P/Q;
O/=Q;
}
void io_transparency() {
cout << "Testing IO transparency functions!" << endl;
cout << "GIF opaque image" << endl;
cout << "Superimposed transparent PNG image" << endl;
cout << "Two transparent images" << endl;
cout << "Transparent image" << endl;
cout << "Saved and reloaded PNG transparent image" << endl;
}
void io() {
cout << "Testing IO functions!" << endl;
save(J,
"out_color.jpg",95);
save(R,G,B,
"out_color.png");
K/=255.;
L/=255.;
for (int k=0;k<110;k++)
for (int j=0;j<120;j++)
for (int i=0;i<130;i++)
M(i,j,k)=i+j+k;
saveAnalyze<float>(I,"out");
if (I(10,10)!=I0(10,10))
cout << "Analyze error!!!" << endl;
saveAnalyze<double>(K,"out");
if (K(10,10)!=K0(10,10))
cout << "Analyze error!!!" << endl;
}
void algos() {
cout << "Testing Algos functions!" << endl;
J=I;
}
void schemes(){
cout << "Testing PDE schemes" << endl;
cout << dp << " " << dm << endl;
cout << pp << " " << pm << endl;
}
int main() {
typedef void (*FUNC)();
vector< pair<string,FUNC> > tests;
#define ADD_TEST(func) \
tests.push_back(make_pair(string(#func), func));
ADD_TEST(images);
ADD_TEST(io);
ADD_TEST(algos);
ADD_TEST(schemes);
ADD_TEST(io_transparency);
std::vector< pair<string,FUNC> >::const_iterator it;
if(argc<=1)
for(it=tests.begin(); it!=tests.end(); ++it) {
cout << "---" << it->first << "---" << std::endl;
it->second();
}
else {
bool fail=false;
for(int i=1; i<argc; i++) {
for(it=tests.begin(); it!=tests.end(); ++it) {
if(it->first == argv[i]) {
cout << "---" << it->first << "---" << std::endl;
it->second();
break;
}
}
if(it==tests.end()) {
std::cout << "Unknown test " << argv[i] << endl;
fail = true;
}
}
if(fail) {
cout << "--- Available tests:" << endl;
for(it=tests.begin(); it!=tests.end(); ++it)
cout << it->first << ' ';
cout << endl;
return 0;
}
}
return 0;
}