Adding effetcs in cheese(gsoc project)



Hi
I am interested in the ideas 'hackergotchi creation' and 'Put alpha-transparent pngs onto cam image'
Because of the bigger size of the mail,i have to write a separate mail(instead of replying to original mail).You asked me to write a code.

I have written a code which is for loading image from some directory and adding alpha value to it.I couldn't write the complete working code as I am having exams.It is just the sample code.So I will write the complete working code during the 'coding period' of the project.
Here is the sample code. I have used clutter library.

#include <clutter/clutter.h>
#include <stdlib.h>

ClutterActor *stage = NULL;

/* For showing the filename: */
ClutterActor *label_filename = NULL;
ClutterBehaviour *behaviour_opacity = NULL;

 struct Item
{
  ClutterActor *actor;
  gchar* filepath;
}
Item;

void load_image(const gchar* directory_path)
{
 
  /* Discover the images in the directory: */
  GError *error = NULL;
  GDir* dir = g_dir_open (directory_path, 0, &error);
  if (error)
  {
    g_warning("g_dir_open() failed: %s\n", error->message);
    g_clear_error(&error);
    return;
  }

  const gchar* filename = NULL;
  while ( (filename = g_dir_read_name(dir)) )
  {
    gchar* path = g_build_filename (directory_path, filename, NULL);

    /* Try to load the file as an image: */
    GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(path, NULL);
    if(pixbuf)
    {
      Item* item = g_new0(Item, 1);

      /* Add an actor to show this image: */
      item->actor = clutter_texture_new_from_pixbuf (pixbuf);
      item->filepath = g_strdup(path);
     
    }

    if(pixbuf)
      g_object_unref (pixbuf);

    g_free (path);
  }
}
 
int main(int argc, char *argv[])
{
  ClutterColor stage_color = { 0xB0, 0xB0, 0xB0, 0xff };

  clutter_init (&argc, &argv);

  /* Get the stage and set its size and color: */
  stage = clutter_stage_get_default ();
  clutter_actor_set_size (stage, 800, 600);
  clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);

  /* Create and add a label actor, hidden at first: */
  label_filename = clutter_label_new ();
  ClutterColor label_color = { 0x60, 0x60, 0x90, 0xff }; /* blueish */
  clutter_label_set_color (CLUTTER_LABEL (label_filename), &label_color);
  clutter_label_set_font_name (CLUTTER_LABEL (label_filename), "Sans 24");
  clutter_actor_set_position (label_filename, 10, 10);
  clutter_actor_set_opacity (label_filename, 0);
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), label_filename);
  clutter_actor_show (label_filename);

   /* Show the stage: */
  clutter_actor_show (stage);
 
  load_image ("./images/");
  ClutterActor *actor = item->actor;
  clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
  behaviour_opacity =
  clutter_behaviour_opacity_new (alpha, 0, 255);
  clutter_behaviour_apply (behaviour_opacity, label_filename);

    /* Start the main loop, so we can respond to events: */
  clutter_main ();

  return EXIT_SUCCESS;

}



--
Ankur Modi
Undergraduate student,IT department NSIT,Delhi University,India
contact no:-9953622997

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]