Re: How to use cairo with gtk




On Mar 21, 2008, at 10:06 PM, Ye Wenbin wrote:
On Sat, 22 Mar 2008 07:15:06 +0800, muppet <scott asofyet org> wrote:
Thank you very much!
I was told to use cairo_set_source_surface function, that works.
I paste my code here, in case somebody has the same question.

Very nice.


The perl API is pretty much the same; $imagesurface->get_data() returns you a scalar holding the image data. If you ensure that the cairo image
surface is created in cairo's RGB24 format, you can use the data
directly with Gtk2::Gdk::Pixbuf like this:


[snip]

Also I try this way, but it seems weird, the window is black.
the document of  gdk_pixbuf_new_from_data says "only RGB images with 8
bits per sample are supported", is it the reason?

Yes.  Hence my warning about the RGB24 format.  ;-)

If you look at the blog mentioned in my other post, you have to do some data rearrangement for cairo's ARGB32 format.



--
If the monkey could type one keystroke every nanosecond, the expected waiting time until the monkey types out Hamlet is so long that the estimated age of the universe is insignificant by comparison ... this is not a practical method for writing plays.
  -- Gian-Carlo Rota





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