#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#define PACKAGE_EXAMPLES_DIR "."
#endif
#include <Ecore.h>
#include <stdio.h>
#include <errno.h>
#include "evas-common.h"
#define WIDTH (320)
#define HEIGHT (240)
static const char *img_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/enlightenment.png";
static const char *commands = \
"commands are:\n"
"\tp - change proxy image's source\n"
"\ts - print noise image's stride value\n"
"\ta - save noise image to disk (/tmp dir)\n"
"\tv - change source visibility\n"
"\te - enable/disable source events\n"
"\th - print help\n";
const char *file_path = "/tmp/evas-images2-example.png";
const char *quality_str = "quality=100";
struct test_data
{
Ecore_Evas *ee;
Evas_Object *logo, *noise_img, *proxy_img, *text_obj, *bg;
};
static struct test_data d = {0};
static void
void *event_info)
{
printf("Mouse Down - obj(%p), coords(%d %d)\n",
}
static void
void *event_info)
{
printf("Mouse Move - obj(%p), coords(%d %d)\n",
}
static void
void *event_info)
{
printf("Mouse Up - obj(%p), coords(%d %d)\n",
}
static void
void *event_info)
{
printf("Multi Down - obj(%p), coords(%d %d)\n",
obj, ev->
canvas.
x, ev->canvas.
y);
}
static void
void *event_info)
{
printf("Multi Move - obj(%p), coords(%d %d)\n",
}
static void
void *event_info)
{
printf("Multi Up - obj(%p), coords(%d %d)\n",
obj, ev->
canvas.
x, ev->canvas.
y);
}
static void
void *event_info)
{
printf("Mouse In - obj(%p), coords(%d %d)\n",
}
static void
void *event_info)
{
printf("Mouse Out - obj(%p), coords(%d %d)\n",
}
static void
void *event_info)
{
printf(
"Hold - obj(%p), hold(%d)\n", obj, ev->
hold);
}
static void
{
printf("Image has been pre-loaded!\n");
}
static void
{
}
static void
_canvas_resize_cb(Ecore_Evas *ee)
{
int w, h;
evas_object_resize(d.bg, w, h);
}
static void
void *einfo)
{
if (strcmp(ev->
key,
"h") == 0)
{
puts(commands);
return;
}
if (strcmp(ev->
key,
"s") == 0)
{
int stride = evas_object_image_stride_get(d.noise_img);
printf("Image has row stride value of %d, which accounts"
" for %d pixels\n", stride, stride / 4);
return;
}
if (strcmp(ev->
key,
"p") == 0)
{
Evas_Object *source = evas_object_image_source_get(d.proxy_img);
if (source == d.logo) source = d.noise_img;
else if (source == d.noise_img) source = d.text_obj;
else source = d.logo;
evas_object_image_source_set(d.proxy_img, source);
printf("Proxy image's source changed\n");
return;
}
if (strcmp(ev->
key,
"a") == 0)
{
if (!evas_object_image_save(d.noise_img, file_path, NULL, quality_str))
fprintf(stderr, "Cannot save image to '%s' (flags '%s')\n",
file_path, quality_str);
else
printf("Image saved to '%s' (flags '%s'), check it out with "
"an image viewer\n", file_path, quality_str);
return;
}
if (strcmp(ev->
key,
"v") == 0)
{
evas_object_image_source_visible_get(d.proxy_img);
evas_object_image_source_visible_set(d.proxy_img, !src_visible);
return;
}
if (strcmp(ev->
key,
"e") == 0)
{
Eina_Bool src_events = evas_object_image_source_events_get(d.proxy_img);
evas_object_image_source_events_set(d.proxy_img, !src_events);
return;
}
}
int
main(void)
{
unsigned int i;
unsigned int pixels[(WIDTH / 4) * (HEIGHT / 4)];
srand(time(NULL));
return EXIT_FAILURE;
if (!d.ee)
evas_object_move(d.bg, 0, 0);
evas_object_resize(d.bg, WIDTH, HEIGHT);
d.logo = evas_object_image_filled_add(d.evas);
evas_object_image_preload(d.logo,
EINA_TRUE);
evas_object_image_file_set(d.logo, img_path, NULL);
evas_object_resize(d.logo, WIDTH / 2, HEIGHT / 2);
for (i = 0; i < sizeof(pixels) / sizeof(pixels[0]); i++)
pixels[i] = rand();
evas_object_image_size_set(d.noise_img, WIDTH / 4, HEIGHT / 4);
evas_object_image_data_set(d.noise_img, pixels);
evas_object_image_filled_set(d.noise_img,
EINA_TRUE);
evas_object_move(d.noise_img, (WIDTH * 5) / 8, HEIGHT / 8);
evas_object_resize(d.noise_img, WIDTH / 4, HEIGHT / 4);
printf("Creating noise image with size %d, %d\n",
WIDTH / 4, HEIGHT / 4);
evas_object_move(d.text_obj, WIDTH / 16, HEIGHT * 9 / 16);
evas_object_resize(d.text_obj, WIDTH / 4, 0);
d.proxy_img = evas_object_image_filled_add(d.evas);
evas_object_image_source_set(d.proxy_img, d.logo);
evas_object_move(d.proxy_img, WIDTH / 2, HEIGHT / 2);
evas_object_resize(d.proxy_img, WIDTH / 2, HEIGHT / 2);
puts(commands);
return 0;
fprintf(stderr, "you got to have at least one evas engine built and linked"
" up to ecore-evas for this example to run properly.\n");
return -1;
}