testing loadsave
@ -69,18 +69,17 @@ namespace ams
 | 
			
		||||
        uint8_t& operator()(int Nc, int I, int J);
 | 
			
		||||
        const uint8_t& operator()(int Nc, int I, int J) const;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        void clear();
 | 
			
		||||
        void setall(amspixel color);
 | 
			
		||||
        int setallplane(int Ncp, uint8_t val);
 | 
			
		||||
 | 
			
		||||
        //todo
 | 
			
		||||
 | 
			
		||||
        int get_colorplane(int Ncp, amsbitplane* bp);
 | 
			
		||||
        int set_colorplane(int Ncp, const amsbitplane* bp);
 | 
			
		||||
        
 | 
			
		||||
        //applies image with alpha blending
 | 
			
		||||
        int apply_image(int I0, int J0, amsimage *img);
 | 
			
		||||
 | 
			
		||||
        //applied color to any pixels where the bitplane's value is >= thresh
 | 
			
		||||
        int apply_bitplane_nz(int I0, int J0, amsbitplane* bp, amspixel color, uint8_t thresh);
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,8 @@
 | 
			
		||||
 | 
			
		||||
namespace ams
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    void amscppimglib4_test1();
 | 
			
		||||
    void amscppimglib4_test2();
 | 
			
		||||
 | 
			
		||||
}; //end namespace ams
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								testimg/test_flipx.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 102 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/test_flipy.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 103 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/test_rotccw.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 102 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/test_rotcw.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 102 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/test_transpose.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 101 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/testpfp0.bmp
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 247 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/testpfp0.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 34 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/testpfp0.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 90 KiB  |