C, C++
Linux(Ubuntu) GTK+3(2) Image Display - 리눅스(우분투) GTK+3(2) 이미지 디스플레이
J-sean
2021. 2. 12. 15:08
반응형
리눅스(우분투)에서 GTK+를 이용해 이미지를 디스플레이 해 보자.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#include <gtk/gtk.h>
static gboolean button_press_callback(GtkWidget* event_box, GdkEventButton* event, gpointer data)
{
g_print("Event box clicked at coordinates %f,%f\n", event->x, event->y);
return TRUE;
}
static void activate(GtkApplication* app, gpointer user_data)
{
GtkWidget* window;
GtkWidget* image;
GtkWidget* event_box;
window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), "Window");
gtk_window_set_default_size(GTK_WINDOW(window), 300, 300);
event_box = gtk_event_box_new();
gtk_container_add(GTK_CONTAINER(window), event_box);
image = gtk_image_new_from_file("Barbara Palvin.jpg");
gtk_container_add(GTK_CONTAINER(event_box), image);
g_signal_connect(G_OBJECT(event_box), "button_press_event", G_CALLBACK(button_press_callback), image);
gtk_widget_show_all(window);
}
int main(int argc, char** argv)
{
GtkApplication* app;
int status;
app = gtk_application_new("sean.s-engineer.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}
|
반응형