initial testing.

master
Aaron 1 month ago
parent ed54d7c0b6
commit 0246b56eea

Binary file not shown.

@ -1,14 +1,14 @@
#ifndef __AMSCIMGLIB4_INTL_HPP__ #ifndef __AMSCIMGLIB4_INTL_HPP__
#define __AMSCIMGLIB4_INTL_HPP__ #define __AMSCIMGLIB4_INTL_HPP__
#include <amscimglib4/amscimglib4_tests.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <amscimglib4/amscimglib4_tests.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

@ -1,7 +1,17 @@
#ifndef __AMSCIMGLIB4_TESTS_HPP__ #ifndef __AMSCIMGLIB4_TESTS_HPP__
#define __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 #endif

@ -90,7 +90,7 @@ AMSCIMGLIB4_API int amscimglib4_image_resize(amscimglib4_image *imgptr, int _siz
return amscimglib4_failure; 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) if(newdata==NULL)
{ {
return amscimglib4_failure; 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(K=0;K<4;K++)
for(I=0;I<_sizex && I<imgptr->sizex;I++) for(I=0;I<_sizex && I<imgptr->sizex;I++)
for(J=0;J<_sizey && J<imgptr->sizey;J++) 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); 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) if(imgfrom->data!=NULL && imgto->data!=NULL)
{ {
for(K=0;K<4;K++) for(K=0;K<4;K++)
for(I=0;I<imgto->sizex;I++) for(I=0;I<imgto->sizex && I<imgfrom->sizex;I++)
for(J=0;J<imgto->sizey;J++) 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]; imgto->data[4*(I+imgto->sizex*J)+K] = imgfrom->data[4*(I+imgfrom->sizex*J)+K];
} }

@ -5,7 +5,61 @@
extern "C" { extern "C" {
#endif #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 #ifdef __cplusplus
}; //end extern "C" }; //end extern "C"

@ -5,5 +5,8 @@ int main(int argc, char* argv[])
{ {
int ret = 0; int ret = 0;
//amscimglib4_test_init();
amscimglib4_test_loadsave();
return ret; return ret;
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Loading…
Cancel
Save