Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <gtkmm.h>
- #include <iostream>
- #include <cstring>
- #include <vector>
- int main (int argc, char *argv[])
- {
- Glib::RefPtr<Gtk::Application> app = Gtk::Application::create();
- Gtk::Window main_window;
- main_window.set_title ("Show Image");
- main_window.set_position (Gtk::WIN_POS_CENTER);
- Glib::RefPtr<Gdk::Pixbuf> ref_orig = Gdk::Pixbuf::create_from_file ("./image.png");
- const guint8* raw = ref_orig->get_pixels();
- const std::vector<guint8> image_pixels (raw, raw + ref_orig->get_byte_length());
- Glib::RefPtr<Gdk::Pixbuf> ref_dest =
- Gdk::Pixbuf::create_from_data (
- image_pixels.data(), Gdk::COLORSPACE_RGB,
- ref_orig->get_has_alpha(), ref_orig->get_bits_per_sample(),
- ref_orig->get_width(), ref_orig->get_height(), ref_orig->get_rowstride());
- Gtk::Image image;
- image.set (ref_dest);
- main_window.add (image);
- main_window.show_all_children();
- return app->run (main_window);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement