Hi,

I had a little time and I have looked into the Cairo backend sources. The
context is based on the (cairo_surface_t *) type. From Cairo documentation
[1]:

  A cairo_surface_t represents an image, either as the destination
  of a drawing operation or as source when drawing onto another
  surface. There are different subtypes of cairo_surface_t for different
  drawing backends; for example, cairo_image_surface_create() creates
  a bitmap image in memory. 

... then it is possible to have a bitmap from Cairo backend.

What more! There is:

cairo_surface_t* cairo_image_surface_create_for_data
                                            (unsigned char *data,
                                             cairo_format_t format,
                                             int width,
                                             int height,
                                             int stride);
With this it would be possible to do what is described in [2]:

NSImage* image = [self getCurrentImage]; 
NSSize size = [image size];  
[image lockFocus]; 
  
NSBitmapImageRep* rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: 
                        NSMakeRect(0,0,size.width,size.height)]; 
  
[image unlockFocus]; 
...

where one would pass [rep bitmapData] into the
cairo_image_surface_create_for_data function.

Now, if I understand it correctly, then if there was an API between GNUstep-gui
and GNUstep-back that would allow GNUstep-gui to pick a kind of drawing
context, then it would be possible to have bitmap drawing in GNUstep-gui.


>From naive point of view the steps necessary would be:
1. create API for picking graphics context with prefered destination
2. pick ONE graphics library as preffered graphics context library and move it's
use (or use of a bundle) into GUI
3. update GUI to use graphics context provided by the graphics library

Can someone who knows more about the gui and back internals look at it closer?

Looks like all necessary code is already in GNUstep, it is just a matter of
"rewiring" it. But well ... I do not see much into the internals...

Regards,

Stefan Urbanek

[1] http://www.cairographics.org/manual/cairo-cairo-surface-t.html
[2]
http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Images/chapter_7_section_5.html#//apple_ref/doc/uid/TP40003290-CH208-BCICHFGA


--
http://stefan.agentfarms.net

First they ignore you, then they laugh at you, then they fight you, then
you win.
- Mahatma Gandhi


_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to