testing loadsave
This commit is contained in:
@ -541,4 +541,46 @@ namespace ams
|
||||
return ret;
|
||||
}
|
||||
|
||||
void amsimage::clear()
|
||||
{
|
||||
this->setall(amspixel(0,0,0,0));
|
||||
}
|
||||
|
||||
void amsimage_setall_tf(
|
||||
int threadnum,
|
||||
int nthreads,
|
||||
amsimage *img,
|
||||
const amspixel color
|
||||
)
|
||||
{
|
||||
int64_t I,I0,I1,Is,N,Ix,Iy;
|
||||
|
||||
N = img->Nx*img->Ny;
|
||||
Is = N/nthreads; Is = (Is<1) ? 1 : Is;
|
||||
I0 = Is*threadnum;
|
||||
I1 = (threadnum<(nthreads-1)) ? Is*(threadnum+1) : N;
|
||||
|
||||
for(I=I0;I<I1;I++)
|
||||
{
|
||||
Ix = I0%img->Nx;
|
||||
Iy = I0/img->Ny;
|
||||
|
||||
img->data[0 + 4*(Ix + img->Nx*Iy)] = color.R;
|
||||
img->data[1 + 4*(Ix + img->Nx*Iy)] = color.G;
|
||||
img->data[2 + 4*(Ix + img->Nx*Iy)] = color.B;
|
||||
img->data[3 + 4*(Ix + img->Nx*Iy)] = color.A;
|
||||
}
|
||||
}
|
||||
|
||||
void amsimage::setall(amspixel color)
|
||||
{
|
||||
imglib4::threaded_execute(
|
||||
amsimage_setall_tf,
|
||||
this->Nx*this->Ny,
|
||||
this,
|
||||
color
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
};
|
@ -3,7 +3,7 @@
|
||||
namespace ams
|
||||
{
|
||||
|
||||
void amscppimglib_test1()
|
||||
void amscppimglib4_test1()
|
||||
{
|
||||
amsimage img1, img2;
|
||||
|
||||
@ -14,6 +14,40 @@ namespace ams
|
||||
img2 = img1.transpose().flipx();
|
||||
printf("img1:(%d,%d)\n",img2.width,img2.height);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void amscppimglib4_test2()
|
||||
{
|
||||
amsimage img,img2;
|
||||
const char *fname = "../testimg/testpfp0.png";
|
||||
char fname2[500];
|
||||
|
||||
read_image(fname,&img);
|
||||
printf("image loaded: %s (%d,%d)\n",fname,img.width,img.height);
|
||||
|
||||
img2 = img.rotcw();
|
||||
sprintf(fname2,"../testimg/test_rotcw.png");
|
||||
write_image(fname2,&img2);
|
||||
|
||||
img2 = img.rotccw();
|
||||
sprintf(fname2,"../testimg/test_rotccw.png");
|
||||
write_image(fname2,&img2);
|
||||
|
||||
img2 = img.flipx();
|
||||
sprintf(fname2,"../testimg/test_flipx.png");
|
||||
write_image(fname2,&img2);
|
||||
|
||||
img2 = img.flipy();
|
||||
sprintf(fname2,"../testimg/test_flipy.png");
|
||||
write_image(fname2,&img2);
|
||||
|
||||
img2 = img.transpose();
|
||||
sprintf(fname2,"../testimg/test_transpose.png");
|
||||
write_image(fname2,&img2);
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,8 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
amscppimglib_test1();
|
||||
//amscppimglib4_test1();
|
||||
amscppimglib4_test2();
|
||||
|
||||
return ret;
|
||||
}
|
Reference in New Issue
Block a user