initial testing.
@ -1,14 +1,14 @@
 | 
			
		||||
#ifndef __AMSCIMGLIB4_INTL_HPP__
 | 
			
		||||
#define __AMSCIMGLIB4_INTL_HPP__
 | 
			
		||||
 | 
			
		||||
#include <amscimglib4/amscimglib4_tests.h>
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <math.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <ctype.h>
 | 
			
		||||
 | 
			
		||||
#include <amscimglib4/amscimglib4_tests.h>
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {  
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,17 @@
 | 
			
		||||
#ifndef __AMSCIMGLIB4_TESTS_HPP__
 | 
			
		||||
#define __AMSCIMGLIB4_TESTS_HPP__
 | 
			
		||||
 | 
			
		||||
void amscimglib4_test_init();
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {  
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
AMSCIMGLIB4_API void amscimglib4_test_init();
 | 
			
		||||
 | 
			
		||||
AMSCIMGLIB4_API void amscimglib4_test_loadsave();
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}; //end extern "C"
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -90,7 +90,7 @@ AMSCIMGLIB4_API int amscimglib4_image_resize(amscimglib4_image *imgptr, int _siz
 | 
			
		||||
        return amscimglib4_failure;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    newdata = (unsigned char*) malloc(sizeof(char)*4*_sizex*_sizey);
 | 
			
		||||
    newdata = (unsigned char*) malloc(sizeof(unsigned char)*4*_sizex*_sizey);
 | 
			
		||||
    if(newdata==NULL)
 | 
			
		||||
    {
 | 
			
		||||
        return amscimglib4_failure;
 | 
			
		||||
@ -106,7 +106,7 @@ AMSCIMGLIB4_API int amscimglib4_image_resize(amscimglib4_image *imgptr, int _siz
 | 
			
		||||
        for(K=0;K<4;K++)
 | 
			
		||||
        for(I=0;I<_sizex && I<imgptr->sizex;I++)
 | 
			
		||||
        for(J=0;J<_sizey && J<imgptr->sizey;J++)
 | 
			
		||||
            newdata[4*(I+_sizex*J)+K] = imgptr->data[4*(I+_sizex*J)+K];
 | 
			
		||||
            newdata[4*(I+_sizex*J)+K] = imgptr->data[4*(I+imgptr->sizex*J)+K];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    free(imgptr->data);
 | 
			
		||||
@ -154,8 +154,8 @@ AMSCIMGLIB4_API int amscimglib4_image_copy(amscimglib4_image *imgto, const amsci
 | 
			
		||||
    if(imgfrom->data!=NULL && imgto->data!=NULL)
 | 
			
		||||
    {
 | 
			
		||||
        for(K=0;K<4;K++)
 | 
			
		||||
        for(I=0;I<imgto->sizex;I++)
 | 
			
		||||
        for(J=0;J<imgto->sizey;J++)
 | 
			
		||||
        for(I=0;I<imgto->sizex && I<imgfrom->sizex;I++)
 | 
			
		||||
        for(J=0;J<imgto->sizey && J<imgfrom->sizey;J++)
 | 
			
		||||
            imgto->data[4*(I+imgto->sizex*J)+K] = imgfrom->data[4*(I+imgfrom->sizex*J)+K];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,61 @@
 | 
			
		||||
extern "C" {  
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void amscimglib4_test_init()
 | 
			
		||||
{
 | 
			
		||||
    amscimglib4_image *img1 = NULL;
 | 
			
		||||
    amscimglib4_image *img2 = NULL;
 | 
			
		||||
    int res;
 | 
			
		||||
 | 
			
		||||
    printf("Testing basic image operations for memory leaks...\n");
 | 
			
		||||
    printf("use valgrind...\n");
 | 
			
		||||
    
 | 
			
		||||
    res = amscimglib4_image_new(&img1,1000,1000); printf("res=%d (%d,%d)\n",res,img1->sizex,img1->sizey);
 | 
			
		||||
    res = amscimglib4_image_new(&img2,200,1000); printf("res=%d (%d,%d)\n",res,img2->sizex,img2->sizey);
 | 
			
		||||
    
 | 
			
		||||
    res = amscimglib4_image_resize(img1,500,500); printf("res=%d (%d,%d)\n",res,img1->sizex,img1->sizey);
 | 
			
		||||
    res = amscimglib4_image_copy(img2,img1); printf("res=%d, img2=(%d,%d), img1=(%d,%d)\n",res, img2->sizex,img2->sizey,img1->sizex,img1->sizey);
 | 
			
		||||
 | 
			
		||||
    amscimglib4_image_delete(&img1);
 | 
			
		||||
    amscimglib4_image_delete(&img2);
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
AMSCIMGLIB4_API void amscimglib4_test_loadsave()
 | 
			
		||||
{
 | 
			
		||||
    printf("Testing basic image loading/saving and conversion...\n");
 | 
			
		||||
 | 
			
		||||
    amscimglib4_image *img1 = NULL;
 | 
			
		||||
    amscimglib4_image *img2 = NULL;
 | 
			
		||||
 | 
			
		||||
    amscimglib4_image_new(&img1,1,1);
 | 
			
		||||
    amscimglib4_image_new(&img2,1,1);
 | 
			
		||||
 | 
			
		||||
    amscimglib4_readimage_bmp("../testimg/testpfp0.bmp",img1);
 | 
			
		||||
    printf("read in (%d,%d) bitmap image.\n",img1->sizex,img1->sizey);
 | 
			
		||||
    amscimglib4_image_flipx(img1);
 | 
			
		||||
    amscimglib4_writeimage_bmp("../testimg/testpfp0_1.bmp",img1);
 | 
			
		||||
    amscimglib4_writeimage_jpeg("../testimg/testpfp0_2.jpg",img1,90);
 | 
			
		||||
    amscimglib4_writeimage_png("../testimg/testpfp0_3.png",img1);
 | 
			
		||||
 | 
			
		||||
    amscimglib4_readimage("../testimg/testpfp0.png",img1);
 | 
			
		||||
    printf("read in (%d,%d) png image.\n",img1->sizex,img1->sizey);
 | 
			
		||||
    amscimglib4_transpose_image(img1);
 | 
			
		||||
    amscimglib4_writeimage("../testimg/testpfp1_1.bmp",img1);
 | 
			
		||||
    amscimglib4_writeimage("../testimg/testpfp1_2.png",img1);
 | 
			
		||||
    amscimglib4_writeimage("../testimg/testpfp1_3.jpg",img1);
 | 
			
		||||
 | 
			
		||||
    amscimglib4_readimage("../testimg/testpfp0.jpg",img1);
 | 
			
		||||
    printf("read in (%d,%d) jpg image.\n",img1->sizex,img1->sizey);
 | 
			
		||||
    amscimglib4_image_flipy(img1);
 | 
			
		||||
    amscimglib4_writeimage("../testimg/testpfp2_1.bmp",img1);
 | 
			
		||||
    amscimglib4_writeimage("../testimg/testpfp2_2.png",img1);
 | 
			
		||||
    amscimglib4_writeimage("../testimg/testpfp2_3.jpg",img1);
 | 
			
		||||
 | 
			
		||||
    amscimglib4_image_delete(&img1);
 | 
			
		||||
    amscimglib4_image_delete(&img2);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}; //end extern "C"
 | 
			
		||||
 | 
			
		||||
@ -5,5 +5,8 @@ int main(int argc, char* argv[])
 | 
			
		||||
{
 | 
			
		||||
    int ret = 0;
 | 
			
		||||
 | 
			
		||||
    //amscimglib4_test_init();
 | 
			
		||||
    amscimglib4_test_loadsave();
 | 
			
		||||
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										
											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  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/testpfp0_1.bmp
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 247 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/testpfp0_2.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 19 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/testpfp0_3.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 102 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/testpfp1_1.bmp
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 101 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/testpfp1_2.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 101 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/testpfp1_3.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 50 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/testpfp2_1.bmp
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 108 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/testpfp2_2.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 108 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								testimg/testpfp2_3.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 51 KiB  |