goocanvas vs crcanvas,which better?

2009-03-26 Thread chen zhixin
Program need to draw realtime lines on per frame,first time i use
cairo_surface_create_similar  and draw surface on the frame.
(frame draw on GtkDrawingArea),this make fast on my pc and the
Machine(use slitaz system),but when i use ubuntu on the machine,the
Xorg process take 100% cpu,this make me craze,i still don't kown why.

I want to use canvas to change this,there are some cairo
canvas,goocanvas can be found in lib.gnome.org,it will be a part of
gnome?
goocanvas vs crcanvas ,which should i use? or somebody have a good
method to do these.

software do these:
1. capture frame from TV card by V4L2,and then change fmt from yuyv to gray.
2. draw gray frame to GtkDrawingarea by gdk_draw_gray to a GdkPixmap.
3. do some other things on the GdkPixmap,such as draw pixbuf and
text,and then gdk_draw_drawable.
4. measure on the drawingarea.such as
line,circle,ellipse,polygon,arrow,draw results on the frame.
5. do other things ,such as zoom,save as image,video.

there are some problems:
1. can create cairo surface on GRAY picture,then i can draw something on it ?
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Ho to implement new GSource?

2009-03-26 Thread Tomasz Jankowski
Hello!

I'm working on MT application, which perform some tasks in separated
threads. My application also use GTK+ and it should work on Windows, so I
need to deal somehow with running all functions, which change GUI from one
thread.

I run one thread with GTK's main loop and i want to implement new source,
which will check GAsysnQueue for new elements (passed to it by other
threads) and perform some actions (like updating progress bars).

I went to GLib documentation and i stuck there. I'm unable to figure out how
main loop works and how can I correctly implement new source type. I cannot
use idle source, because I want to check my async queue more often. On the
other hand I want to understand how main loop works in GLib.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Ho to implement new GSource?

2009-03-26 Thread Chris Vine
On Thu, 26 Mar 2009 12:17:17 +0100
Tomasz Jankowski tomc...@gmail.com wrote:

 
 Hello!
 
 I'm working on MT application, which perform some tasks in separated
 threads. My application also use GTK+ and it should work on Windows,
 so I need to deal somehow with running all functions, which change
 GUI from one thread.
 
 I run one thread with GTK's main loop and i want to implement new
 source, which will check GAsysnQueue for new elements (passed to it
 by other threads) and perform some actions (like updating progress
 bars).
 
 I went to GLib documentation and i stuck there. I'm unable to figure
 out how main loop works and how can I correctly implement new source
 type. I cannot use idle source, because I want to check my async
 queue more often. On the other hand I want to understand how main
 loop works in GLib. 

You can use g_idle_add(), and any custom GSource object you make is
going to have to do something very similar.  In unix what g_idle_add()
does is put a byte in a pipe on which the main loop has a file
descriptor poll.  In windows I think it uses a windows thread event
object.

Instead of worker threads placing things in a GAsyncQueue, you can pass
them as a data argument when they call g_idle_add().  Or if there is a
special reason to do so you can pass the data onto a queue, and your
idle function can pop it off again.

Chris
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: goocanvas vs crcanvas,which better?

2009-03-26 Thread Dov Grobgeld
Hi Chen,

For the application that you described, using a canvas doesn't give you much
and you can just as well create a cairo context and draw on the image
directly. But there are a few things that you should be aware of:

   - Drawing overlays on av full realtime speed is going to take a lot of
   CPU no matter how fast you do it.
   - You should make sure to prepare all the data offline before you ship it
   off to the screen. Thus don't put the data from the frame grabber on the
   screen until after you have annotated it.
   - If the annotation is static, it certainly faster to prepare a
   transparent pixbuf and draw the annotation on the pixbuf and then simply
   merge the data from the frame grabber with the overlay mostly transparent
   pixbuf, and then ship the result of to display.
   - If you want the user to be able to interactively zoom the resulting
   pixbuf, you may want to have a look at my GtkImageViewer that creates such a
   zoomable interface for you. See the tutorial at:
   http://giv.sourceforge.net/gtk-image-viewer/

