Fix images EET handling by using correct APIs
This commit is contained in:
parent
8882a38cdb
commit
a62f3906e7
|
@ -175,10 +175,10 @@ static Exactness_Image *
|
||||||
_pixels_compare(Exactness_Image *img1, Exactness_Image *img2, Eina_Bool *has_diff)
|
_pixels_compare(Exactness_Image *img1, Exactness_Image *img2, Eina_Bool *has_diff)
|
||||||
{
|
{
|
||||||
Exactness_Image *imgO = malloc(sizeof(*imgO));
|
Exactness_Image *imgO = malloc(sizeof(*imgO));
|
||||||
int w, h;
|
unsigned int w, h;
|
||||||
int *pxs1, *pxs2, *pxsO;
|
int *pxs1, *pxs2, *pxsO;
|
||||||
int w1 = img1 ? img1->w : 0, h1 = img1 ? img1->h : 0;
|
unsigned int w1 = img1 ? img1->w : 0, h1 = img1 ? img1->h : 0;
|
||||||
int w2 = img2 ? img2->w : 0, h2 = img2 ? img2->h : 0;
|
unsigned int w2 = img2 ? img2->w : 0, h2 = img2 ? img2->h : 0;
|
||||||
imgO->w = MAX(w1, w2);
|
imgO->w = MAX(w1, w2);
|
||||||
imgO->h = MAX(h1, h2);
|
imgO->h = MAX(h1, h2);
|
||||||
if (has_diff) *has_diff = EINA_FALSE;
|
if (has_diff) *has_diff = EINA_FALSE;
|
||||||
|
@ -187,8 +187,7 @@ _pixels_compare(Exactness_Image *img1, Exactness_Image *img2, Eina_Bool *has_dif
|
||||||
free(imgO);
|
free(imgO);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
imgO->pixels_count = imgO->w * imgO->h *4;
|
imgO->pixels = malloc(imgO->w * imgO->h * 4);
|
||||||
imgO->pixels = malloc(imgO->pixels_count);
|
|
||||||
|
|
||||||
pxs1 = img1 ? img1->pixels : NULL;
|
pxs1 = img1 ? img1->pixels : NULL;
|
||||||
pxs2 = img2 ? img2->pixels : NULL;
|
pxs2 = img2 ? img2->pixels : NULL;
|
||||||
|
@ -513,8 +512,7 @@ _image_read(const char *filename)
|
||||||
evas_object_image_size_get(img, &w, &h);
|
evas_object_image_size_get(img, &w, &h);
|
||||||
ex_img->w = w;
|
ex_img->w = w;
|
||||||
ex_img->h = h;
|
ex_img->h = h;
|
||||||
ex_img->pixels_count = w * h * 4;
|
len = w * h * 4;
|
||||||
len = ex_img->pixels_count;
|
|
||||||
ex_img->pixels = malloc(len);
|
ex_img->pixels = malloc(len);
|
||||||
memcpy(ex_img->pixels, evas_object_image_data_get(img, EINA_FALSE), len);
|
memcpy(ex_img->pixels, evas_object_image_data_get(img, EINA_FALSE), len);
|
||||||
|
|
||||||
|
@ -604,15 +602,7 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if (!strcmp(ext, ".exu"))
|
if (!strcmp(ext, ".exu"))
|
||||||
{
|
{
|
||||||
Exactness_Unit *ex_unit;
|
Exactness_Unit *ex_unit= unit_eet_read(argv[arg]);
|
||||||
Eet_File *file = eet_open(argv[arg], EET_FILE_MODE_READ);
|
|
||||||
if (!file)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Impossible to extract EET from %s\n", argv[arg]);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
ex_unit = eet_data_read(file, unit_desc_make(), CACHE_FILE_ENTRY);
|
|
||||||
eet_close(file);
|
|
||||||
_units = eina_list_append(_units, ex_unit);
|
_units = eina_list_append(_units, ex_unit);
|
||||||
}
|
}
|
||||||
else if (!strcmp(ext, ".rec"))
|
else if (!strcmp(ext, ".rec"))
|
||||||
|
|
|
@ -69,6 +69,7 @@ _shot_do(Evas *e)
|
||||||
Ecore_Evas *ee_orig;
|
Ecore_Evas *ee_orig;
|
||||||
unsigned int *pixels;
|
unsigned int *pixels;
|
||||||
int w, h;
|
int w, h;
|
||||||
|
Eina_Bool alpha;
|
||||||
|
|
||||||
if (!e) return;
|
if (!e) return;
|
||||||
|
|
||||||
|
@ -77,6 +78,8 @@ _shot_do(Evas *e)
|
||||||
ecore_evas_manual_render(ee_orig);
|
ecore_evas_manual_render(ee_orig);
|
||||||
pixels = (void *)ecore_evas_buffer_pixels_get(ee_orig);
|
pixels = (void *)ecore_evas_buffer_pixels_get(ee_orig);
|
||||||
if (!pixels) return;
|
if (!pixels) return;
|
||||||
|
|
||||||
|
alpha = ecore_evas_alpha_get(ee_orig);
|
||||||
ecore_evas_geometry_get(ee_orig, NULL, NULL, &w, &h);
|
ecore_evas_geometry_get(ee_orig, NULL, NULL, &w, &h);
|
||||||
if ((w < 1) || (h < 1)) return;
|
if ((w < 1) || (h < 1)) return;
|
||||||
|
|
||||||
|
@ -92,7 +95,7 @@ _shot_do(Evas *e)
|
||||||
_ignore_evas_creation--;
|
_ignore_evas_creation--;
|
||||||
|
|
||||||
o = evas_object_image_add(ecore_evas_get(ee));
|
o = evas_object_image_add(ecore_evas_get(ee));
|
||||||
evas_object_image_alpha_set(o, ecore_evas_alpha_get(ee_orig));
|
evas_object_image_alpha_set(o, alpha);
|
||||||
evas_object_image_size_set(o, w, h);
|
evas_object_image_size_set(o, w, h);
|
||||||
evas_object_image_data_set(o, pixels);
|
evas_object_image_data_set(o, pixels);
|
||||||
|
|
||||||
|
@ -113,12 +116,14 @@ _shot_do(Evas *e)
|
||||||
else if (_dest_type == FTYPE_EXU)
|
else if (_dest_type == FTYPE_EXU)
|
||||||
{
|
{
|
||||||
Exactness_Image *ex_img = malloc(sizeof(*ex_img));
|
Exactness_Image *ex_img = malloc(sizeof(*ex_img));
|
||||||
|
int nb_bytes = w * h * 4;
|
||||||
ex_img->w = w;
|
ex_img->w = w;
|
||||||
ex_img->h = h;
|
ex_img->h = h;
|
||||||
ex_img->pixels_count = w * h * 4;
|
ex_img->alpha = alpha;
|
||||||
ex_img->pixels = malloc(ex_img->pixels_count);
|
ex_img->pixels = malloc(nb_bytes);
|
||||||
memcpy(ex_img->pixels, pixels, ex_img->pixels_count);
|
memcpy(ex_img->pixels, pixels, nb_bytes);
|
||||||
_dest_unit->imgs = eina_list_append(_dest_unit->imgs, ex_img);
|
_dest_unit->imgs = eina_list_append(_dest_unit->imgs, ex_img);
|
||||||
|
_dest_unit->nb_shots++;
|
||||||
_printf(1, "Shot taken (in %s).\n", _dest);
|
_printf(1, "Shot taken (in %s).\n", _dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -378,14 +383,7 @@ _src_open()
|
||||||
_printf(2, "<%s> Source file is <%s>\n", __func__, _src_filename);
|
_printf(2, "<%s> Source file is <%s>\n", __func__, _src_filename);
|
||||||
if (_src_type == FTYPE_EXU)
|
if (_src_type == FTYPE_EXU)
|
||||||
{
|
{
|
||||||
Eet_File *file = eet_open(_src_filename, EET_FILE_MODE_READ);
|
_src_unit = unit_eet_read(_src_filename);
|
||||||
if (!file)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Impossible to extract EET from %s\n", _src_filename);
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
_src_unit = eet_data_read(file, unit_desc_make(), CACHE_FILE_ENTRY);
|
|
||||||
eet_close(file);
|
|
||||||
}
|
}
|
||||||
else if (_src_type == FTYPE_REC)
|
else if (_src_type == FTYPE_REC)
|
||||||
{
|
{
|
||||||
|
@ -696,10 +694,7 @@ int main(int argc, char **argv)
|
||||||
if (_dest_unit)
|
if (_dest_unit)
|
||||||
{
|
{
|
||||||
_dest_unit->events = _src_unit->events;
|
_dest_unit->events = _src_unit->events;
|
||||||
Eet_Data_Descriptor *unit_edd = unit_desc_make();
|
unit_eet_write(_dest_unit, _dest);
|
||||||
Eet_File *file = eet_open(_dest, EET_FILE_MODE_WRITE);
|
|
||||||
eet_data_write(file, unit_edd, CACHE_FILE_ENTRY, _dest_unit, EINA_TRUE);
|
|
||||||
eet_close(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
|
|
@ -103,10 +103,7 @@ _output_write()
|
||||||
Exactness_Unit unit;
|
Exactness_Unit unit;
|
||||||
unit.imgs = NULL;
|
unit.imgs = NULL;
|
||||||
unit.events = _events_list->variant_list;
|
unit.events = _events_list->variant_list;
|
||||||
Eet_Data_Descriptor *unit_edd = unit_desc_make();
|
unit_eet_write(&unit, _out_filename);
|
||||||
Eet_File *file = eet_open(_out_filename, EET_FILE_MODE_WRITE);
|
|
||||||
eet_data_write(file, unit_edd, CACHE_FILE_ENTRY, &unit, EINA_TRUE);
|
|
||||||
eet_close(file);
|
|
||||||
}
|
}
|
||||||
else if (!strcmp(_out_filename + strlen(_out_filename) - 4,".rec"))
|
else if (!strcmp(_out_filename + strlen(_out_filename) - 4,".rec"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -953,35 +953,69 @@ void _data_descriptors_shutdown(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Eet_Data_Descriptor *
|
static Eet_Data_Descriptor *
|
||||||
unit_desc_make(void)
|
_unit_desc_make(void)
|
||||||
{
|
{
|
||||||
Eet_Data_Descriptor_Class eddc;
|
Eet_Data_Descriptor_Class eddc;
|
||||||
static Eet_Data_Descriptor *unit_d = NULL;
|
static Eet_Data_Descriptor *unit_d = NULL;
|
||||||
_data_descriptors_init();
|
_data_descriptors_init();
|
||||||
if (!unit_d)
|
if (!unit_d)
|
||||||
{
|
{
|
||||||
/* Exactness_Image */
|
|
||||||
Exactness_Image ex_img;
|
|
||||||
Eet_Data_Descriptor *img_d;
|
|
||||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Image);
|
|
||||||
img_d = eet_data_descriptor_stream_new(&eddc);
|
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(img_d, Exactness_Image, "w", w, EET_T_UINT);
|
|
||||||
EET_DATA_DESCRIPTOR_ADD_BASIC(img_d, Exactness_Image, "h", h, EET_T_UINT);
|
|
||||||
eet_data_descriptor_element_add(img_d, "pixels", EET_T_CHAR, EET_G_VAR_ARRAY,
|
|
||||||
(char *)(&(ex_img.pixels)) - (char *)(&(ex_img)),
|
|
||||||
(char *)(&(ex_img.pixels_count)) - (char *)(&(ex_img)), NULL, NULL);
|
|
||||||
|
|
||||||
/* Exactness_Unit */
|
/* Exactness_Unit */
|
||||||
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Unit);
|
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Unit);
|
||||||
unit_d = eet_data_descriptor_stream_new(&eddc);
|
unit_d = eet_data_descriptor_stream_new(&eddc);
|
||||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit,
|
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit,
|
||||||
"events", events, _desc->_variant_descriptor);
|
"events", events, _desc->_variant_descriptor);
|
||||||
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit,
|
EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit,
|
||||||
"imgs", imgs, img_d);
|
"nb_shots", nb_shots, EET_T_UINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return unit_d;
|
return unit_d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* END Event struct descriptors */
|
/* END Event struct descriptors */
|
||||||
|
|
||||||
|
EAPI Exactness_Unit *
|
||||||
|
unit_eet_read(const char *filename)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
Exactness_Unit *unit = NULL;
|
||||||
|
Eet_File *file = eet_open(filename, EET_FILE_MODE_READ);
|
||||||
|
if (!file)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Impossible to extract EET from %s\n", filename);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
unit = eet_data_read(file, _unit_desc_make(), CACHE_FILE_ENTRY);
|
||||||
|
for (i = 0; i < unit->nb_shots; i++)
|
||||||
|
{
|
||||||
|
char entry[16];
|
||||||
|
Exactness_Image *ex_img = malloc(sizeof(*ex_img));
|
||||||
|
sprintf(entry, "images/%d", i + 1);
|
||||||
|
ex_img->pixels = eet_data_image_read(file, entry,
|
||||||
|
&ex_img->w, &ex_img->h, &ex_img->alpha,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
unit->imgs = eina_list_append(unit->imgs, ex_img);
|
||||||
|
}
|
||||||
|
eet_close(file);
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool unit_eet_write(Exactness_Unit *unit, const char *filename)
|
||||||
|
{
|
||||||
|
Eina_List *itr;
|
||||||
|
Exactness_Image *ex_img;
|
||||||
|
int i = 1;
|
||||||
|
Eet_File *file = eet_open(filename, EET_FILE_MODE_WRITE);
|
||||||
|
eet_data_write(file, _unit_desc_make(), CACHE_FILE_ENTRY, unit, EINA_TRUE);
|
||||||
|
EINA_LIST_FOREACH(unit->imgs, itr, ex_img)
|
||||||
|
{
|
||||||
|
char entry[16];
|
||||||
|
sprintf(entry, "images/%d", i++);
|
||||||
|
eet_data_image_write(file, entry,
|
||||||
|
ex_img->pixels, ex_img->w, ex_img->h, ex_img->alpha,
|
||||||
|
0, 100, EET_IMAGE_LOSSLESS);
|
||||||
|
}
|
||||||
|
eet_close(file);
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -269,19 +269,22 @@ EAPI Eina_Bool objects_files_compare(const char *filename1, const char *filename
|
||||||
/* START Unit desc */
|
/* START Unit desc */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int w;
|
unsigned int w;
|
||||||
int h;
|
unsigned int h;
|
||||||
|
int alpha;
|
||||||
void *pixels;
|
void *pixels;
|
||||||
int pixels_count;
|
|
||||||
} Exactness_Image;
|
} Exactness_Image;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
Eina_List *events; /* List of Variant_st */
|
Eina_List *events; /* List of Variant_st */
|
||||||
Eina_List *imgs; /* List of Exactness_Image */
|
Eina_List *imgs; /* List of Exactness_Image */
|
||||||
|
int nb_shots;
|
||||||
} Exactness_Unit;
|
} Exactness_Unit;
|
||||||
|
|
||||||
Eet_Data_Descriptor *unit_desc_make(void);
|
Eet_Data_Descriptor *unit_desc_make(void);
|
||||||
|
EAPI Exactness_Unit *unit_eet_read(const char *filename);
|
||||||
|
EAPI Eina_Bool unit_eet_write(Exactness_Unit *unit, const char *filename);
|
||||||
/* END Unit desc */
|
/* END Unit desc */
|
||||||
|
|
||||||
Tsuite_Event_Type tsuite_event_mapping_type_get(const char *name);
|
Tsuite_Event_Type tsuite_event_mapping_type_get(const char *name);
|
||||||
|
|
Loading…
Reference in New Issue