Skip to content

Commit 9ff0068

Browse files
committed
added filter logic to UI, added images to readme to reflect UI changes
1 parent 98cf9d2 commit 9ff0068

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

C_image_processing/main.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,49 @@
1010
// callback functions for all filters
1111
static void black_and_white_filter_apply(GtkWidget *widget, gpointer data)
1212
{
13+
GtkWidget *image = data;
1314
black_and_white_filter("assets/images/test_image.bmp", "assets/images/test_image_black_and_white.bmp");
15+
gtk_image_set_from_file(GTK_IMAGE(image), "assets/images/test_image_black_and_white.bmp");
1416
g_print("Black And White Filter Has Been Applied\n");
1517
}
1618

1719
static void bright_filter_apply(GtkWidget *widget, gpointer data)
1820
{
21+
GtkWidget *image = data;
1922
bright_filter("assets/images/test_image.bmp", "assets/images/test_image_bright.bmp");
23+
gtk_image_set_from_file(GTK_IMAGE(image), "assets/images/test_image_bright.bmp");
2024
g_print("Bright Filter Has Been Applied\n");
2125
}
2226

2327
static void dark_filter_apply(GtkWidget *widget, gpointer data)
2428
{
29+
GtkWidget *image = data;
2530
dark_filter("assets/images/test_image.bmp", "assets/images/test_image_dark.bmp");
31+
gtk_image_set_from_file(GTK_IMAGE(image), "assets/images/test_image_dark.bmp");
2632
g_print("Dark Filter Has Been Applied\n");
2733
}
2834

2935
static void negative_filter_apply(GtkWidget *widget, gpointer data)
3036
{
37+
GtkWidget *image = data;
3138
negative_filter("assets/images/test_image.bmp", "assets/images/test_image_negative.bmp");
39+
gtk_image_set_from_file(GTK_IMAGE(image), "assets/images/test_image_negative.bmp");
3240
g_print("Negative Filter Has Been Applied\n");
3341
}
3442

3543
static void rgb_to_gray_filter_apply(GtkWidget *widget, gpointer data)
3644
{
45+
GtkWidget *image = data;
3746
rgb_to_gray_filter("assets/images/test_image.bmp", "assets/images/test_image_rgb_to_gray.bmp");
47+
gtk_image_set_from_file(GTK_IMAGE(image), "assets/images/test_image_rgb_to_gray.bmp");
3848
g_print("RGB To Gray Filter Has Been Applied\n");
3949
}
4050

4151
static void sepia_filter_apply(GtkWidget *widget, gpointer data)
4252
{
53+
GtkWidget *image = data;
4354
sepia_filter("assets/images/test_image.bmp", "assets/images/test_image_sepia.bmp");
55+
gtk_image_set_from_file(GTK_IMAGE(image), "assets/images/test_image_dark.bmp");
4456
g_print("Sepia Filter Has Been Applied\n");
4557
}
4658

@@ -110,7 +122,7 @@ static void activate(GtkApplication *app, gpointer user_data)
110122

111123
// create image widget
112124
image = gtk_image_new_from_file("assets/images/test_image.bmp");
113-
gtk_image_set_pixel_size(GTK_IMAGE(image), 1000);
125+
gtk_image_set_pixel_size(GTK_IMAGE(image), 900);
114126

115127
// append image widget to image box
116128
gtk_box_append(GTK_BOX(image_box), image);
@@ -132,12 +144,12 @@ static void activate(GtkApplication *app, gpointer user_data)
132144
button4 = gtk_button_new_with_label("RGB To Gray Filter");
133145
button5 = gtk_button_new_with_label("Sepia Filter");
134146
// connect buttons to callback functions
135-
g_signal_connect(button0, "clicked", G_CALLBACK(black_and_white_filter_apply), NULL);
136-
g_signal_connect(button1, "clicked", G_CALLBACK(bright_filter_apply), NULL);
137-
g_signal_connect(button2, "clicked", G_CALLBACK(dark_filter_apply), NULL);
138-
g_signal_connect(button3, "clicked", G_CALLBACK(negative_filter_apply), NULL);
139-
g_signal_connect(button4, "clicked", G_CALLBACK(rgb_to_gray_filter_apply), NULL);
140-
g_signal_connect(button5, "clicked", G_CALLBACK(sepia_filter_apply), NULL);
147+
g_signal_connect(button0, "clicked", G_CALLBACK(black_and_white_filter_apply), image);
148+
g_signal_connect(button1, "clicked", G_CALLBACK(bright_filter_apply), image);
149+
g_signal_connect(button2, "clicked", G_CALLBACK(dark_filter_apply), image);
150+
g_signal_connect(button3, "clicked", G_CALLBACK(negative_filter_apply), image);
151+
g_signal_connect(button4, "clicked", G_CALLBACK(rgb_to_gray_filter_apply), image);
152+
g_signal_connect(button5, "clicked", G_CALLBACK(sepia_filter_apply), image);
141153
// append buttons to button box
142154
gtk_box_append(GTK_BOX(button_box), button0);
143155
gtk_box_append(GTK_BOX(button_box), button1);

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# C Image Processing
22

33
<p align="center">
4-
<img src="readme_image_1.png" width="800"/>
4+
<img src="readme_image_0.png" width="400"/>
5+
<img src="readme_image_1.png" width="400"/>
6+
<img src="readme_image_2.png" width="400"/>
7+
<img src="readme_image_3.png" width="400"/>
58
</p>
69

710
This program is to builds a simple library of image processing functions in C. The library is then used to create a program that can read in a PPM image, apply a filter to it, and then write the modified image to a new file.

readme_image_0.png

182 KB
Loading

readme_image_2.png

439 KB
Loading

readme_image_3.png

257 KB
Loading

0 commit comments

Comments
 (0)