ARGB Graphics Made Easy

Code — May 22, 2006 @ 5:49 am

Many people dismiss Enlightenment’s cool GUI effects as just “hacks” that are no substitute for real transparency. That may have been true in the past when X didn’t have such features, but thanks to the new Xrender engine in Evas, it’s no longer true. For the skeptics, here’s a little 48-line program that can display any Edje file with full transparency (when a composite manager is running). Don’t try this with XLib.

#include <stdio.h>
#include <stdlib.h>
#include <Evas.h>
#include <Ecore.h>
#include <Ecore_Evas.h>
#include <Edje.h>

int main(int argc, char ** argv)
{
   Evas *evas;
   Ecore_Evas *ee;
   Evas_Object *edje;

   if (argc < 2)
      exit(1);

   ecore_init();
   ecore_app_args_set(argc, (const char **)argv);
   ecore_evas_init();
   ee = ecore_evas_xrender_x11_new(0, 0, 0, 0, 400, 400);
   evas = ecore_evas_get(ee);
   ecore_evas_alpha_set(ee, 1);
   ecore_evas_title_set(ee, "MAGIC!");
   ecore_evas_borderless_set(ee, 1);
   edje_init();
   edje_frametime_set(1.0/30.0);
   ecore_evas_move(ee, 0, 0);

   edje = edje_object_add(evas);
   if (!edje_object_file_set(edje, argv[1], "Main"))
   {
      fprintf(stderr, "Failed to load collection 'Main' from Edje file %s\n",
              argv[1]);
      exit(1);
   }
   evas_object_move(edje, 0, 0);
   ecore_evas_resize(ee, 200, 200);
   evas_object_resize(edje, 200, 200);
   evas_object_show(edje);
   ecore_evas_show(ee);
   ecore_main_loop_begin();
   edje_shutdown();
   ecore_evas_shutdown();
   ecore_shutdown();
   return 0;
}

Two examples are shown here -- a static camera image and an animated E logo:
Screenshot

You can download the source, together with the two sample edjes here. You need to have Evas, Ecore and Edje installed (visit Get-E.org for more info). This all comes with a minor caveat: Xrender performance generally ranges from sucky to depressing, and as a result evas_xrender is approximately 10 times slower than the plain software engine. But any decently fast computer should be able to handle this test case with ease.

Here’s something you’re “capable” of doing, Sheed

Humor,Sports — May 18, 2006 @ 11:14 am
Going Fishin'

Memo to Nokia

Rants — May 9, 2006 @ 6:34 pm

We hate the commercials. Especially that retarded “my cellphone is precious territory” girl. If you are really THAT stuck up about putting a guy’s number in your cellphone, you need to go see a shrink ASAP. That girl is one of the top five most annoying TV commercial actresses of all time. Please stop. Take them off. Please. I can’t stand it anymore.

Copyright © Ibukun Olumuyiwa 2007.