[Gtk-sharp-list] Drawing pixbufs to screen FAST..

Eto eto@shaw.ca
Wed, 05 Jan 2005 21:14:08 +0000


On January 5, 2005 07:11 pm, Dan Winship wrote:
> Are you sure you're actually drawing it to the screen? Have you read the
> bits of the gdk documentation about drawing and expose events and the
> like? The problem might be that you're not invalidating the window, so
> the drawing you do doesn't show up until some arbitrary time later.
>
> -- Dan

Hey Dan,

When doing the animation, I draw directly to the screen by doing something 
like this:

Gdk.Drawable drawable = drawingArea.GdkWindow;

// create pixbuf and generate it's content

drawable.DrawPixbuf(...);  

I don't do this in the expose event (when animating).  I do not have a problem 
with it actually drawing to screen, as it all updates properly.  It's just 
slow(er).  I wouldn't call it unbearable for some applications, but for doing 
an animation like I am, I can't get it go as fast as I need it..

It's even slower when doing any sort of scaling, like doing 50%, etc.. but 
this is mainly due to having to create a secondary pixbuf and doing 
Pixbuf.Scale() on it, then drawing the scaled pixbuf.  Ideally I'd be able to 
get all this to go fast.   

I thought of using Cairo to do the drawing so that it'd use some video 
acceleration, but havn't had much success yet on that front.

I tried Gabriel's suggestion, but unfortunately, the images aren't static so i 
would need to create the pixbuf anyway and converting from pixbuf to pixmap 
is just the same as just drawing the pixbuf. *shrug*

Thanks for any help!
Curtis.