Remove template read/write

This commit is contained in:
iabdalkader 2014-04-02 02:13:32 +02:00
parent c844da7bec
commit 25e76a5db6

View File

@ -2,82 +2,6 @@
#include "xalloc.h"
#include "imlib.h"
#include <arm_math.h>
int imlib_save_template(struct image *image, const char *path)
{
UINT n_out;
FIL fp;
FRESULT res=FR_OK;
res = f_open(&fp, path, FA_READ|FA_WRITE|FA_OPEN_ALWAYS);
if (res != FR_OK) {
return res;
}
/* write template width */
res = f_write(&fp, &image->w, sizeof(image->w), &n_out);
if (res != FR_OK || n_out != sizeof(image->w)) {
goto error;
}
/* write template height */
res = f_write(&fp, &image->h, sizeof(image->h), &n_out);
if (res != FR_OK || n_out != sizeof(image->h)) {
goto error;
}
/* write template data */
res = f_write(&fp, image->data, image->w*image->h*sizeof(*image->data), &n_out);
if (res != FR_OK || n_out != image->w*image->h*sizeof(*image->data)) {
goto error;
}
error:
f_close(&fp);
return res;
}
int imlib_load_template(struct image *image, const char *path)
{
UINT n_out;
FIL fp;
FRESULT res=FR_OK;
res = f_open(&fp, path, FA_READ|FA_OPEN_EXISTING);
if (res != FR_OK) {
return res;
}
/* read template width */
res = f_read(&fp, &image->w, sizeof(image->w), &n_out);
if (res != FR_OK || n_out != sizeof(image->w)) {
goto error;
}
/* read template height */
res = f_read(&fp, &image->h, sizeof(image->h), &n_out);
if (res != FR_OK || n_out != sizeof(image->h)) {
goto error;
}
printf("loading template:%dx%d \n", image->w, image->h);
image->data = xalloc(sizeof(*image->data)*image->w*image->h);
if (image->data == NULL) {
goto error;
}
/* read template data */
res = f_read(&fp, image->data, image->w*image->h*sizeof(*image->data), &n_out);
if (res != FR_OK || n_out != image->w*image->h*sizeof(*image->data)) {
goto error;
}
error:
f_close(&fp);
return res;
}
float imlib_template_match(struct image *f, struct image *t_orig, struct rectangle *r)
{
int x,y,u,v;