pixelize-1.0.0.orig/0000700000175000017500000000000011135225010012436 5ustar uweuwepixelize-1.0.0.orig/menu.h0000600000175000017500000000166211134712554013577 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* menu.h by Paul Wilkins 1/2/2000 */ #ifndef __MENU_H #define __MENU_H GtkWidget *setup_menu(GtkWidget *); extern gint delete_event(GtkWidget *, GdkEvent *, gpointer); extern void destroy(GtkWidget *, gpointer); #endif pixelize-1.0.0.orig/display.h0000600000175000017500000000160711134712554014277 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* setup_display.h by Paul Wilkins 1/2/2000 */ #ifndef __DISPLAY_H #define __DISPLAY_H #include int resize_window(); GtkWidget *setup_display(GtkWidget *); #endif pixelize-1.0.0.orig/info_popup.c0000600000175000017500000003017211134712554015002 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* info_popup.c by Paul Wilkins 1/2/2000 */ #include #include #include /* #include */ #include "globals.h" #include "read_db.h" #include "find_match.h" #include "render_image.h" #include "draw_image.h" #include "highlight.h" #include "info_popup.h" #define LIST_WIDTH 400 GtkWidget *infWindow = NULL; GtkWidget *info_list; GtkWidget *info_label; int info_x; /* the current cell */ int info_y; int ignore_selection = 0; void info_fill_list(); void clear_all_highlights(int); void set_highlight(); void set_highlight_dups(); /* pops up a new window with all the options in it */ void info_popup(int x, int y){ char buf[64]; GtkWidget *vbox; GtkWidget *table; GtkWidget *scrolled_window; GtkWidget *button; GtkWidget *radio; void info_prevCB(GtkWidget *, gpointer); void info_nextCB(GtkWidget *, gpointer); void info_highlightCB(GtkWidget *, gpointer); void info_highlight_dupsCB(GtkWidget *, gpointer); void info_selectionCB(GtkWidget *, gint, gint, GdkEventButton *, gpointer); if (!infWindow) { infWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(infWindow), "Image Information"); gtk_signal_connect(GTK_OBJECT(infWindow), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &infWindow); gtk_container_set_border_width(GTK_CONTAINER(infWindow), 4); /* all the sections go in the vbox */ vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(infWindow), vbox); gtk_widget_show(vbox); /***** image location label *******************************************************/ info_label = gtk_label_new(""); gtk_box_pack_start(GTK_BOX(vbox), info_label, FALSE, FALSE, 0); gtk_widget_show(info_label); /***** list box with scrolled window *******************************************************/ /* This is the scrolled window to put the GtkList widget inside */ scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_set_usize(scrolled_window, LIST_WIDTH, 250); gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0); gtk_widget_show(scrolled_window); info_list = gtk_clist_new(1); GTK_WIDGET_SET_FLAGS(info_list, GTK_CAN_DEFAULT); gtk_signal_connect(GTK_OBJECT(info_list), "select_row", GTK_SIGNAL_FUNC(info_selectionCB), NULL); gtk_clist_set_column_width(GTK_CLIST(info_list), 0, LIST_WIDTH); gtk_clist_set_selection_mode(GTK_CLIST(info_list), /* GTK_SELECTION_BROWSE */ GTK_SELECTION_EXTENDED ); gtk_container_add(GTK_CONTAINER(scrolled_window), info_list); /* gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(scrolled_window), info_list); */ gtk_widget_show(info_list); /***** next and previous buttons *******************************************************/ table = gtk_table_new(1, 2, TRUE); gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); gtk_widget_show(table); button = gtk_button_new_with_label("Previous"); GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(info_prevCB), NULL); gtk_table_attach(GTK_TABLE(table), button, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show(button); button = gtk_button_new_with_label("Next"); GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(info_nextCB), NULL); gtk_table_attach(GTK_TABLE(table), button, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0); gtk_widget_show(button); /***** highlight radio buttons *******************************************************/ radio = gtk_check_button_new_with_label("Highlight Image"); GTK_WIDGET_UNSET_FLAGS(radio, GTK_CAN_FOCUS); gtk_box_pack_start(GTK_BOX(vbox), radio, FALSE, FALSE, 0); gtk_signal_connect(GTK_OBJECT(radio), "toggled", GTK_SIGNAL_FUNC(info_highlightCB), NULL); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(radio), (globals.do_highlight&DO_HIGHLIGHT) ? TRUE : FALSE); gtk_widget_show(radio); radio = gtk_check_button_new_with_label("Highlight Duplicates"); GTK_WIDGET_UNSET_FLAGS(radio, GTK_CAN_FOCUS); gtk_box_pack_start(GTK_BOX(vbox), radio, FALSE, FALSE, 0); gtk_signal_connect(GTK_OBJECT(radio), "toggled", GTK_SIGNAL_FUNC(info_highlight_dupsCB), NULL); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(radio), (globals.do_highlight&DO_HIGHLIGHT_DUPS) ? TRUE : FALSE); gtk_widget_show(radio); /************************************************************/ button = gtk_button_new_with_label("Dismiss"); GTK_WIDGET_UNSET_FLAGS(button, GTK_CAN_FOCUS); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), GTK_OBJECT(infWindow)); gtk_box_pack_end(GTK_BOX(vbox), button, FALSE, FALSE, 0); gtk_widget_show(button); } /* save the x and y coords */ info_x = x; info_y = y; /* set the coord label */ sprintf(buf, "Image coordinates: %dx%d", info_x, info_y); gtk_label_set(GTK_LABEL(info_label), buf); /* clear and optionalls reset the highlites */ clear_all_highlights(1); if(globals.do_highlight & DO_HIGHLIGHT){ set_highlight(); } if(globals.do_highlight & DO_HIGHLIGHT_DUPS){ set_highlight_dups(); } highlight_changed(); /* fill the list box */ info_fill_list(); if(!GTK_WIDGET_VISIBLE(infWindow)) { gtk_widget_show(infWindow); } } void info_fill_list(){ int i; char *ary[1]; struct PIC_DB *db; struct IMAGE_INFO *inf; ignore_selection = 1; inf = &(globals.image[info_y][info_x]); /* don't allow the widget to update */ gtk_clist_freeze(GTK_CLIST(info_list)); /* set the list entries */ gtk_clist_clear(GTK_CLIST(info_list)); for(i=0; imatches[i]; ary[0] = db->fname; gtk_clist_append(GTK_CLIST(info_list), ary); } /* select the current image in the list */ gtk_clist_select_row(GTK_CLIST(info_list), inf->match_no, 0); /* possibly scroll the list */ if(GTK_VISIBILITY_FULL != gtk_clist_row_is_visible(GTK_CLIST(info_list), inf->match_no)){ gtk_clist_moveto(GTK_CLIST(info_list), inf->match_no, -1, 0.5, 0.0); } /* allow the widget to update */ gtk_clist_thaw(GTK_CLIST(info_list)); ignore_selection = 0; } void info_selectionCB( GtkWidget *clist, gint row, gint col, GdkEventButton *event, gpointer data ){ struct IMAGE_INFO *inf; if(ignore_selection) return; inf = &(globals.image[info_y][info_x]); /* if it is the current image */ if(inf->match_no == row) return; /* store the new row */ inf->match_no = row; /* finally, draw the new image */ change_small_image(info_x, info_y); /* clear and optionalls reset the highlites */ clear_all_highlights(0); if(globals.do_highlight & DO_HIGHLIGHT){ set_highlight(); } if(globals.do_highlight & DO_HIGHLIGHT_DUPS){ set_highlight_dups(); } highlight_changed(); } void info_prevCB(GtkWidget *widget, gpointer data){ info_prev(); } void info_nextCB(GtkWidget *widget, gpointer data){ info_next(); } void info_highlightCB(GtkWidget *widget, gpointer data){ struct IMAGE_INFO *inf; if(TRUE == GTK_TOGGLE_BUTTON(widget)->active){ globals.do_highlight |= DO_HIGHLIGHT; } else { globals.do_highlight &= ~DO_HIGHLIGHT; } inf = &(globals.image[info_y][info_x]); if(globals.do_highlight & DO_HIGHLIGHT){ inf->do_highlight = 1; } else { inf->do_highlight = 0; } highlight_changed(); if(globals.do_highlight) start_highlight_timer(); else stop_highlight_timer(); } void info_highlight_dupsCB(GtkWidget *widget, gpointer data){ if(TRUE == GTK_TOGGLE_BUTTON(widget)->active){ globals.do_highlight |= DO_HIGHLIGHT_DUPS; } else { globals.do_highlight &= ~DO_HIGHLIGHT_DUPS; } if(globals.do_highlight & DO_HIGHLIGHT_DUPS){ set_highlight_dups(); } else { clear_all_highlights(0); } highlight_changed(); if(globals.do_highlight) start_highlight_timer(); else stop_highlight_timer(); } void info_prev(){ struct IMAGE_INFO *inf; inf = &(globals.image[info_y][info_x]); /* unselect the current image in the list */ gtk_clist_unselect_row(GTK_CLIST(info_list), inf->match_no, 0); /* the previous item in the list */ inf->match_no--; if(inf->match_no < 0) inf->match_no = MAX_MATCHES-1; ignore_selection = 1; /* select the current image in the list */ gtk_clist_select_row(GTK_CLIST(info_list), inf->match_no, 0); /* possibly scroll the list */ if(GTK_VISIBILITY_FULL != gtk_clist_row_is_visible(GTK_CLIST(info_list), inf->match_no)){ gtk_clist_moveto(GTK_CLIST(info_list), inf->match_no, -1, 0.0, 0.0); } ignore_selection = 0; /* finally, draw the new image */ change_small_image(info_x, info_y); /* clear and optionalls reset the highlites */ clear_all_highlights(0); if(globals.do_highlight & DO_HIGHLIGHT){ set_highlight(); } if(globals.do_highlight & DO_HIGHLIGHT_DUPS){ set_highlight_dups(); } highlight_changed(); } void info_next(){ struct IMAGE_INFO *inf; inf = &(globals.image[info_y][info_x]); /* unselect the current image in the list */ gtk_clist_unselect_row(GTK_CLIST(info_list), inf->match_no, 0); /* the next item in the list */ inf->match_no++; if(inf->match_no >= MAX_MATCHES) inf->match_no = 0; ignore_selection = 1; /* select the current image in the list */ gtk_clist_select_row(GTK_CLIST(info_list), inf->match_no, 0); /* possibly scroll the list */ if(GTK_VISIBILITY_FULL != gtk_clist_row_is_visible(GTK_CLIST(info_list), inf->match_no)){ gtk_clist_moveto(GTK_CLIST(info_list), inf->match_no, -1, 1.0, 0.0); } ignore_selection = 0; /* finally, draw the new image */ change_small_image(info_x, info_y); /* clear and optionalls reset the highlites */ clear_all_highlights(0); if(globals.do_highlight & DO_HIGHLIGHT){ set_highlight(); } if(globals.do_highlight & DO_HIGHLIGHT_DUPS){ set_highlight_dups(); } highlight_changed(); } void set_highlight(){ struct IMAGE_INFO *inf; inf = &(globals.image[info_y][info_x]); if(globals.do_highlight & DO_HIGHLIGHT){ inf->do_highlight = 1; } } void set_highlight_dups(){ int x, y; struct PIC_DB *db, *db2; struct IMAGE_INFO *inf, *inf2; /* find duplicates and mark them */ inf = &(globals.image[info_y][info_x]); db = inf->matches[inf->match_no]; for(y=0; ymatches[inf2->match_no]; if(db == db2) inf2->do_highlight = 1; } } } void clear_all_highlights(int clear_current){ int x, y; struct IMAGE_INFO *inf; /* clear everyone */ for(y=0; ydo_highlight = 0; } } } pixelize-1.0.0.orig/setup_menu.c0000600000175000017500000001375411134712555015020 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* setup_menu.c by Paul Wilkins 1/2/2000 */ #include #include #ifdef USE_GNOME #include #endif #include /* #include */ #include "globals.h" #include "menu.h" #include "options.h" extern void quitCB(gpointer); extern void openCB(gpointer); extern void saveCB(gpointer); extern void renderCB(gpointer); extern void optionsCB(gpointer); extern void licenseCB(gpointer); extern void helpCB(gpointer); #ifdef USE_GNOME GnomeUIInfo filemenu[] = { {GNOME_APP_UI_ITEM, "Open Image", "Open an image to render to", openCB, NULL, NULL, GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL}, {GNOME_APP_UI_ITEM, "Save Image", "Save the rendered image", saveCB, NULL, NULL, GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL}, GNOMEUIINFO_MENU_EXIT_ITEM(quitCB, NULL), GNOMEUIINFO_END }; GnomeUIInfo optmenu[] = { {GNOME_APP_UI_ITEM, "Render", "Render the image", renderCB, NULL, NULL, GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL}, {GNOME_APP_UI_ITEM, "Options", "Options", optionsCB, NULL, NULL, GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL}, GNOMEUIINFO_END }; GnomeUIInfo helpmenu[] = { {GNOME_APP_UI_ITEM, "License", "License", licenseCB, NULL, NULL, GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL}, GNOMEUIINFO_HELP("grpn"), GNOMEUIINFO_END }; GnomeUIInfo mainmenu[] = { GNOMEUIINFO_MENU_FILE_TREE(filemenu), GNOMEUIINFO_MENU_HELP_TREE(optmenu), GNOMEUIINFO_MENU_HELP_TREE(helpmenu), GNOMEUIINFO_END }; /* create the menubar */ GtkWidget *setup_menu(GtkWidget *parent) { gnome_app_create_menus(GNOME_APP(parent), mainmenu); return NULL; } #else /* not USE_GNOME */ /* create the menubar */ GtkWidget *setup_menu(GtkWidget *parent) { GtkWidget *menu_bar; GtkWidget *fileM, *fileI; GtkWidget *openI; GtkWidget *saveI; GtkWidget *sepI; GtkWidget *quitI; GtkWidget *optM, *optI; GtkWidget *renderI; GtkWidget *optionsI; GtkWidget *helpM, *helpI; GtkWidget *hlpI; GtkWidget *licenseI; /********************************************************/ /* File */ fileM = gtk_menu_new(); /* Remember: don't gtk_widget_show the menu */ /* Open */ openI = gtk_menu_item_new_with_label("Open"); gtk_menu_append(GTK_MENU(fileM), openI); gtk_widget_show(openI); gtk_signal_connect_object(GTK_OBJECT(openI), "activate", GTK_SIGNAL_FUNC(openCB), NULL); /* Save */ saveI = gtk_menu_item_new_with_label("Save"); gtk_menu_append(GTK_MENU(fileM), saveI); gtk_widget_show(saveI); gtk_signal_connect_object(GTK_OBJECT(saveI), "activate", GTK_SIGNAL_FUNC(saveCB), NULL); /* separator */ sepI = gtk_menu_item_new(); gtk_menu_append(GTK_MENU(fileM), sepI); gtk_widget_show(sepI); /* Quit */ quitI = gtk_menu_item_new_with_label("Quit"); gtk_menu_append(GTK_MENU(fileM), quitI); gtk_widget_show(quitI); gtk_signal_connect_object(GTK_OBJECT(quitI), "activate", GTK_SIGNAL_FUNC(quitCB), NULL); /********************************************************/ /* Options */ optM = gtk_menu_new(); /* Remember: don't gtk_widget_show the menu */ /* render */ renderI = gtk_menu_item_new_with_label("Render"); gtk_menu_append(GTK_MENU(optM), renderI); gtk_widget_show(renderI); gtk_signal_connect_object(GTK_OBJECT(renderI), "activate", GTK_SIGNAL_FUNC(renderCB), NULL); /* Options */ optionsI = gtk_menu_item_new_with_label("Options"); gtk_menu_append(GTK_MENU(optM), optionsI); gtk_widget_show(optionsI); gtk_signal_connect_object(GTK_OBJECT(optionsI), "activate", GTK_SIGNAL_FUNC(optionsCB), NULL); /********************************************************/ /* create the "Help" pulldown menu */ helpM = gtk_menu_new(); /* Help */ hlpI = gtk_menu_item_new_with_label("Help"); gtk_menu_append(GTK_MENU(helpM), hlpI); gtk_widget_show(hlpI); gtk_signal_connect_object(GTK_OBJECT(hlpI), "activate", GTK_SIGNAL_FUNC(helpCB), NULL); /* Help */ licenseI = gtk_menu_item_new_with_label("License"); gtk_menu_append(GTK_MENU(helpM), licenseI); gtk_widget_show(licenseI); gtk_signal_connect_object(GTK_OBJECT(licenseI), "activate", GTK_SIGNAL_FUNC(licenseCB), NULL); /********************************************************/ /* tell the menubar who is the heplp widget */ menu_bar = gtk_menu_bar_new(); gtk_box_pack_start(GTK_BOX(parent), menu_bar, FALSE, FALSE, 0); gtk_widget_show(menu_bar); fileI = gtk_menu_item_new_with_label("File"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(fileI), fileM); gtk_menu_bar_append(GTK_MENU_BAR(menu_bar), fileI); gtk_widget_show(fileI); optI = gtk_menu_item_new_with_label("Options"); gtk_menu_item_set_submenu(GTK_MENU_ITEM(optI), optM); gtk_menu_bar_append(GTK_MENU_BAR(menu_bar), optI); gtk_widget_show(optI); helpI = gtk_menu_item_new_with_label("Help"); gtk_menu_item_right_justify(GTK_MENU_ITEM(helpI)); gtk_menu_item_set_submenu(GTK_MENU_ITEM(helpI), helpM); gtk_menu_bar_append(GTK_MENU_BAR(menu_bar), helpI); gtk_widget_show(helpI); return menu_bar; } #endif /* USE_GNOME */ pixelize-1.0.0.orig/main.c0000600000175000017500000000636711134713721013556 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* main.c by Paul Wilkins 1/2/2000 */ /* main.c by Paul Wilkins. * This file contains the main program. */ #include #include #ifdef USE_GNOME #include #endif #include #include "globals.h" #include "icon_bitmap" #include "display.h" #include "status.h" #include "menu.h" #include "cursor.h" void usage(char *str){ fprintf(stderr, "Error: %s\n", str); fprintf(stderr, "Usage: pixelize\n"); } int main(int argc, char *argv[]) { GtkWidget *main_w; GtkWidget *vbox; GtkWidget *menu; GdkBitmap *icon_bitmap; #ifdef USE_GNOME GnomeAppBar *appbar; #endif #ifdef USE_GNOME gnome_init("pixelize", "1.0", argc, argv); gnome_app_new("pixelize", "pixelize"); #else /* initialize gtk */ gtk_init(&argc, &argv); #endif if(argc > 2){ usage("Unknown Argument."); exit(1); } init_globals(); if(argc == 2){ globals.start_fname = argv[1]; } #ifdef USE_GNOME main_w = gnome_app_new("pixelize", "pixelize"); globals.topwin = main_w; setup_menu(main_w); appbar = GNOME_APPBAR(gnome_appbar_new(FALSE, FALSE, FALSE)); gnome_app_set_statusbar(GNOME_APP(main_w), GTK_WIDGET(appbar)); /*create the box that everyone goes in */ vbox = gtk_vbox_new(FALSE, 0); gnome_app_set_contents(GNOME_APP(main_w), vbox); gtk_widget_show(vbox); #else /* the main window contains the work area and the menubar */ main_w = gtk_window_new(GTK_WINDOW_TOPLEVEL); globals.topwin = main_w; gtk_widget_set_name(main_w, "pixelize"); /*create the box that everyone goes in */ vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(main_w), vbox); gtk_widget_show(vbox); /* set up the menu bar */ menu = setup_menu(vbox); #endif /* handle window manager close */ gtk_signal_connect(GTK_OBJECT(main_w), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL); gtk_signal_connect(GTK_OBJECT(main_w), "destroy", GTK_SIGNAL_FUNC(destroy), NULL); /* create the varrious subsystems */ setup_display(vbox); setup_status(vbox); gtk_widget_show(main_w); gdk_window_move(GTK_WIDGET(main_w)->window, 100, 100); gdk_window_set_hints(GTK_WIDGET(main_w)->window, 100, 100, 300, 300, 0, 0, GDK_HINT_POS|GDK_HINT_MIN_SIZE); /* Create pixmap of depth 1 (bitmap) for icon */ icon_bitmap = gdk_bitmap_create_from_data(main_w->window, icon_bitmap_bits, icon_bitmap_width, icon_bitmap_height); gdk_window_set_icon(main_w->window, NULL, icon_bitmap, NULL); cursor_normal(); gtk_main(); return 0; } pixelize-1.0.0.orig/render.h0000600000175000017500000000151711134712555014112 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* render.h by Paul Wilkins 1/2/2000 */ #ifndef __RENDER_H #define __RENDER_H int render(); void free_image_data(); #endif pixelize-1.0.0.orig/help.h0000600000175000017500000000151611134712554013561 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* help.h by Paul Wilkins 1/2/2000 */ #ifndef __HELP_H #define __HELP_H void help_popup(); void license_popup(); #endif pixelize-1.0.0.orig/highlight.c0000600000175000017500000000505311134712554014573 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* highlight.c by Paul Wilkins 1/2/2000 */ #include #include /* #include */ /* #include */ #include "globals.h" #include "draw_image.h" #include "render_image.h" #include "highlight.h" int timeout_exists = 0; int highlight_timeout(gpointer data){ static int state = 0; int xx, yy; GdkGC *gc; struct IMAGE_INFO *inf; if(globals.do_highlight == 0) return TRUE; /* search for the images to highlight and draw the highlight here */ for(yy=0; yydo_highlight){ if(state == 1){ gc = GTK_WIDGET(globals.picDA)->style->white_gc; } else { gc = GTK_WIDGET(globals.picDA)->style->black_gc; } gdk_draw_rectangle(GTK_WIDGET(globals.picDA)->window, gc, FALSE, xx*globals.cur_opt.pixW, yy*globals.cur_opt.pixH, globals.cur_opt.pixW-1, globals.cur_opt.pixH-1); } } } state = !state; /* make sure our drawing happens now */ gdk_flush(); return TRUE; } int highlight_changed(){ /* redraw the screen */ redraw_screen(0, 0, globals.cur_opt.width, globals.cur_opt.height); /* redraw the highlights */ highlight_timeout(NULL); return 1; } int start_highlight_timer(){ /* start a timer if one does not already exist */ if(!timeout_exists){ globals.timer = gtk_timeout_add(200, highlight_timeout, NULL); timeout_exists = 1; } return 1; } int stop_highlight_timer(){ if(timeout_exists){ gtk_timeout_remove(globals.timer); timeout_exists = 0; } /* redraw the screen */ redraw_screen(0, 0, globals.cur_opt.width, globals.cur_opt.height); return 1; } pixelize-1.0.0.orig/file_dialog.c0000600000175000017500000001552211134755606015071 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* file_dialog.c by Paul Wilkins 1/2/2000 */ #include #include #include #include #include #include #include /* #include */ #include "globals.h" #include "options.h" #include "render.h" #include "display.h" #include "cursor.h" #include "draw_image.h" #include "file_dialog.h" /* 1 == regular * 0 == not regular * -1 == does not exist */ int file_type(const char *fname){ struct stat statb; /* get the file's size */ if(stat(fname, &statb) == -1){ // perror("stat"); return -1; } if(S_ISREG(statb.st_mode)){ return 1; } return 0; } int check_valid_types(char *type){ GdkPixbufFormat *pixbuf_format; gchar *fmtname; GSList *formats, *l; formats = gdk_pixbuf_get_formats(); for (l = formats; l; l = g_slist_next(l)) { pixbuf_format = (GdkPixbufFormat*)l->data; fmtname = gdk_pixbuf_format_get_name(pixbuf_format); if(type) { if(0 == strcmp(type, fmtname)) return 1; } else { printf("%s\n", fmtname); } } g_slist_free(formats); return 0; } char *get_extension(const char *fname){ char *p1 = strrchr(fname, '.'); if(p1 == NULL) { fprintf(stderr, "Error: Can not find file extension\n"); return NULL; } return p1+1; } int save_image(const char *fname){ char *extension; GError *error; if(fname == NULL || *fname == '\0' || 0==file_type(fname)){ fprintf(stderr, "Error: Invalid file name.\n"); return 0; } if(globals.out_im == NULL){ fprintf(stderr, "Error: render an image first.\n"); return 0; } extension = get_extension(fname); if(0 == check_valid_types(extension)){ fprintf(stderr, "Error: Can not determine file type from extension\n"); fprintf(stderr, "Valid extension types are:\n"); check_valid_types(NULL); return(0); } error = NULL; if(1 != gdk_pixbuf_save(globals.out_im, fname, extension, &error, NULL)){ fprintf(stderr, "Error: Can't write %s: %s\n", fname, error->message); return(0); } return 1; } int open_image(const char *fname){ GdkPixbuf *im; GError *gerror; if(fname == NULL || *fname == '\0' || 1!=file_type(fname)){ fprintf(stderr, "Error: Invalid file name.\n"); return 0; } /* free old data */ if(globals.in_im != NULL) g_object_unref(globals.in_im); if(globals.in_im_scaled != NULL) g_object_unref(globals.in_im_scaled); globals.in_im = NULL; globals.in_im_scaled = NULL; free_image_data(); /* Load the image specified as the first argument */ gerror = NULL; if(NULL == (im = gdk_pixbuf_new_from_file(fname, &gerror))){ fprintf(stderr, "Error: Can't load image %s: %s\n", fname, gerror->message); return 0; } /* add an alpha channel */ globals.in_im = gdk_pixbuf_add_alpha(im, 0, 0, 0, 0); g_object_unref(im); if(NULL == (globals.in_fname=malloc(strlen(fname)+1))){ perror("malloc"); exit(1); } strcpy(globals.in_fname, fname); if(0 == calc_dimensions(&(globals.new_opt))){ fprintf(stderr, "Invalid option value.\n"); } copy_opt_data(); refresh_options_win(&(globals.new_opt)); /* scale the image */ if(NULL == (globals.in_im_scaled=gdk_pixbuf_scale_simple( globals.in_im, globals.cur_opt.pixW * globals.cur_opt.nPixW, globals.cur_opt.pixH * globals.cur_opt.nPixH, GDK_INTERP_BILINEAR ))){ fprintf(stderr, "Error: Unable to scale image: %s\n", fname); return 0; } resize_window(); return 1; } /* save the rendered image */ void filesel_save(GtkWidget *w, GtkFileSelection *fs) { cursor_busy(); if(1 == save_image(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs)))){ gtk_widget_hide(GTK_WIDGET(GTK_FILE_SELECTION(fs))); } cursor_normal(); } /* open an image */ void filesel_open(GtkWidget *w, GtkFileSelection *fs) { cursor_busy(); if(1 == open_image(gtk_file_selection_get_filename(GTK_FILE_SELECTION(fs)))){ gtk_widget_hide(GTK_WIDGET(GTK_FILE_SELECTION(fs))); } cursor_normal(); } int file_open_dialog(char *fname){ static GtkWidget *dialog = NULL; if(dialog == NULL){ /* Create a new file selection widget */ dialog = gtk_file_selection_new("Open Image"); gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(dialog)); gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dialog)), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog); /* Connect the ok_button to file_ok_sel function */ gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button), "clicked", (GtkSignalFunc)filesel_open, dialog); /* Connect the cancel_button to destroy the widget */ gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(dialog)->cancel_button), "clicked", (GtkSignalFunc)gtk_widget_hide, GTK_OBJECT(dialog)); } if(fname != NULL){ gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog), fname); } if(!GTK_WIDGET_VISIBLE(dialog)){ gtk_widget_show(dialog); } return 0; } int file_save_dialog(char *fname){ static GtkWidget *dialog = NULL; if(dialog == NULL){ /* Create a new file selection widget */ dialog = gtk_file_selection_new("Save Image"); gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(dialog)); gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dialog)), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog); /* Connect the ok_button to file_ok_sel function */ gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dialog)->ok_button), "clicked", (GtkSignalFunc)filesel_save, dialog); /* Connect the cancel_button to destroy the widget */ gtk_signal_connect_object(GTK_OBJECT(GTK_FILE_SELECTION(dialog)->cancel_button), "clicked", (GtkSignalFunc)gtk_widget_hide, GTK_OBJECT(dialog)); } if(fname != NULL){ gtk_file_selection_set_filename(GTK_FILE_SELECTION(dialog), fname); } if(!GTK_WIDGET_VISIBLE(dialog)){ gtk_widget_show(dialog); } return 0; } pixelize-1.0.0.orig/cursor.h0000600000175000017500000000152211134712554014143 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* cursor.h by Paul Wilkins 1/2/2000 */ #ifndef __CURSOR_H #define __CURSOR_H void cursor_busy(); void cursor_normal(); #endif pixelize-1.0.0.orig/status.h0000600000175000017500000000201411134712555014147 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* status.h by Paul Wilkins 1/2/2000 */ #ifndef __STATUS_H #define __STATUS_H #define ST_PERCENT 0x1 #define ST_READY 0x2 #define ST_PROGRESS 0x4 void toggle_progress_indicator(int onoff); void set_progress_indicator(double val); void refresh_mode_display(); GtkWidget *setup_status(GtkWidget *parent); #endif pixelize-1.0.0.orig/TODO0000600000175000017500000000155311134715066013152 0ustar uweuweTODO list from Pixelize 1.0.0 - Option to toggle between the origional and rendered image. - Option to tag good images and scroll between them - make_db meeds to know about your X display. This is stupid since make_db never opens any windows. This is an issue with imlib. - Add an option to make_db to update the pic_db.dat file by somehow checking if files have been added, removed or changed, and then changing pic_db.dat as required. - Make all of the error and warning messages that Pixelize currently prints to the console, come up in a popup window. - Hourglass - Done v0.9.0 - Make Pixelize deal with aspect ratios correctly. I think this will be really hard, since the current way of storing the info in pic_db.dat knows nothing about aspect ratio. - Write man pages. - Add a percent done thingy to Pixelize when reading pic_db.dat. pixelize-1.0.0.orig/stats.h0000600000175000017500000000155211134712555013770 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* stats.h by Paul Wilkins 1/2/2000 */ #ifndef __STATS_H #define __STATS_H int calc_mead_std(double *data, int n, double *mean, double *std); #endif pixelize-1.0.0.orig/file_dialog.h0000600000175000017500000000164111134714373015067 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* file_dialog by Paul Wilkins 1/2/2000 */ #ifndef __FILE_DIALOG_H #define __FILE_DIALOG_H int file_open_dialog(char *fname); int file_save_dialog(char *fname); int open_image(const char *fname); #endif pixelize-1.0.0.orig/make_db_imlib2.c0000600000175000017500000001434711134712554015452 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* make_db.c by Paul Wilkins 1/2/2000 */ #include #include #include #include #include #include #include struct PIX { int cnt; double r; double g; double b; }; #define MAX_SIZE 5 #define MAX_PATH_LEN 512 int main(int argc, char **argv) { int write_db = 1; int i, j, n; int size; Display *disp; Imlib_Image *im; int qh, qw; int width, height; int ww, hh; DATA32 pixel; DATA32 *p1; struct PIX ***quad; char my_cwd[MAX_PATH_LEN+1]; FILE *dbfp; /* Be nice and tell the user if they don't, to provide a file as an arg */ if (argc <= 1) { fprintf(stderr, "make_db is a program that scanns pictures and creates a file\n"); fprintf(stderr, "called pic_db.dat. The file pic_db.dat is used by Pixelize\n"); fprintf(stderr, "when \"rendering\" images.\n"); fprintf(stderr, "\n"); fprintf(stderr, "Usage:\n %s image_files\n", argv[0]); exit(1); } if(NULL == (quad=malloc((MAX_SIZE+1)*sizeof(struct PIX *)))){ perror("malloc"); exit(1); } for(i=1; i<=MAX_SIZE; i++){ if(NULL == (quad[i]=malloc((MAX_SIZE+1)*sizeof(struct PIX *)))){ perror("malloc"); exit(1); } for(j=0; j<=MAX_SIZE; j++){ if(NULL == (quad[i][j]=malloc((MAX_SIZE+1)*sizeof(struct PIX)))){ perror("malloc"); exit(1); } } } /* Connect to the default Xserver */ disp = XOpenDisplay(NULL); /* Immediately afterwards Intitialise Imlib */ /* id = Imlib_init(disp); */ imlib_set_color_usage(128); imlib_context_set_dither(1); imlib_context_set_display(disp); imlib_context_set_visual(DefaultVisual(disp, DefaultScreen(disp))); imlib_context_set_colormap(DefaultColormap(disp, DefaultScreen(disp))); if(write_db){ if(NULL == (dbfp=fopen("pic_db.dat", "a+"))){ printf("Error opening pic_db.dat for write\n"); exit(1); } fprintf(dbfp, "%d\n", MAX_SIZE); } /* get the cwd. we may use it later */ if(NULL == (getcwd(my_cwd, MAX_PATH_LEN))){ fprintf(stderr, "Warning: Can't determine Current working directory.\n"); fprintf(stderr, " This may generate an invalid pic_db.dat file.\n"); my_cwd[0] = '\0'; } /* for each file */ for(n=1; n= size) qh = size - 1; for(ww=0; ww= size) qw = size - 1; pixel = *p1; quad[size][qw][qh].cnt++; quad[size][qw][qh].r += (double)((pixel>>16)&0xff); quad[size][qw][qh].g += (double)((pixel>> 8)&0xff); quad[size][qw][qh].b += (double)((pixel )&0xff); p1++; } } } /* special case for size = 2 */ for(hh=0; hh<2; hh++){ for(ww=0; ww<2; ww++){ for(i=0; i<2; i++){ for(j=0; j<2; j++){ quad[2][ww][hh].cnt += quad[4][ww*2+i][hh*2+j].cnt; quad[2][ww][hh].r += quad[4][ww*2+i][hh*2+j].r; quad[2][ww][hh].g += quad[4][ww*2+i][hh*2+j].g; quad[2][ww][hh].b += quad[4][ww*2+i][hh*2+j].b; } } } } /* special case for size = 1 */ for(i=0; i<2; i++){ for(j=0; j<2; j++){ quad[1][0][0].cnt += quad[2][i][j].cnt; quad[1][0][0].r += quad[2][i][j].r; quad[1][0][0].g += quad[2][i][j].g; quad[1][0][0].b += quad[2][i][j].b; } } for(size=1; size<=MAX_SIZE; size++){ if(write_db){ for(hh=0; hh Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. pixelize-1.0.0.orig/globals.h0000600000175000017500000000376511134754747014276 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* globals.h by Paul Wilkins 1/2/2000 */ #ifndef __GLOBALS_H #define __GLOBALS_H #define PIX_SIZE 0x1 #define PIX_COUNT 0x2 struct IMAGE_OPTIONS { int width, height; /* width and height od final image */ int pixW, pixH; /* size to scale small images to */ int nPixW, nPixH; int proximity; int opt_alg; }; /* globals we use alot */ struct GLOBALS { GtkWidget *topwin; /* the main window */ GtkWidget *ebox; /* an event box around the scrolled window */ GtkWidget *picScroll; /* drawing area scrollbar widget */ GtkWidget *picDA; /* drawing area widget */ GdkPixmap *pixmap; /* pixmap of the image */ struct PIC_DB *head; /* the image database */ struct IMAGE_INFO **image; /* the constructed image */ int max_order; /* maximum order when fitting images */ struct IMAGE_OPTIONS cur_opt; struct IMAGE_OPTIONS new_opt; int timer; int do_highlight; char *start_fname; int show_rendered; int disp_w, disp_h; /* size of display */ char *in_fname; /* input file */ GdkPixbuf *in_im_scaled; GdkPixbuf *in_im; char *out_fname; /* output file */ GdkPixbuf *out_im; }; extern struct GLOBALS globals; int init_globals(); #endif pixelize-1.0.0.orig/highlight.h0000600000175000017500000000174311134712554014602 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* highlight.h by Paul Wilkins 1/2/2000 */ #ifndef __HIGHLIGHT_H #define __HIGHLIGHT_H #define DO_HIGHLIGHT 0x1 #define DO_HIGHLIGHT_DUPS 0x2 int highlight_timeout(gpointer data); int start_highlight_timer(); int stop_highlight_timer(); int highlight_changed(); #endif pixelize-1.0.0.orig/options.c0000600000175000017500000002612011134761562014320 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* options.c by Paul Wilkins 1/2/2000 */ #include #include #include /* #include */ #include "globals.h" #include "draw_image.h" #include "options.h" GtkWidget *optWindow = NULL; GtkWidget *size_x_entry; GtkWidget *size_y_entry; GtkWidget *count_x_entry; GtkWidget *count_y_entry; GtkWidget *size_button; GtkWidget *count_button; /* pops up a new window with all the options in it */ void optionsCB(gpointer data){ char buf[8]; GSList *group; GtkWidget *button; GtkWidget *frame; GtkWidget *hbox; GtkWidget *vbox; GtkWidget *vbox2; GtkWidget *label; GtkWidget *entry; void pix_opt_alg_CB(GtkWidget *, gpointer); void pix_size_x_CB(GtkWidget *, GtkWidget *); void pix_size_y_CB(GtkWidget *, GtkWidget *); void pix_count_x_CB(GtkWidget *, GtkWidget *); void pix_count_y_CB(GtkWidget *, GtkWidget *); void pix_proximity_CB(GtkWidget *, GtkWidget *); void apply_CB(GtkWidget *, GtkWidget *); if (!optWindow) { optWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (optWindow), "Options"); gtk_signal_connect(GTK_OBJECT(optWindow), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &optWindow); gtk_container_set_border_width(GTK_CONTAINER(optWindow), 4); /* all the sections go in the vbox */ vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(optWindow), vbox); gtk_widget_show(vbox); /***** IMAGES *******************************************************/ frame = gtk_frame_new("Images"); gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); gtk_container_set_border_width(GTK_CONTAINER(frame), 4); gtk_widget_show(frame); vbox2 = gtk_vbox_new(FALSE, 4); gtk_container_set_border_width(GTK_CONTAINER(vbox2), 4); gtk_container_add(GTK_CONTAINER(frame), vbox2); gtk_widget_show(vbox2); /***** size *****/ hbox = gtk_hbox_new(FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); size_button = button = gtk_radio_button_new_with_label(NULL, ""); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_signal_connect(GTK_OBJECT(button), "toggled", GTK_SIGNAL_FUNC(pix_opt_alg_CB), (gpointer)PIX_SIZE); gtk_widget_show(button); label = gtk_label_new("Image Sizes: "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); size_x_entry = entry = gtk_entry_new_with_max_length(5); gtk_widget_set_usize(entry, 50, -1); gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(pix_size_x_CB), entry); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); gtk_widget_show(entry); label = gtk_label_new("X"); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); size_y_entry = entry = gtk_entry_new_with_max_length(5); gtk_widget_set_usize(entry, 50, -1); gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(pix_size_y_CB), entry); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); gtk_widget_show(entry); label = gtk_label_new(" Pixels "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); /***** number *****/ hbox = gtk_hbox_new(FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); group = gtk_radio_button_group(GTK_RADIO_BUTTON(button)); count_button = button = gtk_radio_button_new_with_label(group, ""); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_signal_connect(GTK_OBJECT(button), "toggled", GTK_SIGNAL_FUNC(pix_opt_alg_CB), (gpointer)PIX_COUNT); gtk_widget_show(button); label = gtk_label_new("Number of Images: "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); count_x_entry = entry = gtk_entry_new_with_max_length(5); gtk_widget_set_usize(entry, 50, -1); gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(pix_count_x_CB), entry); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); gtk_widget_show(entry); label = gtk_label_new("X"); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); count_y_entry = entry = gtk_entry_new_with_max_length(5); gtk_widget_set_usize(entry, 50, -1); gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(pix_count_y_CB), entry); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); gtk_widget_show(entry); /***** proximity *****/ hbox = gtk_hbox_new(FALSE, 2); gtk_box_pack_start(GTK_BOX(vbox2), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); label = gtk_label_new("Proximity of duplicates: "); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show(label); entry = gtk_entry_new_with_max_length(5); gtk_widget_set_usize(entry, 50, -1); gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(pix_proximity_CB), entry); sprintf(buf, "%d", globals.new_opt.proximity); gtk_entry_set_text(GTK_ENTRY(entry), buf); gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0); gtk_widget_show(entry); /**************** Dismiss **************************/ // hbox = gtk_hbox_new(FALSE, 2); // gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); // gtk_widget_show(hbox); // button = gtk_button_new_with_label("Apply"); // gtk_signal_connect_object(GTK_OBJECT(button), "clicked", // GTK_SIGNAL_FUNC(apply_CB), // GTK_OBJECT(optWindow)); // gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); // GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); // gtk_widget_show(button); button = gtk_button_new_with_label("Dismiss"); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(optWindow)); // gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0); GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); gtk_widget_show(button); } /* set the toggle buttons to the right state */ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(size_button), globals.new_opt.opt_alg == PIX_SIZE ? TRUE : FALSE); gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(count_button), globals.new_opt.opt_alg == PIX_COUNT ? TRUE : FALSE); /* set the test entry boxes to the right state */ refresh_options_win(&(globals.new_opt)); if (!GTK_WIDGET_VISIBLE(optWindow)) { gtk_widget_show(optWindow); } else { gtk_widget_destroy(optWindow); } } int is_valid_int(char *str){ char *p1; int val; for(p1=str; *p1!='\0'; p1++){ if(!isdigit(*p1)) return -1; } if(1 != sscanf(str, "%d", &val)) return -1; return val; } void refresh_options_win(struct IMAGE_OPTIONS *im_opt){ char buf[8]; if(optWindow){ sprintf(buf, "%d", im_opt->pixW); gtk_entry_set_text(GTK_ENTRY(size_x_entry), buf); sprintf(buf, "%d", im_opt->pixH); gtk_entry_set_text(GTK_ENTRY(size_y_entry), buf); sprintf(buf, "%d", im_opt->nPixW); gtk_entry_set_text(GTK_ENTRY(count_x_entry), buf); sprintf(buf, "%d", im_opt->nPixH); gtk_entry_set_text(GTK_ENTRY(count_y_entry), buf); if(globals.new_opt.opt_alg == PIX_SIZE){ gtk_entry_set_editable(GTK_ENTRY(size_x_entry), TRUE); gtk_entry_set_editable(GTK_ENTRY(size_y_entry), TRUE); gtk_entry_set_editable(GTK_ENTRY(count_x_entry), FALSE); gtk_entry_set_editable(GTK_ENTRY(count_y_entry), FALSE); gtk_widget_set_sensitive(size_x_entry, TRUE); gtk_widget_set_sensitive(size_y_entry, TRUE); gtk_widget_set_sensitive(count_x_entry, FALSE); gtk_widget_set_sensitive(count_y_entry, FALSE); } else { gtk_entry_set_editable(GTK_ENTRY(size_x_entry), FALSE); gtk_entry_set_editable(GTK_ENTRY(size_y_entry), FALSE); gtk_entry_set_editable(GTK_ENTRY(count_x_entry), TRUE); gtk_entry_set_editable(GTK_ENTRY(count_y_entry), TRUE); gtk_widget_set_sensitive(size_x_entry, FALSE); gtk_widget_set_sensitive(size_y_entry, FALSE); gtk_widget_set_sensitive(count_x_entry, TRUE); gtk_widget_set_sensitive(count_y_entry, TRUE); } } } void apply_CB(GtkWidget *widget, GtkWidget *dialog){ if(0 == calc_dimensions(&(globals.new_opt))){ printf("error\n"); return; } refresh_options_win(&(globals.new_opt)); gtk_widget_destroy(dialog); } void pix_opt_alg_CB(GtkWidget *widget, gpointer data){ if(GTK_TOGGLE_BUTTON(widget)->active){ globals.new_opt.opt_alg = (int)data; } refresh_options_win(&(globals.new_opt)); } void pix_size_x_CB(GtkWidget *widget, GtkWidget *entry){ gchar *txt; txt = gtk_entry_get_text(GTK_ENTRY(entry)); printf("pix_size_x_CB: %s\n", txt); globals.new_opt.pixW = is_valid_int(txt); if(0 == calc_dimensions(&(globals.new_opt))){ printf("error\n"); return; } refresh_options_win(&(globals.new_opt)); } void pix_size_y_CB(GtkWidget *widget, GtkWidget *entry){ gchar *txt; txt = gtk_entry_get_text(GTK_ENTRY(entry)); printf("pix_size_y_CB: %s\n", txt); globals.new_opt.pixH = is_valid_int(txt); if(0 == calc_dimensions(&(globals.new_opt))){ printf("error\n"); return; } refresh_options_win(&(globals.new_opt)); } void pix_count_x_CB(GtkWidget *widget, GtkWidget *entry){ gchar *txt; txt = gtk_entry_get_text(GTK_ENTRY(entry)); printf("pix_count_x_CB: %s\n", txt); globals.new_opt.nPixW = is_valid_int(txt); if(0 == calc_dimensions(&(globals.new_opt))){ printf("error\n"); return; } refresh_options_win(&(globals.new_opt)); } void pix_count_y_CB(GtkWidget *widget, GtkWidget *entry){ gchar *txt; txt = gtk_entry_get_text(GTK_ENTRY(entry)); printf("pix_count_y_CB: %s\n", txt); globals.new_opt.nPixH = is_valid_int(txt); if(0 == calc_dimensions(&(globals.new_opt))){ printf("error\n"); return; } refresh_options_win(&(globals.new_opt)); } void pix_proximity_CB(GtkWidget *widget, GtkWidget *entry){ gchar *txt; txt = gtk_entry_get_text(GTK_ENTRY(entry)); printf("pix_proximity_CB: %s\n", txt); globals.new_opt.proximity = is_valid_int(txt); } pixelize-1.0.0.orig/display.c0000600000175000017500000001606311134755421014274 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* display.c by Paul Wilkins 1/2/2000 */ #include #include #include #include "globals.h" #include "read_db.h" #include "render_image.h" #include "file_dialog.h" #include "draw_image.h" #include "find_match.h" #include "info_popup.h" #include "display.h" /* some callbacks */ static gint ExposeCB(GtkWidget *widget, GdkEventExpose *event, gpointer func_data); static gint ResizeCB(GtkWidget *widget, GdkEventConfigure *event, gpointer func_data); static gint ButtonPressEvnt(GtkWidget *widget, GdkEventButton *event, gpointer func_data); static gint ButtonReleaseEvnt(GtkWidget *widget, GdkEventButton *event, gpointer func_data); static gint KeyPressEvnt(GtkWidget *widget, GdkEventKey *event, gpointer func_data); static gint KeyReleaseEvnt(GtkWidget *widget, GdkEventKey *event, gpointer func_data); GtkWidget *setup_display(GtkWidget *parent){ int wid, hgt; wid = 300; hgt = 300; /***** create an event box *****/ globals.ebox = gtk_event_box_new(); gtk_box_pack_start(GTK_BOX(parent), globals.ebox, TRUE, TRUE, 0); gtk_widget_show(globals.ebox); /***** create a new scrolled window. *****/ globals.picScroll = gtk_scrolled_window_new(NULL, NULL); gtk_widget_set_usize(globals.picScroll, wid, hgt); gtk_container_set_border_width(GTK_CONTAINER(globals.picScroll), 0); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(globals.picScroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add(GTK_CONTAINER(globals.ebox), globals.picScroll); /* gtk_box_pack_start(GTK_BOX(parent), globals.picScroll, TRUE, TRUE, 0); */ gtk_widget_show(globals.picScroll); /***** create the drawing area *****/ globals.picDA = gtk_drawing_area_new(); gtk_drawing_area_size(GTK_DRAWING_AREA(globals.picDA), wid, hgt); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(globals.picScroll), globals.picDA); gtk_widget_show(globals.picDA); /* Signals used to handle window ops */ gtk_signal_connect(GTK_OBJECT(globals.picDA), "expose_event", (GtkSignalFunc)ExposeCB, NULL); gtk_signal_connect(GTK_OBJECT(globals.picDA), "configure_event", (GtkSignalFunc)ResizeCB, NULL); /* Event signals (Input) */ gtk_signal_connect(GTK_OBJECT(globals.picDA), "button_press_event", (GtkSignalFunc)ButtonPressEvnt, NULL); gtk_signal_connect(GTK_OBJECT(globals.picDA), "button_release_event", (GtkSignalFunc)ButtonReleaseEvnt, NULL); gtk_signal_connect_after(GTK_OBJECT(globals.picDA), "key_press_event", (GtkSignalFunc)KeyPressEvnt, NULL); gtk_signal_connect_after(GTK_OBJECT(globals.picDA), "key_release_event", (GtkSignalFunc)KeyReleaseEvnt, NULL); gtk_widget_set_events(globals.picDA, GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK); GTK_WIDGET_SET_FLAGS(globals.picDA, GTK_CAN_FOCUS); gtk_widget_grab_focus(globals.picDA); return globals.picScroll; } static gint ExposeCB(GtkWidget *widget, GdkEventExpose *event, gpointer func_data){ static int picInitalized = 0; if(picInitalized == 0){ /* save the size of the display */ globals.disp_w = gdk_screen_width(); globals.disp_h = gdk_screen_height(); picInitalized = 1; if(globals.start_fname){ open_image(globals.start_fname); } } redraw_screen(event->area.x, event->area.y, event->area.width, event->area.height); return FALSE; } static gint ResizeCB(GtkWidget *widget, GdkEventConfigure *event, gpointer func_data){ int w, h; gdk_window_get_size(GTK_WIDGET(globals.ebox)->window, &w, &h); /* we need to tell Gtk's brain dead scrollbar when not to appear */ if(w >= globals.cur_opt.width && h >= globals.cur_opt.height){ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(globals.picScroll), GTK_POLICY_NEVER, GTK_POLICY_NEVER); } else { gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(globals.picScroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); } /* dammit: let the user resize the window! I think gtk_widget_set_usize() messes with this. */ /* gdk_window_set_hints(GTK_WIDGET(globals.topwin)->window, 0, 0, 300, 300, 0, 0, GDK_HINT_MIN_SIZE); */ return TRUE; } static gint KeyPressEvnt(GtkWidget *widget, GdkEventKey *event, gpointer func_data){ printf("picKeyPressEvnt\n"); return TRUE; } static gint KeyReleaseEvnt(GtkWidget *widget, GdkEventKey *event, gpointer func_data){ printf("picKeyReleaseEvnt\n"); switch(event->keyval){ case GDK_space: case GDK_KP_Space: globals.show_rendered = !globals.show_rendered; redraw_screen(0, 0, globals.cur_opt.width, globals.cur_opt.height); break; } return TRUE; } static gint ButtonPressEvnt(GtkWidget *widget, GdkEventButton *event, gpointer func_data) { int xx, yy; xx = event->x / globals.cur_opt.pixW; yy = event->y / globals.cur_opt.pixH; if(event->x < 0 || event->x >= globals.cur_opt.width) return TRUE; if(event->y < 0 || event->y >= globals.cur_opt.height) return TRUE; if(globals.image != NULL){ if(event->button == 2){ info_popup(xx, yy); info_prev(); } else if (event->button == 3) { info_popup(xx, yy); info_next(); } else if (event->button == 1) { info_popup(xx, yy); } } return TRUE; } static gint ButtonReleaseEvnt(GtkWidget *widget, GdkEventButton *event, gpointer func_data) { return TRUE; } int resize_window(){ int x, y, w, h; /* calculate the window size */ if(globals.cur_opt.width > globals.disp_w){ w = globals.disp_w; x = 0; } else { w = globals.cur_opt.width; x = 100; } if(globals.cur_opt.height > globals.disp_h){ h = globals.disp_h; y = 0; } else { h = globals.cur_opt.height; y = 100; } gtk_drawing_area_size(GTK_DRAWING_AREA(globals.picDA), globals.cur_opt.width, globals.cur_opt.height); /* gdk_window_resize(GTK_WIDGET(globals.topwin)->window, w, h); gtk_window_set_default_size(GTK_WINDOW(globals.mainwin), w, h); */ /* set the size of the window, and allow user resizing */ gtk_widget_set_usize(GTK_WIDGET(globals.picScroll), w, h); gtk_window_set_policy(GTK_WINDOW(globals.topwin), TRUE, TRUE, TRUE); return 1; } pixelize-1.0.0.orig/options.h0000600000175000017500000000175211134712554014326 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* options.h by Paul Wilkins 1/2/2000 */ #ifndef __OPTIONS_H #define __OPTIONS_H /* the dialog */ extern GtkWidget *optWindow; /* pops up a new window with all the options in it */ void optionsCB(gpointer data); void refresh_options_win(struct IMAGE_OPTIONS *im_opt); #endif pixelize-1.0.0.orig/find_match.c0000600000175000017500000000451511134712554014722 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* find_match.c by Paul Wilkins 1/2/2000 */ #include #include #include #include "read_db.h" #include "find_match.h" struct PIC_DB **find_match(int order, int *match_data, struct PIC_DB *head){ int i, j; int r, g, b; int r1, g1, b1; int r2, g2, b2; int *p1, *p2; double fit; double best_fit[MAX_MATCHES]; struct PIC_DB **matches; struct PIC_DB *db; if(NULL == (matches=malloc(MAX_MATCHES*sizeof(struct PIC_DB *)))){ perror("malloc"); exit(1); } for(i=0; inext){ /* printf("comparing against: %s\n", db->fname); */ p1 = db->data[order-1]; p2 = match_data; fit = 0.0; for(i=0; i g1 && r1 > b1) r /= 2.0; else if(g1 > r1 && g1 > b1) g /= 2.0; else if(b1 > r1 && b1 > g1) b /= 2.0; */ fit += sqrt(r*r + g*g + b*b); } for(i=0; ii; j--){ best_fit[j] = best_fit[j-1]; matches[j] = matches[j-1]; } best_fit[i] = fit; matches[i] = db; break; } } } return matches; } pixelize-1.0.0.orig/help.c0000600000175000017500000001076411134761620013557 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* help.c by Paul Wilkins 1/2/2000 */ #include #include #include #include "help.h" #include "license.h" #define HELP_TXT \ "\n\ Pixelize v1.0.0\n\ \n\ By: Paul Wilkins\n\ pwilkins@wilkins.ne.mediaone.net\n\ \n\ Pixelize is a program that will use many scaled down images\n\ to try to duplicate, as closely as possible, another image.\n\ \n\ Pixelize works by splitting up the image you want rendered\n\ (or duplicated) into a grid of small rectangular areas. Each\n\ area is analyzed, and replaced with an image chosen from a\n\ large database of images. Pixelize tries to pick images that\n\ best matches each area.\n\ \n\ Pixelize may be told how to size the grid, by either the number\n\ of areas in the grid, or by the dimensions of the areas in the\n\ grid.\n\ \n\ Once Pixelize has rendered an image, it displays the grid of\n\ small images that it has chosen, in place of the original image.\n\ By clicking on each small image, Pixelize will allow you to\n\ choose alternate images from a list of images, that also fit\n\ well into that area.\n\ \n\ Pixelize works best when it can choose images from a very large\n\ database of images. With about 1000 images, Pixelize can do a\n\ reasonable job.\n\ \n\ Steps to create a \"rendered\" image:\n\ \n\ 1) Create the database that Pixelize requires. Use the included\n\ program, make_db.\n\ \n\ 2) Start Pixelize. Open an image using \"Open\" from the File menu.\n\ \n\ 3) Render the image. Use \"Render\" from the Options manu.\n\ \n\ " void popup_window(GtkWidget **dialog, char *txt, char *title){ GtkWidget *vbox; GtkWidget *scrolled_win; GtkWidget *label; GtkWidget *button; if (!*dialog) { *dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(*dialog), title); gtk_signal_connect(GTK_OBJECT(*dialog), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), dialog); gtk_container_set_border_width(GTK_CONTAINER(*dialog), 5); gtk_window_set_title(GTK_WINDOW(*dialog), title); gtk_widget_set_usize(*dialog, 470, 470); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(*dialog), vbox); gtk_widget_show(vbox); scrolled_win = gtk_scrolled_window_new (NULL, NULL); gtk_container_set_border_width(GTK_CONTAINER(scrolled_win), 5); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrolled_win), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(vbox), scrolled_win, TRUE, TRUE, 0); gtk_widget_show(scrolled_win); label = gtk_label_new(txt); gtk_signal_connect(GTK_OBJECT(label), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &label); gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_win), label); gtk_widget_show(label); button = gtk_button_new_with_label("Dismiss"); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(*dialog)); gtk_box_pack_end(GTK_BOX(vbox), button, FALSE, FALSE, 0); GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); /* gtk_widget_grab_default(button); This puts an ugly box around the botton */ gtk_widget_show(button); } if (!GTK_WIDGET_VISIBLE(*dialog)) gtk_widget_show(*dialog); else gtk_widget_destroy(*dialog); } void license_popup(){ static GtkWidget *dialog = NULL; popup_window(&dialog, LICENSE_TXT, "License"); } void help_popup(){ static GtkWidget *dialog = NULL; popup_window(&dialog, HELP_TXT, "Help"); } pixelize-1.0.0.orig/callback_menu.c0000600000175000017500000000305611134712550015401 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* callback_menu.c by Paul Wilkins 1/2/2000 */ #include #include /* #include */ #include "globals.h" #include "menu.h" #include "help.h" #include "render.h" #include "file_dialog.h" #include "options.h" gint delete_event(GtkWidget *w, GdkEvent *e, gpointer d){ return FALSE; /* will call our destroy function */ } void destroy(GtkWidget *widget, gpointer data){ gtk_main_quit(); } /* quit the program */ void quitCB(gpointer data){ gtk_main_quit(); } /* open an image to render */ void openCB(gpointer data){ file_open_dialog(NULL); } /* save the rendered image */ void saveCB(gpointer data){ file_save_dialog(NULL); } /* save the rendered image */ void renderCB(gpointer data){ render(); } void licenseCB(gpointer data){ license_popup(); } void helpCB(gpointer data){ help_popup(); } pixelize-1.0.0.orig/status.c0000600000175000017500000000767611134712555014165 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* status.c by Paul Wilkins 1/2/2000 */ #include #include #include /* #include */ #include "globals.h" #include "status.h" GtkWidget *mode_display; GtkWidget *progress_bar; void toggle_progress_indicator(int onoff){ if(onoff == ST_PERCENT){ gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), "%p%%"); gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0); gtk_progress_set_activity_mode(GTK_PROGRESS(progress_bar), FALSE); gtk_progress_set_show_text(GTK_PROGRESS(progress_bar), TRUE); } else if(onoff == ST_PROGRESS){ gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), "%p%%"); gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0); gtk_progress_set_activity_mode(GTK_PROGRESS(progress_bar), TRUE); gtk_progress_set_show_text(GTK_PROGRESS(progress_bar), FALSE); } else if(onoff == ST_READY){ gtk_progress_set_format_string(GTK_PROGRESS(progress_bar), "Ready"); gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), 0.0); gtk_progress_set_activity_mode(GTK_PROGRESS(progress_bar), FALSE); gtk_progress_set_show_text(GTK_PROGRESS(progress_bar), TRUE); } else { fprintf(stderr, "toggle_progress_indicator: onoff invalid\n"); exit(1); } /* force an update NOW */ gtk_widget_draw(GTK_WIDGET(progress_bar), NULL); gdk_flush(); } void set_progress_indicator(double val){ static int last_percent = -1; /* don't bother updating if we haven't changed by al least 1 percent */ if(last_percent == (int)(100.0*val)) return; last_percent = (int)(100.0*val); gtk_progress_bar_update(GTK_PROGRESS_BAR(progress_bar), val); /* force an update NOW */ gtk_widget_draw(GTK_WIDGET(progress_bar), NULL); gdk_flush(); } void refresh_mode_display(){ char buf[256]; if(globals.cur_opt.opt_alg == PIX_SIZE){ sprintf(buf, " Size of images: %dx%d", globals.cur_opt.pixW, globals.cur_opt.pixH); } else { sprintf(buf, " Number of Images: %dx%d", globals.cur_opt.nPixW, globals.cur_opt.nPixH); } gtk_label_set(GTK_LABEL(mode_display), buf); } GtkWidget *setup_status(GtkWidget *parent){ GtkWidget *hbox; /* create the hbox that will hold our widgets */ hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_end(GTK_BOX(parent), hbox, FALSE, FALSE, 0); gtk_widget_show(hbox); /* first is a progressbar */ progress_bar = gtk_progress_bar_new(); /* Set the progress bar format */ gtk_progress_bar_set_bar_style(GTK_PROGRESS_BAR(progress_bar), GTK_PROGRESS_CONTINUOUS); gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(progress_bar), GTK_PROGRESS_LEFT_TO_RIGHT); gtk_progress_set_activity_mode(GTK_PROGRESS(progress_bar), FALSE); gtk_progress_set_show_text(GTK_PROGRESS(progress_bar), TRUE); toggle_progress_indicator(ST_READY); gtk_box_pack_start(GTK_BOX(hbox), progress_bar, FALSE, FALSE, 0); gtk_widget_show(progress_bar); /* now a label to display stuff */ mode_display = gtk_label_new(" "); gtk_box_pack_start(GTK_BOX(hbox), mode_display, FALSE, FALSE, 0); gtk_widget_show(mode_display); /* set the string */ refresh_mode_display(); return hbox; } pixelize-1.0.0.orig/draw_image.c0000600000175000017500000001326411134755233014727 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* draw_image.c by Paul Wilkins 1/2/2000 */ #include #include #include #include /* #include */ #include "globals.h" #include "render_image.h" #include "read_db.h" #include "draw_image.h" int check_options(struct IMAGE_OPTIONS *im_opt){ int ret = 1; if(im_opt->opt_alg == PIX_SIZE) { if(im_opt->pixW < 1){ printf("Image size X: invalid number\n"); ret = 0; } if(im_opt->pixH < 1){ printf("Image size Y: invalid number\n"); ret = 0; } } else { if(im_opt->nPixW < 1){ printf("Image count X: invalid number\n"); ret = 0; } if(im_opt->nPixH < 1){ printf("Image count Y: invalid number\n"); ret = 0; } } if(-1 == im_opt->proximity){ printf("Image proximity: invalid number\n"); ret = 0; } return ret; } int calc_dimensions(struct IMAGE_OPTIONS *im_opt){ if(0 == check_options(im_opt)){ printf("error with options\n"); return 0; } if(im_opt->opt_alg == PIX_SIZE) { if(globals.in_im == NULL){ im_opt->nPixW = 0; im_opt->nPixH = 0; } else { im_opt->nPixW = ceil((double)gdk_pixbuf_get_width(globals.in_im) / (double)im_opt->pixW); im_opt->nPixH = ceil((double)gdk_pixbuf_get_height(globals.in_im) / (double)im_opt->pixH); } } else if (im_opt->opt_alg == PIX_COUNT) { if(globals.in_im == NULL){ im_opt->pixW = 0; im_opt->pixH = 0; } else { im_opt->pixW = ceil((double)gdk_pixbuf_get_width(globals.in_im) / (double)im_opt->nPixW); im_opt->pixH = ceil((double)gdk_pixbuf_get_height(globals.in_im) / (double)im_opt->nPixH); } } else { fprintf(stderr, "calc_dimensions: I shouldn't get here.\n"); exit(1); } im_opt->width = im_opt->nPixW * im_opt->pixW; im_opt->height = im_opt->nPixH * im_opt->pixH; return 1; } int copy_opt_data(){ int ret = 0; if(globals.cur_opt.width != globals.new_opt.width) ret = 1; if(globals.cur_opt.height != globals.new_opt.height) ret = 1; globals.cur_opt.pixW = globals.new_opt.pixW; globals.cur_opt.pixH = globals.new_opt.pixH; globals.cur_opt.nPixW = globals.new_opt.nPixW; globals.cur_opt.nPixH = globals.new_opt.nPixH; globals.cur_opt.width = globals.new_opt.width; globals.cur_opt.height = globals.new_opt.height; globals.cur_opt.opt_alg = globals.new_opt.opt_alg; globals.cur_opt.proximity = globals.new_opt.proximity; return ret; } void redraw_screen(int x, int y, int w, int h){ int width, height; GtkStyle *style; /* return if o image has been opened */ if(globals.in_im == NULL) return; /* copy it to the screen */ style = gtk_widget_get_style(GTK_WIDGET(globals.picDA)); width = gdk_pixbuf_get_width((globals.image && globals.show_rendered) ? globals.out_im : globals.in_im_scaled); height = gdk_pixbuf_get_height((globals.image && globals.show_rendered) ? globals.out_im : globals.in_im_scaled); // modify width and height such that we don't ask for portions of the image that don't exist if(x+w > width) w = width-x; if(w < 0) w = 0; if(y+h > height) h = height-y; if(h < 0) h = 0; gdk_draw_pixbuf( GTK_WIDGET(globals.picDA)->window, style->fg_gc[GTK_STATE_NORMAL], (globals.image && globals.show_rendered) ? globals.out_im : globals.in_im_scaled, x, y, // src x, y x, y, // dst x, y w, h, GDK_RGB_DITHER_NORMAL, 0, 0 // dither offset ); } int change_small_image(int xx, int yy){ struct PIC_DB *db; struct IMAGE_INFO *inf; GError *gerror; GdkPixbuf *im; GdkPixbuf *scale_im; GdkPixbuf *scale_im_alpha; if(globals.image != NULL){ inf = &(globals.image[yy][xx]); db = inf->matches[inf->match_no]; /* load the image */ gerror = NULL; if(NULL == (im = gdk_pixbuf_new_from_file(db->fname, &gerror))){ fprintf(stderr, "Error: Can't load image %s: %s\n", db->fname, gerror->message); return 0; } /* scale the image */ if(NULL == (scale_im=gdk_pixbuf_scale_simple(im, globals.cur_opt.pixW, globals.cur_opt.pixH, GDK_INTERP_BILINEAR))){ fprintf(stderr, "Error: Unable to scale image %s\n", db->fname); return 0; } /* add an alpha channel */ scale_im_alpha = gdk_pixbuf_add_alpha(scale_im, 0, 0, 0, 0); draw_small_image(scale_im_alpha, xx, yy); copy_image_RGB(scale_im_alpha, globals.out_im, xx, yy); g_object_unref(im); g_object_unref(scale_im); g_object_unref(scale_im_alpha); } return 1; } int draw_small_image(GdkPixbuf *scale_im, int x, int y){ GtkStyle *style; style = gtk_widget_get_style(GTK_WIDGET(globals.picDA)); gdk_draw_pixbuf( GTK_WIDGET(globals.picDA)->window, style->fg_gc[GTK_STATE_NORMAL], scale_im, 0, 0, // src x, y globals.cur_opt.pixW * x, globals.cur_opt.pixH * y, globals.cur_opt.pixW, globals.cur_opt.pixH, GDK_RGB_DITHER_NORMAL, 0, 0 // dither offset ); return 1; } pixelize-1.0.0.orig/read_line.h0000600000175000017500000000173511134712555014557 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* * read_line.h by Paul Wilkins 11/20/96 */ #ifndef __READ_LINE_H #define __READ_LINE_H /* * Reads a line from the specified file into the specified string. * Returns 1 on success and EOF if end of file was reached. */ int read_line(FILE *, char *); #endif pixelize-1.0.0.orig/README0000600000175000017500000000216011134712555013335 0ustar uweuwe Pixelize Version 0.8.0 By Paul Wilkins Pixelize is a program that will use many scaled down images to try to duplicate, as closely as possible, another image. Pixelize works by splitting up the image you want rendered (or duplicated) into a grid of small rectangular areas. Each area is analyzed, and replaced with an image chosen from a large database of images. Pixelize tries to pick images that best matches each area. To build Pixelize: 1) Edit the Makefile to tell the compiler where to find the X and GTK headers and libraries if you do not have the gtk-config script properly installed. Most systems will not need this. 2) Run make. 3) Copy the executables, pixelize and make_db, to it's final installation directory, for example /usr/local/bin. Note that in order to use Pixelize to render an immage, you will have to run make_db to create the database of images that Pixelize requires. Pixelize can be found at the following locations: http://wilkins.ne.mediaone.net/pixelize.html ftp://metalab.unc.edu/pub/linux/apps/graphics/misc That's it. Good Luck. Paul pwilkins@wilkins.ne.mediaone.net pixelize-1.0.0.orig/render_image.h0000600000175000017500000000254011134712555015251 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* render_image.h by Paul Wilkins 1/2/2000 */ #ifndef __RENDER_IMAGE_H #define __RENDER_IMAGE_H struct IMAGE_INFO { int nMatch; /* number of matches in matches */ int match_no; /* which match in matches is db */ int do_highlight; /* should we highlight this image somehow */ struct PIC_DB *db; /* the image we are actually using */ struct PIC_DB **matches; /* all the other possible matches */ }; GdkPixbuf *render_image(struct IMAGE_INFO **image, int nPixW, int nPixH, int pixW, int pixH); void copy_image_RGB( GdkPixbuf *src, GdkPixbuf *dst, int col, int row); #endif pixelize-1.0.0.orig/read_db.h0000600000175000017500000000176411134712555014217 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* read_db.h by paul wilkins 1/2/2000 */ #ifndef __READ_PIC_DB_H #define __READ_PIC_DB_H struct PIC_DB { int done; int refcnt; char *fname; int **data; struct PIC_DB *next; }; struct PIC_DB *read_database(int *max_order); void reset_db_data(struct PIC_DB *head); #endif pixelize-1.0.0.orig/globals.c0000600000175000017500000000344711134754772014264 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* globals.c by Paul Wilkins 1/2/2000 */ #include #include #include /* #include */ #include "read_db.h" #include "globals.h" struct GLOBALS globals; int init_globals(){ globals.topwin = NULL; globals.ebox = NULL; globals.disp_w = 0; globals.disp_h = 0; globals.picDA = NULL; globals.picScroll = NULL; globals.head = NULL; globals.image = NULL; globals.max_order = 0; globals.do_highlight = 0; globals.show_rendered = 1; globals.in_fname = NULL; globals.in_im = NULL; globals.in_im_scaled = NULL; globals.pixmap = NULL; globals.out_fname = NULL; globals.out_im = NULL; globals.start_fname = NULL; globals.cur_opt.pixW = 25; globals.cur_opt.pixH = 25; globals.cur_opt.nPixW = 30; globals.cur_opt.nPixH = 30; globals.cur_opt.proximity = 8; globals.cur_opt.opt_alg = PIX_SIZE; globals.new_opt.pixW = 25; globals.new_opt.pixH = 25; globals.new_opt.nPixW = 30; globals.new_opt.nPixH = 30; globals.new_opt.proximity = 8; globals.new_opt.opt_alg = PIX_SIZE; return 1; } pixelize-1.0.0.orig/stats.c0000600000175000017500000000253011134712555013760 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* stats.c by Paul Wilkins 1/2/2000 */ #include #include #include "stats.h" int calc_mead_std(double *data, int n, double *mean, double *std){ int i; double sum; double sd; if(n == 0){ *std = 0.0; *mean = 0.0; } else if(n == 1){ *std = 0.0; *mean = data[0]; } else { /* find the mean */ sum = 0.0; for(i=0; i #include #include "read_line.h" int read_line(FILE *fp, char *line){ char c; while(EOF != (c = getc(fp)) && c!='\n'){ *line++ = c; } *line++ = '\0'; if(c == EOF) return EOF; return 1; } pixelize-1.0.0.orig/render_image.c0000600000175000017500000001126211134732614015243 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* render_image.c by Paul Wilkins 1/2/2000 */ #include #include #include #include /* #include */ #include "globals.h" #include "status.h" #include "read_db.h" #include "draw_image.h" #include "render_image.h" void find_next(struct IMAGE_INFO **image, struct PIC_DB *db, int *col, int *row, int nPixW, int nPixH){ int r, c, cl; cl = (*col) + 1; for(r=*row; rdone == 1) continue; image[hh][ww].db->done = 1; /* load the image */ gerror = NULL; if(NULL == (im=gdk_pixbuf_new_from_file(image[hh][ww].db->fname, &gerror))){ fprintf(stderr, "Error: Unable to open %s: %s\n", image[hh][ww].db->fname, gerror->message); continue; } /* scale the image */ if(NULL == (scale_im=gdk_pixbuf_scale_simple(im, pixW, pixH, GDK_INTERP_BILINEAR))){ fprintf(stderr, "Error: Unable to scale image %s\n", image[hh][ww].db->fname); continue; } /* add an alpha channel */ scale_im_alpha = gdk_pixbuf_add_alpha(scale_im, 0, 0, 0, 0); /* copy the image data into the output data */ for(i=0; irefcnt; i++){ if(i == 0){ row = hh; col = ww; } else { find_next(image, image[hh][ww].db, &col, &row, nPixW, nPixH); } draw_small_image(scale_im_alpha, col, row); copy_image_RGB(scale_im_alpha, dest, col, row); } g_object_unref(im); g_object_unref(scale_im); g_object_unref(scale_im_alpha); /* update the progress bar */ percent = (double)(hh*nPixW + ww + 1) / (double)(nPixH*nPixW); set_progress_indicator(percent); } } return dest; } pixelize-1.0.0.orig/render.c0000600000175000017500000002437011134767246014116 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* render.c by Paul Wilkins 1/2/2000 */ #include #include #include #include /* #include */ #include "globals.h" #include "read_db.h" #include "display.h" #include "stats.h" #include "status.h" #include "find_match.h" #include "draw_image.h" #include "cursor.h" #include "render_image.h" #include "render.h" #define STATS_SIZE 6 struct PIX { int cnt; double r; double g; double b; }; void average_image_area(struct PIX *avg, GdkPixbuf *im, int x, int y, int w, int h){ int i, j; int r, g, b; int xx, yy; guchar *pixels, *p; int rowstride, n_channels;; /* printf("average_image_area: x: %d y: %d w: %d h: %d\n", x, y, w, h); */ n_channels = gdk_pixbuf_get_n_channels(im); rowstride = gdk_pixbuf_get_rowstride(im); pixels = gdk_pixbuf_get_pixels(im); avg->r = 0.0; avg->g = 0.0; avg->b = 0.0; for(j=0; jr += r; avg->g += g; avg->b += b; } } avg->cnt = w * h; avg->r /= (double)(w*h); avg->g /= (double)(w*h); avg->b /= (double)(w*h); /* printf("average_image_area: r: %g g: %g b: %g\n", avg->r, avg->g, avg->b); */ } double calc_stddev(GdkPixbuf *im, int x, int y, int nPixW, int nPixH){ int w, h, n; int xx, yy, ww, hh; int pxx, pyy; double xoff, yoff; double meanR, stdR; double meanG, stdG; double meanB, stdB; struct PIX avg; double dataR[STATS_SIZE*STATS_SIZE]; double dataG[STATS_SIZE*STATS_SIZE]; double dataB[STATS_SIZE*STATS_SIZE]; /* printf("calc_stddev: x: %d y: %d\n", x, y); */ xoff = (double)x / (double)nPixW * (double)gdk_pixbuf_get_width(im); yoff = (double)y / (double)nPixH * (double)gdk_pixbuf_get_height(im); n = 0; pyy = (int)yoff; for(h=0; h=maxy) continue; for(x=cx-n; x<=cx+n; x++){ if(x<0 || x>=maxx) continue; if(x==cx && y==cy) continue; if(image[y][x].db == match) return 1; } } return 0; } int guess_order(double val, int pixW, int pixH, int max_order){ int order; order = (int)(sqrt((double)(pixW*pixH))/9.0 + (val / 6.0)); if(order > max_order) order = max_order; return order; } int render(){ int i, j; int pixW, pixH; int nPixW, nPixH; int *match_data; int proximity; double percent; GdkPixbuf *im; GdkPixbuf *out_im; int order; int ww, hh; double stddev; struct IMAGE_INFO **image; struct PIC_DB **matches; if(globals.in_fname == NULL || globals.in_im_scaled == NULL){ fprintf(stderr, "Error: Open an Image first!\n"); return 0; } /* free the old data, if any */ free_image_data(); /* calculate the new images dimensions */ if(0 == calc_dimensions(&(globals.new_opt))){ fprintf(stderr, "Invalid option. Bye.\n"); return 0; } /* set the cursor */ cursor_busy(); /* copy the image rendering data from new_opt to cur_opt */ if(copy_opt_data()){ resize_window(); if(globals.in_im_scaled != NULL) g_object_unref(globals.in_im_scaled); /* scale the image */ if(NULL == (globals.in_im_scaled=gdk_pixbuf_scale_simple( globals.in_im, globals.cur_opt.pixW * globals.cur_opt.nPixW, globals.cur_opt.pixH * globals.cur_opt.nPixH, GDK_INTERP_BILINEAR ))){ fprintf(stderr, "Error: Unable to scale image: %s\n", globals.in_fname); return 0; } } /* update the mode display info */ refresh_mode_display(); /* set our local copies of some of the globals */ im = globals.in_im_scaled; pixW = globals.cur_opt.pixW; pixH = globals.cur_opt.pixH; nPixW = globals.cur_opt.nPixW; nPixH = globals.cur_opt.nPixH; /* malloc the array to store the image info */ if(NULL == (image=malloc(nPixH*sizeof(struct IMAGE_INFO *)))){ perror("Malloc"); exit(1); } for(hh=0; hh= nPixW){ ww = 0; hh++; if(hh >= nPixH) hh = 0; } } matches = image[hh][ww].matches; /* pick one of the (hopefully the best) matches to fill this spot */ proximity = globals.cur_opt.proximity; do { for(i=0; i=0 && i == MAX_MATCHES); /* probably only one file */ if(matches[i] == NULL) i = 0; /* store the image we picked */ image[hh][ww].match_no = i; image[hh][ww].db = matches[i]; image[hh][ww].db->refcnt++; image[hh][ww].db->done = 0; } /* render the image */ if(NULL == (out_im = render_image(image, nPixW, nPixH, pixW, pixH))){ fprintf(stderr, "Error: Can't render image.\n"); exit(1); } globals.out_im = out_im; /* display it */ // draw_big_image(out_im); redraw_screen(0, 0, globals.cur_opt.width, globals.cur_opt.height); /* turn off the progress bar */ toggle_progress_indicator(ST_READY); /* set the cursor */ cursor_normal(); return 1; } pixelize-1.0.0.orig/cursor.c0000600000175000017500000000237711134712554014147 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* cursor.c by Paul Wilkins 1/2/2000 */ #include #include /* #include */ /* #include */ #include "cursor.h" #include "globals.h" void cursor_busy(){ static GdkCursor *cur = NULL; if(cur == NULL) cur = gdk_cursor_new(GDK_WATCH); gdk_window_set_cursor(GTK_WIDGET(globals.topwin)->window, cur); gdk_flush(); } void cursor_normal(){ static GdkCursor *cur = NULL; if(cur == NULL) cur = gdk_cursor_new(GDK_TOP_LEFT_ARROW); gdk_window_set_cursor(GTK_WIDGET(globals.topwin)->window, cur); } pixelize-1.0.0.orig/license.h0000600000175000017500000000276111134712554014256 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define LICENSE_TXT "\n\ \n\ Copyright (C) 2000 Paul Wilkins\n\ \n\ This program is free software; you can redistribute it and/or\n\ modify it under the terms of the GNU General Public License\n\ as published by the Free Software Foundation; either version 2\n\ of the License, or (at your option) any later version.\n\ \n\ This program is distributed in the hope that it will be useful,\n\ but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See\n\ the GNU General Public License for more details.\n\ \n\ You should have received a copy of the GNU General Public License\n\ along with this program; if not, write to the Free Software\n\ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA \n\ 02111-1307, USA.\n\ \n\ \n\ " pixelize-1.0.0.orig/make_db.c0000600000175000017500000001431511135224067014205 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* make_db.c by Paul Wilkins 1/2/2000 */ #include #include #include #include #include #include #include #include // #include struct PIX { int cnt; double r; double g; double b; }; #define MAX_SIZE 5 #define MAX_PATH_LEN 512 int main(int argc, char **argv) { int write_db = 1; int i, j, n; int size; Display *disp; GError *gerror; GdkPixbuf *pb; int qh, qw; int width, height; int ww, hh; guchar *p; guchar *pixels; int rowstride, n_channels; struct PIX ***quad; char my_cwd[MAX_PATH_LEN+1]; FILE *dbfp; gtk_init(&argc, &argv); /* Be nice and tell the user if they don't, to provide a file as an arg */ if (argc <= 1) { fprintf(stderr, "make_db is a program that scanns pictures and creates a file\n"); fprintf(stderr, "called pic_db.dat. The file pic_db.dat is used by Pixelize\n"); fprintf(stderr, "when \"rendering\" images.\n"); fprintf(stderr, "\n"); fprintf(stderr, "Usage:\n %s image_files\n", argv[0]); exit(1); } if(NULL == (quad=malloc((MAX_SIZE+1)*sizeof(struct PIX *)))){ perror("malloc"); exit(1); } for(i=1; i<=MAX_SIZE; i++){ if(NULL == (quad[i]=malloc((MAX_SIZE+1)*sizeof(struct PIX *)))){ perror("malloc"); exit(1); } for(j=0; j<=MAX_SIZE; j++){ if(NULL == (quad[i][j]=malloc((MAX_SIZE+1)*sizeof(struct PIX)))){ perror("malloc"); exit(1); } } } /* Connect to the default Xserver */ // disp = XOpenDisplay(NULL); if(write_db){ if(NULL == (dbfp=fopen("pic_db.dat", "a+"))){ printf("Error opening pic_db.dat for write\n"); exit(1); } fprintf(dbfp, "%d\n", MAX_SIZE); } /* get the cwd. we may use it later */ if(NULL == (getcwd(my_cwd, MAX_PATH_LEN))){ fprintf(stderr, "Warning: Can't determine Current working directory.\n"); fprintf(stderr, " This may generate an invalid pic_db.dat file.\n"); my_cwd[0] = '\0'; } /* for each file */ for(n=1; nmessage); continue; } /* Suck the image's original width and height out of the Image structure */ width = gdk_pixbuf_get_width(pb); height = gdk_pixbuf_get_height(pb); pixels = gdk_pixbuf_get_pixels(pb); rowstride = gdk_pixbuf_get_rowstride(pb); n_channels = gdk_pixbuf_get_n_channels(pb); g_assert (gdk_pixbuf_get_colorspace (pb) == GDK_COLORSPACE_RGB); g_assert (gdk_pixbuf_get_bits_per_sample (pb) == 8); printf("file %d: %s width: %d height: %d\n", n, argv[n], width, height); if(write_db){ if(argv[n][0] != '/'){ fprintf(dbfp, "%s/%s\n", my_cwd, argv[n]); } else { fprintf(dbfp, "%s\n", argv[n]); } } for(size=1; size<=MAX_SIZE; size++){ for(hh=0; hh= size) qh = size - 1; for(ww=0; ww= size) qw = size - 1; p = pixels + hh * rowstride + ww * n_channels; quad[size][qw][qh].cnt++; quad[size][qw][qh].r += (double)(p[0]); quad[size][qw][qh].g += (double)(p[1]); quad[size][qw][qh].b += (double)(p[2]); } } } /* special case for size = 2 */ for(hh=0; hh<2; hh++){ for(ww=0; ww<2; ww++){ for(i=0; i<2; i++){ for(j=0; j<2; j++){ quad[2][ww][hh].cnt += quad[4][ww*2+i][hh*2+j].cnt; quad[2][ww][hh].r += quad[4][ww*2+i][hh*2+j].r; quad[2][ww][hh].g += quad[4][ww*2+i][hh*2+j].g; quad[2][ww][hh].b += quad[4][ww*2+i][hh*2+j].b; } } } } /* special case for size = 1 */ for(i=0; i<2; i++){ for(j=0; j<2; j++){ quad[1][0][0].cnt += quad[2][i][j].cnt; quad[1][0][0].r += quad[2][i][j].r; quad[1][0][0].g += quad[2][i][j].g; quad[1][0][0].b += quad[2][i][j].b; } } for(size=1; size<=MAX_SIZE; size++){ if(write_db){ for(hh=0; hh #include #include #include "read_line.h" #include "read_db.h" struct PIC_DB *malloc_db(int strlen, int n){ int i; struct PIC_DB *db; if(NULL == (db=malloc(sizeof(struct PIC_DB)))){ perror("malloc"); exit(1); } if(NULL == (db->fname=malloc((strlen+1)*sizeof(char)))){ perror("malloc"); exit(1); } if(NULL == (db->data=malloc(n*sizeof(int *)))){ perror("malloc"); exit(1); } for(i=0; idata[i]=malloc(3*(i+1)*(i+1)*sizeof(int)))){ perror("malloc"); exit(1); } } return db; } void reset_db_data(struct PIC_DB *head){ struct PIC_DB *db; for(db=head; db!=NULL; db=db->next){ db->refcnt = 0; db->done = 0; } } struct PIC_DB *read_database(int *max_order){ int i, j, done; int len; int ndb; int size; int ret; FILE *dbfp; int *p1; char line[1024]; struct PIC_DB *head, *db; if(NULL == (dbfp=fopen("pic_db.dat", "r"))){ fprintf(stderr, "Error opening pic_db.dat for read\n"); exit(1); } ret = read_line(dbfp, line); if(ret == EOF) { fprintf(stderr, "Error: can't read first line from pic_db.dat\n"); exit(1); } if(1 != sscanf(line, "%d", &size)){ fprintf(stderr, "Error: can't read size from pic_db.dat\n"); exit(1); } *max_order = size; ndb = 0; head = NULL; /* read in the db */ done = 0; do { ret = read_line(dbfp, line); if(*line == '\0') continue; if(*line == '#') continue; if(*line == '5') continue; len = strlen(line); db = malloc_db(len, size); strcpy(db->fname, line); /* printf("filename: %s\n", db->fname); */ for(j=0; jdata[j]; for(i=0; i<3*(j+1)*(j+1); i++){ if(1 != fscanf(dbfp, "%d", p1)){ fprintf(stderr, "Error: File %d: %s: reading value %d from pic_db.dat\n", ndb, db->fname, i); exit(1); } /* printf("Read value no: %d: %d\n", i, *p1); */ p1++; } } /* add db to the list */ db->next = head; head = db; ndb++; } while (ret != EOF && !done); fclose(dbfp); return head; } pixelize-1.0.0.orig/info_popup.h0000600000175000017500000000157011134712554015007 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* info_popup.h by Paul Wilkins 1/2/2000 */ #ifndef __INFO_POPUP_H #define __INFO_POPUP_H void info_popup(int x, int y); void info_prev(); void info_next(); #endif pixelize-1.0.0.orig/Makefile0000600000175000017500000000154511134713236014120 0ustar uweuwe# compile stuff in this dir CC = gcc CFLAGS = -g -I/usr/X11R6/include `pkg-config --cflags gtk+-2.0` -Wall DFLAGS = -L/usr/X11R6/lib `pkg-config --libs gtk+-2.0` -Wall LIBS = -lm OBJS = main.o setup_menu.o callback_menu.o help.o options.o \ display.o read_db.o globals.o read_line.o \ file_dialog.o draw_image.o status.o \ render.o render_image.o stats.o find_match.o \ info_popup.o highlight.o cursor.o all: make_db pixelize merge: merge.o read_line.o stats.o $(CC) -o $@ merge.o read_line.o stats.o $(DFLAGS) $(LIBS) make_db: make_db.o $(CC) -o $@ make_db.o $(DFLAGS) $(LIBS) # $(CC) -o $@ make_db.o `pkg-config --libs imlib2` $(LIBS) pixelize: $(OBJS) $(CC) -o $@ $(OBJS) $(DFLAGS) $(LIBS) .c.o: $(CC) -c -o $@ $(CFLAGS) $< depend: $(CC) -MM $(CFLAGS) *.c > depend clean: rm -f *.o pixelize make_db core include depend pixelize-1.0.0.orig/pixelize-1.0.0.lsm0000600000175000017500000000116511135225026015452 0ustar uweuweBegin3 Title: pixelize Version: 1.0.0 Entered-date: Jan. 18, 2008 Description: Pixelize is a program that will use many scaled down images to try to duplicate, as closely as possible, another image. Keywords: image viewer photo graphics render Author: pwilkins@lashwhip.com (Paul Wilkins) Maintained-by: pwilkins@lashwhip.com (Paul Wilkins) Primary-site: lashwhip.com /pub 32kB pixelize-1.0.0.tar.gz Alternate-site: metalab.unc.edu /pub/linux/apps/graphics/misc 32kB pixelize-1.0.0.tar.gz Copying-policy: GPL End pixelize-1.0.0.orig/depend0000600000175000017500000000000011134713314013620 0ustar uweuwepixelize-1.0.0.orig/find_match.h0000600000175000017500000000163211134712554014724 0ustar uweuwe/* Copyright (C) 2000 Paul Wilkins This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* find_match.h by Paul Wilkins 1/2/2000 */ #ifndef __FIND_MATCH_H #define __FIND_MATCH_H #define MAX_MATCHES 81 struct PIC_DB **find_match(int order, int *match_data, struct PIC_DB *head); #endif