GTK and images

B

bn

Hello

I have a GTK code that show image (see below). But image must be a
separate file. How to compile image and code together in one binary? I
found that Gimp has a a option that save images as *.h and *.c files.
How to show .h file by GTK functions?

Thanks in advance and sorry for my poor english :-(


#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>

int quit(void);
int interface(void);

GtkWidget *okno, *ramka, *tbl, *obrazek;

int quit() {
gtk_main_quit();
return(0); }

int interface() {
okno=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(okno), "Image");
gtk_window_set_resizable(GTK_WINDOW(okno), FALSE);
ramka=gtk_frame_new(NULL);
gtk_container_add(GTK_CONTAINER(okno), ramka);
gtk_container_set_border_width(GTK_CONTAINER(okno), 1);
tbl=gtk_table_new(7, 5, 0);
gtk_container_add(GTK_CONTAINER(ramka), tbl);
obrazek=gtk_image_new_from_file("/tmp/image.jpg");
gtk_table_attach_defaults(GTK_TABLE(tbl),
obrazek, 1, 4, 1, 2);
gtk_table_set_row_spacings(GTK_TABLE(tbl), 2);
gtk_table_set_col_spacings(GTK_TABLE(tbl), 2);
g_signal_connect(G_OBJECT(okno), "destroy", G_CALLBACK(quit), NULL);
gtk_widget_show_all(okno);
return(0); }

int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);
interface();
gtk_main();
return(0); }
 
N

Nobody

I have a GTK code that show image (see below). But image must be a
separate file. How to compile image and code together in one binary? I
found that Gimp has a a option that save images as *.h and *.c files.
How to show .h file by GTK functions?

You would do better asking on a GTK forum. However, the solution probably
involves replacing gtk_image_new_from_file() with
gtk_image_new_from_pixbuf(), and using e.g. gdk_pixbuf_new_from_data()
to create the GdkPixbuf.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top