Regards,
Dov

2009/3/26 chen zhixin thexin1...@gmail.com

 Program need to draw realtime lines on per frame,first time i use
 cairo_surface_create_similar  and draw surface on the frame.
 (frame draw on GtkDrawingArea),this make fast on my pc and the
 Machine(use slitaz system),but when i use ubuntu on the machine,the
 Xorg process take 100% cpu,this make me craze,i still don't kown why.

 I want to use canvas to change this,there are some cairo
 canvas,goocanvas can be found in lib.gnome.org,it will be a part of
 gnome?
 goocanvas vs crcanvas ,which should i use? or somebody have a good
 method to do these.

 software do these:
 1. capture frame from TV card by V4L2,and then change fmt from yuyv to
 gray.
 2. draw gray frame to GtkDrawingarea by gdk_draw_gray to a GdkPixmap.
 3. do some other things on the GdkPixmap,such as draw pixbuf and
 text,and then gdk_draw_drawable.
 4. measure on the drawingarea.such as
 line,circle,ellipse,polygon,arrow,draw results on the frame.
 5. do other things ,such as zoom,save as image,video.

 there are some problems:
 1. can create cairo surface on GRAY picture,then i can draw something on it
 ?
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: goocanvas vs crcanvas,which better?

2009-03-26 Thread Alexander
Hi, Dov.

On Thursday 26 March 2009, Dov Grobgeld wrote:

- If the annotation is static, it certainly faster to prepare a
transparent pixbuf and draw the annotation on the pixbuf and then simply
merge the data from the frame grabber with the overlay mostly transparent
pixbuf, and then ship the result of to display.

Is there standard facility for creating cairo context for pixbuf? Like 
gdk_cairo_create() for drawables. 
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: cairo context for pixbuf

2009-03-26 Thread Pavel A. da Mek
- Original Message - 
Subject: Re: goocanvas vs crcanvas,which better?



Is there standard facility for creating cairo context for pixbuf? Like 
gdk_cairo_create() for drawables.


pixels = gdk_pixbuf_get_pixels (pixbuf);
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);
surface = cairo_image_surface_create_for_data (
 pixels,
 CAIRO_FORMAT_ARGB32,
 width, height, rowstride
);

This works if the the pixbuf has alpha;
the only flaw is that the red and blue component are exchanged,
so the function

cairo_set_source_rgb (cr, red, green, blue);

must be used as if it would be

cairo_set_source_rgb (cr, blue, green, red);

 P.A. 


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: goocanvas vs crcanvas,which better?

2009-03-26 Thread Dov Grobgeld
The following does it:

  int img_width = gdk_pixbuf_get_width(pixbuf);
  int img_height = gdk_pixbuf_get_height(pixbuf);
  cairo_surface_t *surface
= cairo_image_surface_create_for_data(gdk_pixbuf_get_pixels(pixbuf),
  CAIRO_FORMAT_ARGB32,
  img_width,
  img_height,
  gdk_pixbuf_get_rowstride(pixbuf));


You will have to swap R and B in calls to:

  cairo_set_source_rgba (cr, 0,0,1.0,0.5);


when drawing though, as cairo and gdk_pixbuf have different ideas about
their order.

(These examples are copied from the GtkImageViewer tutorial.)

Regards,
Dov

2009/3/26 Alexander b3n...@yandex.ru

 Hi, Dov.

 On Thursday 26 March 2009, Dov Grobgeld wrote:

 - If the annotation is static, it certainly faster to prepare a
 transparent pixbuf and draw the annotation on the pixbuf and then
 simply
 merge the data from the frame grabber with the overlay mostly
 transparent
 pixbuf, and then ship the result of to display.

 Is there standard facility for creating cairo context for pixbuf? Like
 gdk_cairo_create() for drawables.
 ___
 gtk-app-devel-list mailing list
 gtk-app-devel-list@gnome.org
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list