cairo to sdl surface

Gadi Dor <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <CAPVeivoZCe_V9L6HL50M5zsMv-mFy92aozRedXFMxgiczKpPVA@mail.gmail.com>
Hi all,

I did some progress but still I got blank window, here is my code:

Display *dpy;

    dpy = XOpenDisplay(NULL);

   //stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB32 , width);
   //SDL_Surface *sdl=SDL_SetVideoMode(width,height,24,SDL_HWSURFACE);
    //SDL_Surface *sdl;
     Uint32 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
        rmask = 0xff000000;
        gmask = 0x00ff0000;
        bmask = 0x0000ff00;
        amask = 0x00000000;
#else
        rmask = 0x000000ff;
        gmask = 0x0000ff00;
        bmask = 0x00ff0000;
        amask = 0x00000000;
#endif

SDL_Surface *sdl = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
                                      24, rmask, gmask, bmask, amask);




   cairo_surface_t *surface_source =
cairo_xlib_surface_create(dpy,DefaultRootWindow(dpy), DefaultVisual(dpy,
DefaultScreen(dpy)),height, width);

   cairo_surface_t *surface_dest =
cairo_image_surface_create_for_data((unsigned char *)sdl->pixels,
CAIRO_FORMAT_RGB24, sdl->w, sdl->h, sdl->pitch);
   cairo_t *cr_dest = cairo_create(surface_dest);
   //cairo_scale(cr_dest, (double)width, (double)height );

   cairo_set_source_surface(cr_dest, surface_source, (double)height,
(double)width);
   cairo_paint(cr_dest);

   cairo_set_source_rgba (cr_dest, 0.5, 0.5, 0.5, 1.0);
    SDL_SaveBMP(sdl,"test.bmp");
    //cairo_surface_write_to_png(surface_dest,"test.png");

   cairo_paint(cr_dest);
   cairo_surface_destroy(surface_source);
   cairo_surface_destroy(surface_dest);

I want to copy from cairo surface into sdl surface, any idea please? also
will it work fast? or is there other way?

Best Regards,
Gadi

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.