How to bind a cairo surface to a GTKImage widget

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to bind a cairo surface to a GTKImage widget

Arvind Arvind Pro
Hi
 
I have with me code to load an SVG (Vector) image into a cairo surface using GTKMM and CairoMM-
 
#ifdef CAIRO_HAS_SVG_SURFACE
 
    std::string filename = "image.svg";
    double width = 600;
    double height = 400;
    auto surface =
        Cairo::SvgSurface::create(filename, width, height);
 
    auto cr = Cairo::Context::create(surface);
 
    cr->save(); // save the state of the context
 
Now, I want to load this SVG image into a GTKImage area. One GTKIMage named "image_svg" is the GTKImage widget into which I want to load the SVG image.
 
How do I link the SVG image to the "image_svg" GTKImage widget?
 
Yours sincerely,
Arvind.
 

_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: How to bind a cairo surface to a GTKImage widget

Gtkmm mailing list
Hi,
You can use Gtk::Image::Set(Glib::RefPtr<Cairo::Surface>) method. See here:


Il gio 23 mag 2019, 09:29 Arvind Arvind Pro <[hidden email]> ha scritto:
Hi
 
I have with me code to load an SVG (Vector) image into a cairo surface using GTKMM and CairoMM-
 
#ifdef CAIRO_HAS_SVG_SURFACE
 
    std::string filename = "image.svg";
    double width = 600;
    double height = 400;
    auto surface =
        Cairo::SvgSurface::create(filename, width, height);
 
    auto cr = Cairo::Context::create(surface);
 
    cr->save(); // save the state of the context
 
Now, I want to load this SVG image into a GTKImage area. One GTKIMage named "image_svg" is the GTKImage widget into which I want to load the SVG image.
 
How do I link the SVG image to the "image_svg" GTKImage widget?
 
Yours sincerely,
Arvind.
 
_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list

_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: How to bind a cairo surface to a GTKImage widget

Gtkmm mailing list
Sorry, I should have written:

Gtk::Image::set(const Cairo::RefPtr<Cairo::Surface>&)

That's the right signature...

Il gio 23 mag 2019, 09:40 Luca Bacci <[hidden email]> ha scritto:
Hi,
You can use Gtk::Image::Set(Glib::RefPtr<Cairo::Surface>) method. See here:


Il gio 23 mag 2019, 09:29 Arvind Arvind Pro <[hidden email]> ha scritto:
Hi
 
I have with me code to load an SVG (Vector) image into a cairo surface using GTKMM and CairoMM-
 
#ifdef CAIRO_HAS_SVG_SURFACE
 
    std::string filename = "image.svg";
    double width = 600;
    double height = 400;
    auto surface =
        Cairo::SvgSurface::create(filename, width, height);
 
    auto cr = Cairo::Context::create(surface);
 
    cr->save(); // save the state of the context
 
Now, I want to load this SVG image into a GTKImage area. One GTKIMage named "image_svg" is the GTKImage widget into which I want to load the SVG image.
 
How do I link the SVG image to the "image_svg" GTKImage widget?
 
Yours sincerely,
Arvind.
 
_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list

_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list