Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cairo.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <windows.h>
- #include <gtk/gtk.h>
- #include <gdk/gdk.h>
- #include <gtk/gtkscale.h>
- #include <gtk/gtkvscale.h>
- #include <gtk/gtkvscale.h>
- #include <gdk/gdkkeysyms.h>
- #include <gdk-pixbuf/gdk-pixbuf.h>
- const int square_size = 30;
- float brightness_val = 0.0, contrast_val = 0.0;
- int global, ini, total, flag = 0, image_flag = 0, image_flag2 = 0, neg_flag = 0, grey_flag = 0;
- int width, height, heightini;
- char str[500], str2[500], str3[500], str4[500], str5[500], str6[500], slide[500];
- char image_list[5000][100];
- gint offset;
- GtkWindow *window;
- GdkPixbuf *windowicon, *mypic, *result_pixbuf;
- GtkWidget *fixed_layout, *img, *img2, *dialog, *gbdialog, *grayscale, *brightness, *contrast, *negative;
- GtkButton *openbutton, *closebutton, *nextbutton, *previousbutton, *playbutton, *aboutbutton, *gotofirstbutton, *gotolastbutton, *stopbutton, *negativebutton, *greyscalebutton, *contrastbutton, *brightnessbutton, *restorebutton1, *restorebutton2, *brightnessbutton2, *contrastbutton2, *minimizebutton;
- GtkTooltips *opentooltip, *closetooltip, *nexttooltip, *previoustooltip, *playtooltip, *abouttooltip, *gotofirsttooltip, *gotolasttooltip, *stoptooltip, *negativetooltip, *greyscaletooltip, *contrasttooltip, *brightnesstooltip, *restoretooltip1, *restoretooltip2, *brightnesstooltip2, *contrasttooltip2, *minimizetooltip;
- static unsigned char apply_contrast (unsigned char u_value, float contrast);
- static unsigned char apply_brightness (unsigned char u_value, float brightness);
- static int keyboard_keys(GtkWidget *futile, GdkEventKey *lol, gpointer user_data);
- void create_toolbar();
- void show_about();
- void open_file();
- void start_slide();
- void stop_slide();
- void get_list(char filename[500]);
- void store_list();
- gboolean show_next(gpointer userdata);
- void show_next2();
- void show_previous();
- void image_brightness();
- void image_contrast();
- void goto_first();
- void goto_last();
- void image_negative();
- void increase_brightness();
- void decrease_brightness();
- void increase_contrast();
- void decrease_contrast();
- void image_greyscale();
- void show_original1();
- void show_original2();
- void goodbye_dialog();
- void create_toolbar()
- {
- ini = 10;
- openbutton = gtk_button_new();
- opentooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(openbutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(openbutton),gtk_image_new_from_stock(GTK_STOCK_ORIENTATION_PORTRAIT, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(openbutton), ini, heightini - 40);
- gtk_tooltips_set_tip(opentooltip, GTK_WIDGET(openbutton), "Open (Ctrl+O)", "Open (Ctrl+O)");
- total = (14 * 30) + (13 * 4);
- ini = (width - total) / 2;
- brightnessbutton2 = gtk_button_new();
- brightnesstooltip2 = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(brightnessbutton2), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(brightnessbutton2),gtk_image_new_from_stock(GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(brightnessbutton2), ini, heightini - 40);
- gtk_tooltips_set_tip(brightnesstooltip2, GTK_WIDGET(brightnessbutton2), "Decrease Brightness (-)", "Decrease Brightness (-)");
- ini += 40;
- brightnessbutton = gtk_button_new();
- brightnesstooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(brightnessbutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(brightnessbutton),gtk_image_new_from_stock(GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(brightnessbutton), ini, heightini - 40);
- gtk_tooltips_set_tip(brightnesstooltip, GTK_WIDGET(brightnessbutton), "Increase Brightness (+)", "Increase Brightness (+)");
- ini += 40;
- contrastbutton2 = gtk_button_new();
- contrasttooltip2 = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(contrastbutton2), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(contrastbutton2),gtk_image_new_from_stock(GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(contrastbutton2), ini, heightini - 40);
- gtk_tooltips_set_tip(contrasttooltip2, GTK_WIDGET(contrastbutton2), "Decrease Contrast (Ctrl -)", "Decrease Contrast (Ctrl -)");
- ini += 40;
- contrastbutton = gtk_button_new();
- contrasttooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(contrastbutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(contrastbutton),gtk_image_new_from_stock(GTK_STOCK_GO_UP, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(contrastbutton), ini, heightini - 40);
- gtk_tooltips_set_tip(contrasttooltip, GTK_WIDGET(contrastbutton), "Increase Contrast (Ctrl +)", "Increase Contrast (Ctrl +)");
- ini += 40;
- gotofirstbutton = gtk_button_new();
- gotofirsttooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(gotofirstbutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(gotofirstbutton),gtk_image_new_from_stock(GTK_STOCK_GOTO_FIRST, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(gotofirstbutton), ini, heightini - 40);
- gtk_tooltips_set_tip(gotofirsttooltip, GTK_WIDGET(gotofirstbutton), "Go to first image (Page Up)", "Go to first image (Page Up)");
- ini += 40;
- previousbutton = gtk_button_new();
- previoustooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(previousbutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(previousbutton),gtk_image_new_from_stock(GTK_STOCK_MEDIA_PREVIOUS, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(previousbutton), ini, heightini - 40);
- gtk_tooltips_set_tip(previoustooltip, GTK_WIDGET(previousbutton), "Show Previous (Left key)", "Show Previous (Left key)");
- ini += 40;
- playbutton = gtk_button_new();
- playtooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(playbutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(playbutton),gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(playbutton), ini, heightini - 40);
- gtk_tooltips_set_tip(playtooltip, GTK_WIDGET(playbutton), "Start Slideshow (Spacebar)", "Start Slideshow (Spacebar)");
- stopbutton = gtk_button_new();
- stoptooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(stopbutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(stopbutton),gtk_image_new_from_stock(GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(stopbutton), ini, heightini - 40);
- gtk_tooltips_set_tip(stoptooltip, GTK_WIDGET(stopbutton), "Stop Slideshow (Spacebar)", "Stop Slideshow (Spacebar)");
- ini += 40;
- nextbutton = gtk_button_new();
- nexttooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(nextbutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(nextbutton),gtk_image_new_from_stock(GTK_STOCK_MEDIA_NEXT, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(nextbutton), ini, heightini - 40);
- gtk_tooltips_set_tip(nexttooltip, GTK_WIDGET(nextbutton), "Show Next (Right Key)", "Show Next (Right Key)");
- ini += 40;
- gotolastbutton = gtk_button_new();
- gotolasttooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(gotolastbutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(gotolastbutton),gtk_image_new_from_stock(GTK_STOCK_GOTO_LAST, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(gotolastbutton), ini, heightini - 40);
- gtk_tooltips_set_tip(gotolasttooltip, GTK_WIDGET(gotolastbutton), "Go to last image (Page Down)", "Go to last image (Page Down)");
- ini += 40;
- negativebutton = gtk_button_new();
- negativetooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(negativebutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(negativebutton),gtk_image_new_from_stock(GTK_STOCK_CONVERT, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(negativebutton), ini, heightini - 40);
- gtk_tooltips_set_tip(negativetooltip, GTK_WIDGET(negativebutton), "Show Negative (Ctrl+N)", "Show Negative (Ctrl+N)");
- restorebutton1 = gtk_button_new();
- restoretooltip1 = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(restorebutton1), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(restorebutton1),gtk_image_new_from_stock(GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(restorebutton1), ini, heightini - 40);
- gtk_tooltips_set_tip(restoretooltip1, GTK_WIDGET(restorebutton1), "Restore (Ctrl+N)", "Restore (Ctrl+N)");
- ini += 40;
- greyscalebutton = gtk_button_new();
- greyscaletooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(greyscalebutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(greyscalebutton),gtk_image_new_from_stock(GTK_STOCK_CONNECT, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(greyscalebutton), ini, heightini - 40);
- gtk_tooltips_set_tip(greyscaletooltip, GTK_WIDGET(greyscalebutton), "Show Greyscale Image (Ctrl+G)", "Show Greyscale Image (Ctrl+G)");
- restorebutton2 = gtk_button_new();
- restoretooltip2 = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(restorebutton2), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(restorebutton2),gtk_image_new_from_stock(GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(restorebutton2), ini, heightini - 40);
- gtk_tooltips_set_tip(restoretooltip2, GTK_WIDGET(restorebutton2), "Restore (Ctrl+G)", "Restore (Ctrl+G)");
- ini = width - 40;
- closebutton = gtk_button_new();
- closetooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(closebutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(closebutton),gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(closebutton), ini, heightini - 40);
- gtk_tooltips_set_tip(closetooltip, GTK_WIDGET(closebutton), "Close :( (Ctrl+Q)", "Close :( (Ctrl+Q)");
- ini -= 40;
- minimizebutton = gtk_button_new();
- minimizetooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(minimizebutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(minimizebutton),gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(minimizebutton), ini, heightini - 40);
- gtk_tooltips_set_tip(minimizetooltip, GTK_WIDGET(minimizebutton), "Minimize", "Minimize");
- ini -= 40;
- aboutbutton = gtk_button_new();
- abouttooltip = gtk_tooltips_new();
- gtk_widget_set_size_request(GTK_WIDGET(aboutbutton), square_size, square_size);
- gtk_button_set_image (GTK_BUTTON(aboutbutton),gtk_image_new_from_stock(GTK_STOCK_INFO, GTK_ICON_SIZE_BUTTON));
- gtk_fixed_put(GTK_FIXED(fixed_layout), GTK_WIDGET(aboutbutton), ini, heightini - 40);
- gtk_tooltips_set_tip(abouttooltip, GTK_WIDGET(aboutbutton), "About Us :)", "About Us :)");
- }
- void show_about()
- {
- GtkWidget *dialog;
- const char copyright[] = "Copyright @ Fireflight TM, 2011. All rights reserved.";
- const char *author[] = {"Scape", "mr.rana", "(And special thanks to Mehedi Hasan and Shadman Shadab)", "", "Contact information: sgtlaugh@gmail.com",NULL};
- dialog = gtk_about_dialog_new();
- gtk_window_set_decorated(GTK_WINDOW(dialog), FALSE);
- gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG(dialog),"Firedlight Image Viewer v1.052");
- gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG(dialog),author);
- gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog), copyright);
- gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG(dialog),"A free image viewer :)");
- windowicon = gdk_pixbuf_new_from_file(slide, NULL);
- gtk_window_set_icon(GTK_WINDOW(dialog), windowicon);
- gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER_ALWAYS);
- gtk_dialog_run(GTK_DIALOG(dialog));
- gtk_widget_destroy(dialog);
- }
- void open_file()
- {
- char *filename;
- dialog = gtk_file_chooser_dialog_new ("Open File",window,GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,NULL);
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
- {
- gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
- gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
- grey_flag = 0, neg_flag = 0, image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
- filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
- strcpy(slide, filename);
- get_list(filename);
- store_list();
- system(str2);
- img = gtk_image_new_from_file(filename);
- img2 = img;
- mypic = gdk_pixbuf_new_from_file(filename, NULL);
- windowicon = gdk_pixbuf_new_from_file(filename, NULL);
- gtk_window_set_icon(GTK_WINDOW(window), windowicon);
- GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
- pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
- gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
- gtk_widget_show(img);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img);
- g_free (filename);
- }
- gtk_widget_destroy (dialog);
- }
- void image_greyscale()
- {
- grey_flag = 1, image_flag = 0;
- GtkWidget *img;
- gtk_widget_hide(GTK_WIDGET(greyscalebutton));
- gtk_widget_show(GTK_WIDGET(restorebutton2));
- if (image_flag2 == 0)
- {
- char *sp, *dp;
- int localwidth, localheight, line, result_rowstride, mypic_rowstride, bytes_per_pixel;
- result_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (mypic),
- gdk_pixbuf_get_has_alpha (mypic),
- gdk_pixbuf_get_bits_per_sample (mypic),
- gdk_pixbuf_get_width (mypic),
- gdk_pixbuf_get_height (mypic));
- localwidth = gdk_pixbuf_get_width (result_pixbuf);
- localheight = gdk_pixbuf_get_height (result_pixbuf);
- result_rowstride = gdk_pixbuf_get_rowstride (result_pixbuf);
- mypic_rowstride = gdk_pixbuf_get_rowstride (mypic);
- bytes_per_pixel = gdk_pixbuf_get_has_alpha (result_pixbuf) ? 4 : 3;
- sp = gdk_pixbuf_get_pixels (mypic);
- dp = gdk_pixbuf_get_pixels (result_pixbuf);
- for (line = 0; line < localheight; line ++)
- {
- char *sq = sp;
- char *dq = dp;
- int i;
- for (i = 0; i < localwidth; i ++)
- {
- dq[0] = (sq[0] + sq[1] + sq[2]) / 10;
- dq[1] = dq[0];
- dq[2] = dq[0];
- dq += bytes_per_pixel;
- sq += bytes_per_pixel;
- }
- sp += mypic_rowstride;
- dp += result_rowstride;
- }
- }
- img = gtk_image_new();
- result_pixbuf = gdk_pixbuf_scale_simple(result_pixbuf, width, height, GDK_INTERP_BILINEAR);
- gtk_image_set_from_pixbuf(GTK_IMAGE(img), result_pixbuf);
- gtk_widget_show(img);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img);
- image_flag2 = 1;
- }
- void show_original2()
- {
- grey_flag = 0;
- GtkWidget *img3;
- GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img2));
- pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
- img3 = gtk_image_new();
- gtk_image_set_from_pixbuf(GTK_IMAGE(img3), pixbuf);
- gtk_widget_show(img3);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img3);
- gtk_widget_hide(GTK_WIDGET(restorebutton2));
- gtk_widget_show(GTK_WIDGET(greyscalebutton));
- }
- void image_negative()
- {
- image_flag2 = 0, neg_flag = 1;
- GtkWidget *img;
- gtk_widget_hide(GTK_WIDGET(negativebutton));
- gtk_widget_show(GTK_WIDGET(restorebutton1));
- if (image_flag == 0)
- {
- char *sp, *dp;
- int localwidth, localheight, line, result_rowstride, mypic_rowstride, bytes_per_pixel;
- result_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (mypic),
- gdk_pixbuf_get_has_alpha (mypic),
- gdk_pixbuf_get_bits_per_sample (mypic),
- gdk_pixbuf_get_width (mypic),
- gdk_pixbuf_get_height (mypic));
- localwidth = gdk_pixbuf_get_width (result_pixbuf);
- localheight = gdk_pixbuf_get_height (result_pixbuf);
- result_rowstride = gdk_pixbuf_get_rowstride (result_pixbuf);
- mypic_rowstride = gdk_pixbuf_get_rowstride (mypic);
- bytes_per_pixel = gdk_pixbuf_get_has_alpha (result_pixbuf) ? 4 : 3;
- sp = gdk_pixbuf_get_pixels (mypic);
- dp = gdk_pixbuf_get_pixels (result_pixbuf);
- for (line = 0; line < localheight; line++)
- {
- char *sq = sp;
- char *dq = dp;
- int i;
- for (i = 0; i < localwidth; i++)
- {
- dq[0] = 255 - sq[0];
- dq[1] = 255 - sq[1];
- dq[2] = 255 - sq[2];
- dq += bytes_per_pixel;
- sq += bytes_per_pixel;
- }
- sp += mypic_rowstride;
- dp += result_rowstride;
- }
- }
- img = gtk_image_new();
- result_pixbuf = gdk_pixbuf_scale_simple(result_pixbuf, width, height, GDK_INTERP_BILINEAR);
- gtk_image_set_from_pixbuf(GTK_IMAGE(img), result_pixbuf);
- gtk_widget_show(img);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img);
- image_flag = 1;
- }
- void show_original1()
- {
- neg_flag = 0;
- GtkWidget *img3;
- GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img2));
- pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
- img3 = gtk_image_new();
- gtk_image_set_from_pixbuf(GTK_IMAGE(img3), pixbuf);
- gtk_widget_show(img3);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img3);
- gtk_widget_hide(GTK_WIDGET(restorebutton1));
- gtk_widget_show(GTK_WIDGET(negativebutton));
- }
- static unsigned char apply_brightness (unsigned char u_value, float brightness)
- {
- float nvalue, value;
- double power;
- value = (float) u_value / 255.0;
- if (brightness < 0.0) value = value * (1.0 + brightness);
- else value = value + ((1.0 - value) * brightness);
- return (guchar) (value * 255);
- }
- static unsigned char apply_contrast (unsigned char u_value, float contrast)
- {
- float nvalue;
- double power;
- float value;
- value = (float) u_value / 255.0;
- if (contrast < 0.0)
- {
- if (value > 0.5) nvalue = 1.0 - value;
- else nvalue = value;
- if (nvalue < 0.0) nvalue = 0.0;
- nvalue = 0.5 * pow (nvalue * 2.0 , (double) (1.0 + contrast));
- if (value > 0.5) value = 1.0 - nvalue;
- else value = nvalue;
- }
- else
- {
- if (value > 0.5) nvalue = 1.0 - value;
- else nvalue = value;
- if (nvalue < 0.0) nvalue = 0.0;
- power = (contrast == 1.0) ? 127 : 1.0 / (1.0 - contrast);
- nvalue = 0.5 * pow (2.0 * nvalue, power);
- if (value > 0.5) value = 1.0 - nvalue;
- else value = nvalue;
- }
- return (guchar) (value * 255);
- }
- void image_contrast()
- {
- GtkWidget *img;
- GdkPixbuf *result_pixbuf;
- char *sp, *dp;
- int localwidth, localheight, line, result_rowstride, mypic_rowstride, bytes_per_pixel;
- g_return_val_if_fail ((contrast_val > -1.0 ) && (contrast_val < 1.0 ), NULL);
- result_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (mypic),
- gdk_pixbuf_get_has_alpha (mypic),
- gdk_pixbuf_get_bits_per_sample (mypic),
- gdk_pixbuf_get_width (mypic),
- gdk_pixbuf_get_height (mypic));
- localwidth = gdk_pixbuf_get_width (result_pixbuf);
- localheight = gdk_pixbuf_get_height (result_pixbuf);
- result_rowstride = gdk_pixbuf_get_rowstride (result_pixbuf);
- mypic_rowstride = gdk_pixbuf_get_rowstride (mypic);
- bytes_per_pixel = gdk_pixbuf_get_has_alpha (result_pixbuf) ? 4 : 3;
- sp = gdk_pixbuf_get_pixels (mypic);
- dp = gdk_pixbuf_get_pixels (result_pixbuf);
- for (line = 0; line < localheight; line ++)
- {
- char *sq = sp;
- char *dq = dp;
- int i;
- for (i = 0; i < localwidth; i ++)
- {
- dq[0] = apply_contrast (sq[0], contrast_val);
- dq[1] = apply_contrast (sq[1], contrast_val);
- dq[2] = apply_contrast (sq[2], contrast_val);
- dq += bytes_per_pixel;
- sq += bytes_per_pixel;
- }
- sp += mypic_rowstride;
- dp += result_rowstride;
- }
- img = gtk_image_new();
- result_pixbuf = gdk_pixbuf_scale_simple(result_pixbuf, width, height, GDK_INTERP_BILINEAR);
- gtk_image_set_from_pixbuf(GTK_IMAGE(img), result_pixbuf);
- gtk_widget_show(img);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img);
- }
- void image_brightness()
- {
- GtkWidget *img;
- char *sp, *dp;
- int localwidth, localheight, line, result_rowstride, mypic_rowstride, bytes_per_pixel;
- g_return_val_if_fail ((brightness_val > -1.0 ) && (brightness_val < 1.0 ), NULL);
- result_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (mypic),
- gdk_pixbuf_get_has_alpha (mypic),
- gdk_pixbuf_get_bits_per_sample (mypic),
- gdk_pixbuf_get_width (mypic),
- gdk_pixbuf_get_height (mypic));
- localwidth = gdk_pixbuf_get_width (result_pixbuf);
- localheight = gdk_pixbuf_get_height (result_pixbuf);
- result_rowstride = gdk_pixbuf_get_rowstride (result_pixbuf);
- mypic_rowstride = gdk_pixbuf_get_rowstride (mypic);
- bytes_per_pixel = gdk_pixbuf_get_has_alpha (result_pixbuf) ? 4 : 3;
- sp = gdk_pixbuf_get_pixels (mypic);
- dp = gdk_pixbuf_get_pixels (result_pixbuf);
- for (line = 0; line < localheight; line ++)
- {
- char *sq = sp;
- char *dq = dp;
- int i;
- for (i = 0; i < localwidth; i ++)
- {
- dq[0] = apply_brightness (sq[0], brightness_val);
- dq[1] = apply_brightness (sq[1], brightness_val);
- dq[2] = apply_brightness (sq[2], brightness_val);
- dq += bytes_per_pixel;
- sq += bytes_per_pixel;
- }
- sp += mypic_rowstride;
- dp += result_rowstride;
- }
- img = gtk_image_new();
- result_pixbuf = gdk_pixbuf_scale_simple(result_pixbuf, width, height, GDK_INTERP_BILINEAR);
- gtk_image_set_from_pixbuf(GTK_IMAGE(img), result_pixbuf);
- gtk_widget_show(img);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img);
- }
- static int keyboard_keys(GtkWidget *futile, GdkEventKey *lol, gpointer user_data)
- {
- if (lol->state == GDK_CONTROL_MASK && lol->keyval == GDK_KEY_q)
- goodbye_dialog();
- if (lol->state == GDK_CONTROL_MASK && lol->keyval == GDK_KEY_o)
- open_file();
- if (lol->state == GDK_CONTROL_MASK && lol->keyval == GDK_KEY_n)
- {
- if (neg_flag == 0) image_negative();
- else show_original1();
- }
- if (lol->state == GDK_CONTROL_MASK && lol->keyval == GDK_KEY_g)
- {
- if (grey_flag == 0) image_greyscale();
- else show_original2();
- }
- if (lol->keyval == GDK_KEY_Right)
- show_next2();
- if (lol->keyval == GDK_KEY_Left)
- show_previous();
- if (lol->keyval == GDK_KEY_space)
- {
- if (flag == 0) flag = 1;
- else flag = 0;
- if (flag == 1) start_slide();
- else stop_slide();
- }
- if (lol->keyval == GDK_KEY_Page_Up)
- goto_first();
- if (lol->keyval == GDK_KEY_Page_Down)
- goto_last();
- if (lol->state != GDK_CONTROL_MASK && (lol->keyval == 65451 || lol->keyval == GDK_KEY_plus))
- increase_brightness();
- if (lol->state != GDK_CONTROL_MASK && (lol->keyval == 65453 || lol->keyval == GDK_KEY_minus))
- decrease_brightness();
- if (lol->state == GDK_CONTROL_MASK && (lol->keyval == 65451 || lol->keyval == GDK_KEY_plus))
- increase_contrast();
- if (lol->state == GDK_CONTROL_MASK && (lol->keyval == 65453 || lol->keyval == GDK_KEY_minus))
- decrease_contrast();
- return TRUE;
- }
- void start_slide()
- {
- gint func_ref = g_timeout_add(3000, show_next, (gpointer)32);
- gtk_widget_hide(GTK_WIDGET(playbutton));
- gtk_widget_hide(GTK_WIDGET(openbutton));
- gtk_widget_hide(GTK_WIDGET(closebutton));
- gtk_widget_hide(GTK_WIDGET(gotofirstbutton));
- gtk_widget_hide(GTK_WIDGET(gotolastbutton));
- gtk_widget_hide(GTK_WIDGET(nextbutton));
- gtk_widget_hide(GTK_WIDGET(previousbutton));
- gtk_widget_hide(GTK_WIDGET(aboutbutton));
- gtk_widget_hide(GTK_WIDGET(negativebutton));
- gtk_widget_hide(GTK_WIDGET(restorebutton1));
- gtk_widget_hide(GTK_WIDGET(restorebutton2));
- gtk_widget_hide(GTK_WIDGET(greyscalebutton));
- gtk_widget_hide(GTK_WIDGET(contrastbutton));
- gtk_widget_hide(GTK_WIDGET(contrastbutton2));
- gtk_widget_hide(GTK_WIDGET(brightnessbutton));
- gtk_widget_hide(GTK_WIDGET(minimizebutton));
- gtk_widget_hide(GTK_WIDGET(brightnessbutton2));
- gtk_widget_show(GTK_WIDGET(stopbutton));
- flag = 1;
- }
- void stop_slide()
- {
- flag = 0;
- gint func_ref = g_timeout_add(10000000, show_next, (gpointer)32);
- img2 = img;
- mypic = gdk_pixbuf_new_from_file(str5, NULL);
- gtk_widget_hide(GTK_WIDGET(stopbutton));
- gtk_widget_show(GTK_WIDGET(playbutton));
- gtk_widget_show(GTK_WIDGET(openbutton));
- gtk_widget_show(GTK_WIDGET(closebutton));
- gtk_widget_show(GTK_WIDGET(gotofirstbutton));
- gtk_widget_show(GTK_WIDGET(gotolastbutton));
- gtk_widget_show(GTK_WIDGET(nextbutton));
- gtk_widget_show(GTK_WIDGET(previousbutton));
- gtk_widget_show(GTK_WIDGET(negativebutton));
- gtk_widget_show(GTK_WIDGET(greyscalebutton));
- gtk_widget_show(GTK_WIDGET(contrastbutton));
- gtk_widget_show(GTK_WIDGET(contrastbutton2));
- gtk_widget_show(GTK_WIDGET(brightnessbutton));
- gtk_widget_show(GTK_WIDGET(minimizebutton));
- gtk_widget_show(GTK_WIDGET(brightnessbutton2));
- gtk_widget_show(GTK_WIDGET(aboutbutton));
- }
- void get_list(char filename[500])
- {
- int k = 0, j, l = 0, x;
- int len = strlen(filename);
- for (j = len - 1; filename[j] != '\\'; j--) x = 1;
- str[0] = 0;
- strcat(str, "cd /d ");
- for (k = 0; k < j; k++) str4[l++] = filename[k];
- str4[l] = 0;
- str3[0] = filename[0], str3[1] = filename[1], str3[2] = 0;
- system(str3);
- strcat(str, str4);
- strcpy(str2, str);
- strcat(str, " && dir /b >> dir_listing.txt");
- strcat(str2, " && del dir_listing.txt");
- system(str);
- strcat(str4, "\\dir_listing.txt");
- }
- void store_list()
- {
- FILE *input;
- input = fopen(str4, "r");
- for (global = 0; ;global++)
- {
- if (fscanf(input, "%[^\n]", image_list[global]) == EOF) break;
- fgetc(input);
- }
- fclose(input);
- }
- gboolean show_next(gpointer userdata)
- {
- if (flag == 0) return FALSE;
- int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
- for (; ;)
- {
- for (i = 0; i < global; i++)
- {
- strcpy(str3, image_list[i]);
- l = 0, len = strlen(slide);
- str5[0] = 0;
- for (j = len - 1; slide[j] != '\\'; j--) k = 1;
- for (k = 0; k <= j; k++) str5[l++] = slide[k];
- str5[l] = 0, k = 0;
- strcat(str5, str3), len = strlen(str3);
- for (l = len - 4; l < len; l++) str6[k++] = str3[l];
- str6[k] = 0;
- if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
- {
- if (flag2 == 1)
- {
- grey_flag = 0, neg_flag = 0, image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
- img = gtk_image_new_from_file(str5);
- //img2 = img;
- // mypic = gdk_pixbuf_new_from_file(str5, NULL);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img);
- GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
- pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
- gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
- windowicon = gdk_pixbuf_new_from_file(str5, NULL);
- gtk_window_set_icon(GTK_WINDOW(window), windowicon);
- gtk_widget_show(img);
- strcpy(slide, str5);
- flag3 = 1;
- break;
- }
- if (strcmp(str5, slide) == 0) flag2 = 1;
- }
- }
- if (flag3 == 1) break;
- }
- if (flag == 0) return FALSE;
- return TRUE;
- }
- void show_next2()
- {
- int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
- for (; ;)
- {
- for (i = 0; i < global; i++)
- {
- strcpy(str3, image_list[i]);
- l = 0, len = strlen(slide);
- str5[0] = 0;
- for (j = len - 1; slide[j] != '\\'; j--) k = 1;
- for (k = 0; k <= j; k++) str5[l++] = slide[k];
- str5[l] = 0, k = 0;
- strcat(str5, str3), len = strlen(str3);
- for (l = len - 4; l < len; l++) str6[k++] = str3[l];
- str6[k] = 0;
- if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
- {
- if (flag2 == 1)
- {
- gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
- gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
- grey_flag = 0, neg_flag = 0, image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
- img = gtk_image_new_from_file(str5);
- img2 = img;
- mypic = gdk_pixbuf_new_from_file(str5, NULL);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img);
- GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
- pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
- gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
- windowicon = gdk_pixbuf_new_from_file(str5, NULL);
- gtk_window_set_icon(GTK_WINDOW(window), windowicon);
- gtk_widget_show(img);
- strcpy(slide, str5);
- flag3 = 1;
- break;
- }
- if (strcmp(str5, slide) == 0) flag2 = 1;
- }
- }
- if (flag3 == 1) break;
- }
- }
- void show_previous()
- {
- int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
- for (; ;)
- {
- for (i = global - 1; i >= 0; i--)
- {
- strcpy(str3, image_list[i]);
- l = 0, len = strlen(slide);
- str5[0] = 0;
- for (j = len - 1; slide[j] != '\\'; j--) k = 1;
- for (k = 0; k <= j; k++) str5[l++] = slide[k];
- str5[l] = 0, k = 0;
- strcat(str5, str3), len = strlen(str3);
- for (l = len - 4; l < len; l++) str6[k++] = str3[l];
- str6[k] = 0;
- if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
- {
- if (flag2 == 1)
- {
- gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
- gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
- grey_flag = 0, neg_flag = 0, image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
- img = gtk_image_new_from_file(str5);
- img2 = img;
- mypic = gdk_pixbuf_new_from_file(str5, NULL);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img);
- GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
- pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
- gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
- windowicon = gdk_pixbuf_new_from_file(str5, NULL);
- gtk_window_set_icon(GTK_WINDOW(window), windowicon);
- gtk_widget_show(img);
- strcpy(slide, str5);
- flag3 = 1;
- break;
- }
- if (strcmp(str5, slide) == 0) flag2 = 1;
- }
- }
- if (flag3 == 1) break;
- }
- }
- void goto_first()
- {
- int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
- for (i = 0; i < global; i++)
- {
- strcpy(str3, image_list[i]);
- l = 0, len = strlen(slide);
- str5[0] = 0;
- for (j = len - 1; slide[j] != '\\'; j--) k = 1;
- for (k = 0; k <= j; k++) str5[l++] = slide[k];
- str5[l] = 0, k = 0;
- strcat(str5, str3), len = strlen(str3);
- for (l = len - 4; l < len; l++) str6[k++] = str3[l];
- str6[k] = 0;
- if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
- {
- gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
- gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
- grey_flag = 0, neg_flag = 0, image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
- img = gtk_image_new_from_file(str5);
- img2 = img;
- mypic = gdk_pixbuf_new_from_file(str5, NULL);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img);
- GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
- pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
- gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
- windowicon = gdk_pixbuf_new_from_file(str5, NULL);
- gtk_window_set_icon(GTK_WINDOW(window), windowicon);
- gtk_widget_show(img);
- strcpy(slide, str5);
- flag3 = 1;
- break;
- }
- }
- }
- void increase_brightness()
- {
- if (brightness_val == 1.0) brightness_val = 0.999;
- if (brightness_val <= 1.0)
- {
- brightness_val += 0.10;
- image_brightness();
- }
- }
- void decrease_brightness()
- {
- if (brightness_val == -1.0) brightness_val = -0.999;
- if(brightness_val >= -1.0)
- {
- brightness_val -= 0.10;
- image_brightness();
- }
- }
- void increase_contrast()
- {
- if (contrast_val == 1.0) contrast_val = 0.999;
- if (contrast_val <= 1.0)
- {
- contrast_val += 0.10;
- image_contrast();
- }
- }
- void decrease_contrast()
- {
- if (contrast_val == -1.0) contrast_val = -0.999;
- if(contrast_val >= -1.0)
- {
- contrast_val -= 0.10;
- image_contrast();
- }
- }
- void goto_last()
- {
- int i, j, k, l = 0, len, flag2 = 0, flag3 = 0;
- for (i = global - 1; i >= 0; i--)
- {
- strcpy(str3, image_list[i]);
- l = 0, len = strlen(slide);
- str5[0] = 0;
- for (j = len - 1; slide[j] != '\\'; j--) k = 1;
- for (k = 0; k <= j; k++) str5[l++] = slide[k];
- str5[l] = 0, k = 0;
- strcat(str5, str3), len = strlen(str3);
- for (l = len - 4; l < len; l++) str6[k++] = str3[l];
- str6[k] = 0;
- if (strcmp(str6, ".png") == 0 || strcmp(str6, ".jpg") == 0 || strcmp(str6, ".bmp") == 0)
- {
- gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
- gtk_widget_show(GTK_WIDGET(negativebutton)), gtk_widget_show(GTK_WIDGET(greyscalebutton));
- grey_flag = 0, neg_flag = 0, image_flag = 0, image_flag2 = 0, brightness_val = 0.0, contrast_val = 0.0;
- img = gtk_image_new_from_file(str5);
- img2 = img;
- mypic = gdk_pixbuf_new_from_file(str5, NULL);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img);
- GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
- pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
- gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
- windowicon = gdk_pixbuf_new_from_file(str5, NULL);
- gtk_window_set_icon(GTK_WINDOW(window), windowicon);
- gtk_widget_show(img);
- strcpy(slide, str5);
- flag3 = 1;
- break;
- }
- }
- }
- void minimize()
- {
- gtk_window_iconify(window);
- }
- void goodbye_dialog()
- {
- gbdialog = gtk_message_dialog_new (GTK_WINDOW(window), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Thank you for using this application!\nPlease click Ok to exit.");
- gtk_window_set_decorated(GTK_WINDOW(gbdialog), FALSE);
- gtk_window_set_position (GTK_WINDOW (gbdialog), GTK_WIN_POS_CENTER);
- gtk_dialog_run (GTK_DIALOG (gbdialog));
- gtk_widget_destroy (gbdialog);
- gtk_main_quit();
- }
- int main()
- {
- gtk_init(NULL, NULL);
- width = gdk_screen_width();
- height = gdk_screen_height();
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- /*gtk_window_set_skip_taskbar_hint (window, TRUE);*/
- gtk_window_set_policy(GTK_WINDOW(window), TRUE, TRUE, FALSE);
- gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER_ALWAYS);
- gtk_widget_set_size_request(GTK_WIDGET(window), width, height);
- gtk_window_set_title(GTK_WINDOW(window), "Fireflight Image Viewer 1.052");
- heightini = height;
- height = (height * 16) / 17;
- fixed_layout = gtk_fixed_new();
- char picturename[] = "C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg";
- img = gtk_image_new_from_file(picturename);
- img2 = img;
- mypic = gdk_pixbuf_new_from_file(picturename, NULL);
- windowicon = gdk_pixbuf_new_from_file(picturename, NULL);
- gtk_window_set_icon(GTK_WINDOW(window), windowicon);
- GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(img));
- pixbuf = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR);
- gtk_image_set_from_pixbuf(GTK_IMAGE(img), pixbuf);
- strcpy(slide, picturename);
- gtk_container_add(GTK_CONTAINER(fixed_layout), img);
- create_toolbar();
- gtk_container_add(GTK_CONTAINER(window), fixed_layout);
- get_list(picturename);
- store_list();
- system(str2);
- gtk_window_fullscreen(window);
- g_signal_connect(G_OBJECT(window), "delete-event",G_CALLBACK(gtk_main_quit), NULL);
- g_signal_connect(G_OBJECT(openbutton), "clicked", G_CALLBACK(open_file), NULL);
- g_signal_connect(G_OBJECT(gotofirstbutton), "clicked", G_CALLBACK(goto_first), NULL);
- g_signal_connect(G_OBJECT(gotolastbutton), "clicked", G_CALLBACK(goto_last), NULL);
- g_signal_connect(G_OBJECT(aboutbutton), "clicked", G_CALLBACK(show_about), NULL);
- g_signal_connect(G_OBJECT(closebutton), "clicked",G_CALLBACK(goodbye_dialog), NULL);
- g_signal_connect(G_OBJECT(playbutton), "clicked",G_CALLBACK(start_slide), NULL);
- g_signal_connect(G_OBJECT(stopbutton), "clicked",G_CALLBACK(stop_slide), NULL);
- g_signal_connect(G_OBJECT(nextbutton), "clicked",G_CALLBACK(show_next2), NULL);
- g_signal_connect(G_OBJECT(negativebutton), "clicked",G_CALLBACK(image_negative), NULL);
- g_signal_connect(G_OBJECT(brightnessbutton), "clicked",G_CALLBACK(increase_brightness), NULL);
- g_signal_connect(G_OBJECT(contrastbutton), "clicked",G_CALLBACK(increase_contrast), NULL);
- g_signal_connect(G_OBJECT(brightnessbutton2), "clicked",G_CALLBACK(decrease_brightness), NULL);
- g_signal_connect(G_OBJECT(contrastbutton2), "clicked",G_CALLBACK(decrease_contrast), NULL);
- g_signal_connect(G_OBJECT(restorebutton1), "clicked",G_CALLBACK(show_original1), NULL);
- g_signal_connect(G_OBJECT(restorebutton2), "clicked",G_CALLBACK(show_original2), NULL);
- g_signal_connect(G_OBJECT(greyscalebutton), "clicked",G_CALLBACK(image_greyscale), NULL);
- g_signal_connect(G_OBJECT(previousbutton), "clicked",G_CALLBACK(show_previous), NULL);
- g_signal_connect(G_OBJECT(minimizebutton), "clicked",G_CALLBACK(minimize), NULL);
- g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(keyboard_keys), (gpointer)window);
- gtk_widget_show_all(GTK_WIDGET(window));
- gtk_widget_hide(GTK_WIDGET(stopbutton)), gtk_widget_hide(GTK_WIDGET(restorebutton1)), gtk_widget_hide(GTK_WIDGET(restorebutton2));
- gtk_main();
- return 0x0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement