Re: Windows GTK+ 2.24.10: Cairo contexts not rendering to surface
Jeffrey Sheen <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <CAPYQ83mPP-twgRsCjV1cc7HvmXXXeLw1LEwNOwEw_xgitYrMSQ@mail.gmail.com> |
An update: I implemented LRN's GTK+ 2 alterations to the Zetcode example (see also http://stackoverflow.com/questions/21102622/how-to-create-a-cairo-t-on-a-gtk-2-window). I compiled against the same GTK+ 2 bundle as before, and rendering to the widget worked. I then dropped in this code fragment into the example project to test image surface rendering: cairo_surface_t *surface; cairo_t *cr; surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 390, 60); cr = cairo_create(surface); cairo_set_source_rgb(cr, 0, 0, 0); cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size(cr, 40.0); cairo_move_to(cr, 10.0, 50.0); cairo_show_text(cr, "Test."); cairo_surface_write_to_png(surface, "f:\\cairo_test_basic.png"); cairo_destroy(cr); cairo_surface_destroy(surface); This also worked, outputting the expected PNG file. However, this same code fragment generates a blank PNG file in my main project. I have the same GTK-related parameters in both VS projects' settings (as per http://stackoverflow.com/questions/15906580/how-to-configure-gtk-on-visual-studio-2010 ). The only difference in output when building each is that I get a dozen linker warnings for my main project, all of the form: 1>gdk-win32-2.0.lib(libgdk-win32-2.0-0.dll) : warning LNK4006: __NULL_IMPORT_DESCRIPTOR already defined in gtk-win32-2.0.lib(libgtk-win32-2.0-0.dll); second definition ignored 1>gdk-win32-2.0.lib(libgdk-win32-2.0-0.dll) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library I'd appreciate any advice. Jeff. On 22 January 2017 at 22:41, Jeffrey Sheen < [email protected]> wrote: > Thanks. I'll try the suggested syntax for the GDK Window example, and find > an earlier API reference. > > However, I have also tried rendering with an image context, and the > resulting PNG was blank too. > > Is it possible that I'm having the same issue here (the API has changed, > but for Cairo specifically)? > > What I'll do is build against the very latest stable GTK libs, to check > whether the code functions as expected in the reference examples (i.e. > pixels are rendered). > > Then, given Windows XP is a target platform, what is the latest version of > the Cairo libs that I can build against? N.B. I'm using Cairo in > combination with Pango for image surface rendering only. > > On 22 Jan 2017 21:28, "LRN" <[email protected]> wrote: > > On 22.01.2017 23:24, Jeffrey Sheen wrote: > > Dear list, > > > > I'm trying to incorporate Cairo rendering into a cross-platform project. > > Windows XP is a target platform for the project, so I am building > against the > > GTK+ 2.24.10 Bundle (20120208). N.B. This is a C/C++ implementation. > > > > The problem I'm having is that no Cairo backend contexts are rendering > pixels > > to their surfaces. > > > > I've tried the examples on the Zetcode guides for a PNG image surface > and GTK > > Window: http://zetcode.com/gfx/cairo/cairobackends/ > > These are for GTK3, i think. For GTK2 you need to do something like this: > > ... > g_signal_connect(G_OBJECT(darea), "expose-event", > G_CALLBACK(on_expose_event), NULL); > ... > > static gboolean > on_expose_event (GtkWidget *widget, > GdkEventExpose *event, > gpointer data) > { > cairo_t *cr; > > cr = gdk_cairo_create (gtk_widget_get_window (widget)); > > do_drawing (cr); > > cairo_destroy (cr); > > return FALSE; > } > > > -- > O< ascii ribbon - stop html email! - www.asciiribbon.org > > -- > cairo mailing list > [email protected] > https://lists.cairographics.org/mailman/listinfo/cairo > > > -- cairo mailing list [email protected] https://lists.cairographics.org/mailman/listinfo/cairo