Inspector: implement command line exu comparison

Only png comparison was supported.
This commit is contained in:
Daniel Zaoui 2018-11-03 22:59:50 +02:00
parent e48bda302a
commit f7dfae4423
1 changed files with 45 additions and 9 deletions

View File

@ -1362,6 +1362,7 @@ main(int argc, char *argv[])
goto end;
}
ex_unit->imgs = eina_list_append(ex_unit->imgs, ex_img);
ex_unit->nb_shots++;
_units = eina_list_append(_units, ex_unit);
}
}
@ -1437,9 +1438,10 @@ main(int argc, char *argv[])
if (compare_files && output)
{
Exactness_Unit *unit1 = NULL, *unit2 = NULL;
Eina_List *itr;
EINA_LIST_FOREACH(_units, itr, unit)
const char *out_ext = strrchr(output, '.');
Exactness_Unit *unit1 = NULL, *unit2 = NULL, *unitO = NULL;
Eina_List *itr1, *itr2;
EINA_LIST_FOREACH(_units, itr1, unit)
{
if (!unit1) unit1 = unit;
else if (!unit2) unit2 = unit;
@ -1450,16 +1452,39 @@ main(int argc, char *argv[])
}
}
if (!strcmp(ext, ".png"))
if (!strcmp(out_ext, ".png"))
{
Exactness_Image *ex_img1 = eina_list_data_get(unit1->imgs);
Exactness_Image *ex_img2 = eina_list_data_get(unit2->imgs);
Exactness_Image *ex_imgO = NULL;
if (unit1->nb_shots != 1 || unit2->nb_shots != 1)
{
fprintf(stderr, "Comparison output can be png only if the number of shots to compare is 1.\n");
goto end;
}
}
itr1 = unit1 ? unit1->imgs : NULL;
itr2 = unit2 ? unit2->imgs : NULL;
while (itr1 || itr2)
{
Exactness_Image *ex_img1 = itr1 ? eina_list_data_get(itr1) : NULL;
Exactness_Image *ex_img2 = itr2 ? eina_list_data_get(itr2) : NULL;
Exactness_Image *ex_imgO = NULL;
if (exactness_image_compare(ex_img1, ex_img2, &ex_imgO))
{
if (!unitO) unitO = calloc(1, sizeof(*unitO));
unitO->imgs = eina_list_append(unitO->imgs, ex_imgO);
unitO->nb_shots++;
}
itr1 = eina_list_next(itr1);
itr2 = eina_list_next(itr2);
}
if (!strcmp(out_ext, ".png"))
{
Ecore_Evas *ee;
Eo *e, *img;
if (unitO->nb_shots == 1)
{
Exactness_Image *ex_imgO = eina_list_data_get(unitO->imgs);
ee = ecore_evas_new(NULL, 0, 0, 100, 100, NULL);
e = ecore_evas_get(ee);
img = evas_object_image_add(e);
@ -1469,7 +1494,18 @@ main(int argc, char *argv[])
ecore_evas_free(ee);
goto end;
}
ret = 0;
}
else if (!strcmp(out_ext, ".exu"))
{
if (unitO) exactness_unit_file_write(unitO, output);
else ret = 0;
}
else
{
fprintf(stderr, "Correct output extension (.exu/.png) required\n");
}
goto end;
}
ret = 0;