Hi Filipe,
On 19.07.2010, at 19:25, Felipe Lessa wrote:
> On Mon, Jul 19, 2010 at 4:00 AM, Axel Simon <Axel.Simon@...>
> wrote:
>> Hi Felipe,
>>
>> I've removed those functions because they didn't work. I'm amazed
>> that they
>> worked for you.
>>
>> Basically, Pixbuf stores data in 4 byte entities, containing RGBA
>> (where A
>> is alpha) and Cairo stores ARGB. I have no idea why and obviously
>> there is
>> no way to tell the libraries to store anything else. See:
>>
>> http://cairographics.org/manual/cairo-image-surface.html#cairo-format-t
>>
>> http://library.gnome.org/devel/gdk-pixbuf/stable/gdk-pixbuf-gdk-pixbuf.html#GdkColorspace
>
> I'm as amazed as you =). The code in question is:
>
> renderToImage :: Composed -> IO Image
> renderToImage ((w,h), renderer) = do
> surface <- createImageSurface FormatARGB32 (ceiling w) (ceiling h)
> renderWith surface renderer
> pixbuf <- pixbufFromImageSurface surface
> imageNewFromPixbuf pixbuf
>
> Hmmm... really funny =).
>
Is it possible, that you only draw black artefacts?
>> So, I figured that these functions were inherently broken.
>> Obviously, you
>> can select a red pen in cairo to change the alpha channel in a
>> pixbuf, but
>> that is probably not what you want. If you have a suggestion as to
>> how to
>> fix this, I'm all ears. What we could do is provide a function that
>> converts
>> one format to the other.
>
> In fact, I don't really need a pixbuf. I've used it just to create a
> new static Image. If there is a better way of doing this, I won't
> need pixbufFromImageSurface anymore. Is it possible to draw to a new
> pixmap, create the image with plain "imageNew" then use "imagePixmap"
> to set the pixmap? Unfortunately there isn't an "imageNewFromPixmap"
> nor "imageNewFromCairoSurface" =).
>
Image is also a Drawable, so you should be able to directly render
into the Image.
Obviously, there there should be a way to convert from one format to
another. But there are no C functions for that.
Cheers,
Axel
> Thanks!
>
> --
> Felipe.
|