Wed, 05 Aug 2009 15:00:54 +0100
small changes to hexdump code to stop a gcc warning on platforms where sizeof(int) != sizeof(int*) e.g. x86_64
philpem@5 | 1 | /* |
philpem@5 | 2 | # |
philpem@5 | 3 | # File : greycstoration4gimp.cpp |
philpem@5 | 4 | # ( C++ source file ) |
philpem@5 | 5 | # |
philpem@5 | 6 | # Description : GREYCstoration - A tool to denoise, inpaint and resize images. |
philpem@5 | 7 | # ( GIMP>=2.3.4 plug-in version ) |
philpem@5 | 8 | # This file is a part of the CImg Library project. |
philpem@5 | 9 | # ( http://cimg.sourceforge.net ) |
philpem@5 | 10 | # |
philpem@5 | 11 | # The GREYCstoration algorithm is an implementation of diffusion tensor-directed |
philpem@5 | 12 | # diffusion PDE's for image regularization and interpolation, published in |
philpem@5 | 13 | # |
philpem@5 | 14 | # "Fast Anisotropic Smoothing of Multi-Valued Images |
philpem@5 | 15 | # using Curvature-Preserving PDE's" |
philpem@5 | 16 | # (D. Tschumperle) |
philpem@5 | 17 | # International Journal of Computer Vision, May 2006. |
philpem@5 | 18 | # (see also http://www.greyc.ensicaen.fr/~dtschump/greycstoration) |
philpem@5 | 19 | # |
philpem@5 | 20 | # "Vector-Valued Image Regularization with PDE's : A Common Framework |
philpem@5 | 21 | # for Different Applications" |
philpem@5 | 22 | # (D. Tschumperle, R. Deriche). |
philpem@5 | 23 | # IEEE Transactions on Pattern Analysis and Machine Intelligence, |
philpem@5 | 24 | # Vol 27, No 4, pp 506-517, April 2005. |
philpem@5 | 25 | # |
philpem@5 | 26 | # Copyright : Grzegorz Szwoch (Original GIMP plugin code) |
philpem@5 | 27 | # David Tschumperle (GREYCstoration API) |
philpem@5 | 28 | # Nikita Melnichenko (Bugs corrections) |
philpem@5 | 29 | # Phillip Wood (Contribution) |
philpem@5 | 30 | # |
philpem@5 | 31 | # Plug-in version: 1.1 |
philpem@5 | 32 | # Version history: |
philpem@5 | 33 | # 2008.12.05 |
philpem@5 | 34 | # - Support for denoising in YCrCb color space (patch by Phillip Wood) |
philpem@5 | 35 | # 2.9 (2008.06.09) |
philpem@5 | 36 | # - New version number, following the release number of CImg. |
philpem@5 | 37 | # - Non-interactive mode allowed (patch by Nikita Melnichenko). |
philpem@5 | 38 | # - Pdb description parameters re-ordered (patch by Nikita Melnichenko). |
philpem@5 | 39 | # - Bug correction when dealing with 16 bits image processed in the |
philpem@5 | 40 | # YUV color space. |
philpem@5 | 41 | # 1.1 (2007.03.31) |
philpem@5 | 42 | # - Added support for GimpZoomPreview (optional) |
philpem@5 | 43 | # - Make plug-in work for 1 bpp images |
philpem@5 | 44 | # - Added button to reset parameters to the initial state |
philpem@5 | 45 | # 1.0 (2007.03.09) |
philpem@5 | 46 | # - Initial release |
philpem@5 | 47 | # |
philpem@5 | 48 | # License : CeCILL v2.0 |
philpem@5 | 49 | # ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html ) |
philpem@5 | 50 | # |
philpem@5 | 51 | # This software is governed by the CeCILL license under French law and |
philpem@5 | 52 | # abiding by the rules of distribution of free software. You can use, |
philpem@5 | 53 | # modify and/ or redistribute the software under the terms of the CeCILL |
philpem@5 | 54 | # license as circulated by CEA, CNRS and INRIA at the following URL |
philpem@5 | 55 | # "http://www.cecill.info". |
philpem@5 | 56 | # |
philpem@5 | 57 | # As a counterpart to the access to the source code and rights to copy, |
philpem@5 | 58 | # modify and redistribute granted by the license, users are provided only |
philpem@5 | 59 | # with a limited warranty and the software's author, the holder of the |
philpem@5 | 60 | # economic rights, and the successive licensors have only limited |
philpem@5 | 61 | # liability. |
philpem@5 | 62 | # |
philpem@5 | 63 | # In this respect, the user's attention is drawn to the risks associated |
philpem@5 | 64 | # with loading, using, modifying and/or developing or reproducing the |
philpem@5 | 65 | # software by the user in light of its specific status of free software, |
philpem@5 | 66 | # that may mean that it is complicated to manipulate, and that also |
philpem@5 | 67 | # therefore means that it is reserved for developers and experienced |
philpem@5 | 68 | # professionals having in-depth computer knowledge. Users are therefore |
philpem@5 | 69 | # encouraged to load and test the software's suitability as regards their |
philpem@5 | 70 | # requirements in conditions enabling the security of their systems and/or |
philpem@5 | 71 | # data to be ensured and, more generally, to use and operate it in the |
philpem@5 | 72 | # same conditions as regards security. |
philpem@5 | 73 | # |
philpem@5 | 74 | # The fact that you are presently reading this means that you have had |
philpem@5 | 75 | # knowledge of the CeCILL license and that you accept its terms. |
philpem@5 | 76 | # |
philpem@5 | 77 | */ |
philpem@5 | 78 | |
philpem@5 | 79 | /* HOW TO COMPILE THIS PLUG-IN ? |
philpem@5 | 80 | *------------------------------ |
philpem@5 | 81 | * g++ -o greycstoration4gimp greycstoration4gimp.cpp `gimptool-2.0 --cflags` `gimptool-2.0 --libs` -lpthread -O3 |
philpem@5 | 82 | * Then, copy the file 'greycstoration4gimp' into your GIMP plug-in directory. |
philpem@5 | 83 | */ |
philpem@5 | 84 | |
philpem@5 | 85 | //---------------------------------- |
philpem@5 | 86 | // Define static plug-in parameters |
philpem@5 | 87 | //---------------------------------- |
philpem@5 | 88 | |
philpem@5 | 89 | // Comment the line below if you don't want to use preview with zoom (zoom feature needs GIMP >= 2.3.4) |
philpem@5 | 90 | #define ZOOMPREVIEW |
philpem@5 | 91 | // Uncomment this line to get a rough estimate of how long the plug-in takes to run |
philpem@5 | 92 | // #define TIMER |
philpem@5 | 93 | |
philpem@5 | 94 | // Size of image tiles (in {0, 256, 512, 1024, 2048}) |
philpem@5 | 95 | #define TILESIZE 256 |
philpem@5 | 96 | |
philpem@5 | 97 | // Size of tile borders (in [0-16]). |
philpem@5 | 98 | #define TILEBORDER 4 |
philpem@5 | 99 | |
philpem@5 | 100 | // Number of simultaneous computation threads (in [1-16]). |
philpem@5 | 101 | // Note : GREYCstoration multi-threading is HIGHLY experimental and may not work on your |
philpem@5 | 102 | // computer. Please use it only if you checked that all is working correctly ! |
philpem@5 | 103 | #define NTHREADS 1 |
philpem@5 | 104 | |
philpem@5 | 105 | //----------------------------------------------------------------------- |
philpem@5 | 106 | // Include necessary headers for GIMP, GTK and CImg + GREYCstoration API |
philpem@5 | 107 | //----------------------------------------------------------------------- |
philpem@5 | 108 | #if cimg_OS!=2 |
philpem@5 | 109 | #include <pthread.h> |
philpem@5 | 110 | #endif |
philpem@5 | 111 | #define cimg_plugin "plugins/greycstoration.h" |
philpem@5 | 112 | #define cimg_display_type 0 |
philpem@5 | 113 | #include <gtk/gtk.h> |
philpem@5 | 114 | #include <libgimp/gimp.h> |
philpem@5 | 115 | #include <libgimp/gimpui.h> |
philpem@5 | 116 | #include "plugins/../CImg.h" |
philpem@5 | 117 | using namespace cimg_library; |
philpem@5 | 118 | |
philpem@5 | 119 | //---------------------------------------------------------- |
philpem@5 | 120 | // Define algorithm parameters structure and default values |
philpem@5 | 121 | //---------------------------------------------------------- |
philpem@5 | 122 | struct Parameters { |
philpem@5 | 123 | bool patch_based; // Select patch-based or non-patch method |
philpem@5 | 124 | |
philpem@5 | 125 | // Parameters for patch-based method |
philpem@5 | 126 | gint patch_size; // Size of the patches |
philpem@5 | 127 | gdouble sigma_p; // Sigma_p |
philpem@5 | 128 | gdouble sigma_s; // Sigma_s |
philpem@5 | 129 | gint lookup_size; // Lookup size |
philpem@5 | 130 | |
philpem@5 | 131 | // Parameters for non-patch method |
philpem@5 | 132 | gdouble amplitude; // Regularization amplitude |
philpem@5 | 133 | gdouble sharpness; // Contour preservation for regularization (sharpness) |
philpem@5 | 134 | gdouble anisotropy; // Regularization anisotropy |
philpem@5 | 135 | gdouble alpha; // Noise scale |
philpem@5 | 136 | gdouble sigma; // Geometry regularity |
philpem@5 | 137 | gdouble dl; // Spatial integration step for regularization |
philpem@5 | 138 | gdouble da; // Angular integration step for regulatization |
philpem@5 | 139 | gdouble gauss_prec; // Precision of the gaussian function for regularization |
philpem@5 | 140 | gint interp; // Interpolation type |
philpem@5 | 141 | bool fast_approx; // Use fast approximation for regularization |
philpem@5 | 142 | gint channels; // Which channels to process |
philpem@5 | 143 | gint iterations; // Number of regularization iterations |
philpem@5 | 144 | gboolean update_preview; |
philpem@5 | 145 | }; |
philpem@5 | 146 | |
philpem@5 | 147 | const Parameters defaults_parameters = { |
philpem@5 | 148 | false, // patch_based |
philpem@5 | 149 | 4, // patch_size |
philpem@5 | 150 | 10.0f, // sigma_p |
philpem@5 | 151 | 15.0f, // sigma_s |
philpem@5 | 152 | 7, // Lookup size |
philpem@5 | 153 | 60.0, // amplitude |
philpem@5 | 154 | 0.7, // sharpness |
philpem@5 | 155 | 0.3, // anisotropy |
philpem@5 | 156 | 0.6, // alpha |
philpem@5 | 157 | 1.1, // sigma |
philpem@5 | 158 | 0.8, // dl |
philpem@5 | 159 | 30.0, // da |
philpem@5 | 160 | 2.0, // gauss_prec |
philpem@5 | 161 | 0, // interp |
philpem@5 | 162 | true, // fast_approx |
philpem@5 | 163 | 0, // process RGB channels |
philpem@5 | 164 | 1, // iterations |
philpem@5 | 165 | true // default is to update the preview |
philpem@5 | 166 | }; |
philpem@5 | 167 | |
philpem@5 | 168 | const gint nb_parameters = 20; // Number of parameters + 2 |
philpem@5 | 169 | |
philpem@5 | 170 | //--------------------------- |
philpem@5 | 171 | // GIMP plug-in declarations |
philpem@5 | 172 | //--------------------------- |
philpem@5 | 173 | typedef struct { |
philpem@5 | 174 | gboolean run; |
philpem@5 | 175 | } Interface; |
philpem@5 | 176 | |
philpem@5 | 177 | // Plug-in functions |
philpem@5 | 178 | static void query(void); |
philpem@5 | 179 | static void run(const gchar*name, gint nparams, const GimpParam *param, gint *nreturn_vals, GimpParam **return_vals); |
philpem@5 | 180 | static void process(GimpPixelRgn *srcPTR, GimpPixelRgn *dstPTR, gint bytes, gint x1, gint x2, gint y1, gint y2, gboolean show_progress); |
philpem@5 | 181 | static void callback_response(GtkWidget *widget, gint response_id, gpointer data); |
philpem@5 | 182 | static void run_greycstoration(CImg<unsigned char>& img, const gboolean show_progress); |
philpem@5 | 183 | static gboolean dialog(GimpDrawable *drawable); |
philpem@5 | 184 | static void update_preview(GimpPreview *preview); |
philpem@5 | 185 | |
philpem@5 | 186 | // Plug-in global variables |
philpem@5 | 187 | static gboolean runflag = FALSE; |
philpem@5 | 188 | static Parameters params = defaults_parameters; |
philpem@5 | 189 | GtkWidget *preview; |
philpem@5 | 190 | GtkObject* adj_amplitude; |
philpem@5 | 191 | GtkObject* adj_sharpness; |
philpem@5 | 192 | GtkObject* adj_anisotropy; |
philpem@5 | 193 | GtkObject* adj_alpha; |
philpem@5 | 194 | GtkObject* adj_sigma; |
philpem@5 | 195 | GtkObject* adj_dl; |
philpem@5 | 196 | GtkObject* adj_da; |
philpem@5 | 197 | GtkObject* adj_iterations; |
philpem@5 | 198 | GtkObject* adj_patch_size; |
philpem@5 | 199 | GtkObject* adj_sigma_s; |
philpem@5 | 200 | GtkObject* adj_sigma_p; |
philpem@5 | 201 | GtkObject* adj_lookup_size; |
philpem@5 | 202 | GtkWidget* combo_interp; |
philpem@5 | 203 | GtkWidget* combo_channels; |
philpem@5 | 204 | GtkWidget* button_fast_approx; |
philpem@5 | 205 | GtkWidget* button_patch_based; |
philpem@5 | 206 | CImg<unsigned char> img; |
philpem@5 | 207 | |
philpem@5 | 208 | // Specific GIMP stuffs. |
philpem@5 | 209 | GimpPlugInInfo PLUG_IN_INFO = { 0,0,query,run }; // { init_proc, quit_proc, query_proc, run_proc } |
philpem@5 | 210 | MAIN () |
philpem@5 | 211 | static void query(void) { |
philpem@5 | 212 | static GimpParamDef args[] = { |
philpem@5 | 213 | {GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"}, |
philpem@5 | 214 | {GIMP_PDB_IMAGE, "image", "(unused)"}, |
philpem@5 | 215 | {GIMP_PDB_DRAWABLE, "drawable", "Drawable to draw on"}, |
philpem@5 | 216 | {GIMP_PDB_FLOAT, "amplitude", "Regularization strength for one iteration"}, |
philpem@5 | 217 | {GIMP_PDB_FLOAT, "sharpness", "Contour preservation for regularization"}, |
philpem@5 | 218 | {GIMP_PDB_FLOAT, "anisotropy", "Regularization anisotropy"}, |
philpem@5 | 219 | {GIMP_PDB_FLOAT, "alpha", "Noise scale"}, |
philpem@5 | 220 | {GIMP_PDB_FLOAT, "sigma", "Geometry regularity"} , |
philpem@5 | 221 | {GIMP_PDB_FLOAT, "dl", "Spatial integration step for regularization"} , |
philpem@5 | 222 | {GIMP_PDB_FLOAT, "da", "Angular integration step for regulatization"}, |
philpem@5 | 223 | {GIMP_PDB_FLOAT, "gauss_prec", "Precision of the gaussian function for regularization"}, |
philpem@5 | 224 | {GIMP_PDB_INT8, "interp", "Interpolation type"}, |
philpem@5 | 225 | {GIMP_PDB_INT32, "patch_based", "Use patch-based intead of non-patch method"}, |
philpem@5 | 226 | {GIMP_PDB_INT32, "patch_size", "Size of the patches (for patch-based method)"}, |
philpem@5 | 227 | {GIMP_PDB_FLOAT, "sigma_p", "Sigma_p (for patch-based method)"}, |
philpem@5 | 228 | {GIMP_PDB_FLOAT, "sigma_s", "Sigma_s (for patch-based method)"}, |
philpem@5 | 229 | {GIMP_PDB_INT32, "lookup_size", "Lookup size (for patch-based method)"}, |
philpem@5 | 230 | {GIMP_PDB_INT32, "fast_approx", "Use fast approximation for regularization"}, |
philpem@5 | 231 | {GIMP_PDB_INT32, "channels", "Channels to process"}, |
philpem@5 | 232 | {GIMP_PDB_INT32, "iterations", "Iterations accuracy"} |
philpem@5 | 233 | }; |
philpem@5 | 234 | gimp_install_procedure ("plug_in_greycstoration", |
philpem@5 | 235 | "GREYCstoration Denoising Plugin", |
philpem@5 | 236 | "GREYCstoration is an image regularization algorithm which is able to process" |
philpem@5 | 237 | " a color image by locally removing small variations of pixel intensities" |
philpem@5 | 238 | " while preserving significant global image features, such as edges and corners." |
philpem@5 | 239 | " This plugin uses image regularization for image denoising.", |
philpem@5 | 240 | "Grzegorz Szwoch & David Tschumperle", |
philpem@5 | 241 | "Grzegorz Szwoch & David Tschumperle", |
philpem@5 | 242 | "2008-06-02", |
philpem@5 | 243 | "_GREYCstoration...", |
philpem@5 | 244 | "RGB*, GRAY*", |
philpem@5 | 245 | GIMP_PLUGIN,G_N_ELEMENTS(args),0,args, NULL); |
philpem@5 | 246 | gimp_plugin_menu_register ("plug_in_greycstoration", "<Image>/Filters/Enhance"); |
philpem@5 | 247 | } |
philpem@5 | 248 | |
philpem@5 | 249 | //------------------------------ |
philpem@5 | 250 | // GIMP plug-in 'run' function |
philpem@5 | 251 | //------------------------------ |
philpem@5 | 252 | static void run(const gchar *name, gint nparams, const GimpParam *param, gint *nreturn_vals, GimpParam **return_vals) { |
philpem@5 | 253 | name = 0; |
philpem@5 | 254 | static GimpParam values[1]; |
philpem@5 | 255 | GimpPDBStatusType status = GIMP_PDB_SUCCESS; |
philpem@5 | 256 | GimpDrawable *drawable; |
philpem@5 | 257 | GimpRunMode run_mode; |
philpem@5 | 258 | #ifdef TIMER |
philpem@5 | 259 | GTimer *timer = g_timer_new (); |
philpem@5 | 260 | #endif |
philpem@5 | 261 | run_mode = (GimpRunMode)param[0].data.d_int32; |
philpem@5 | 262 | *return_vals = values; |
philpem@5 | 263 | *nreturn_vals = 1; |
philpem@5 | 264 | values[0].type = GIMP_PDB_STATUS; |
philpem@5 | 265 | values[0].data.d_status = status; |
philpem@5 | 266 | //INIT_I18N (); |
philpem@5 | 267 | |
philpem@5 | 268 | // Get drawable information |
philpem@5 | 269 | drawable = gimp_drawable_get(param[2].data.d_drawable); |
philpem@5 | 270 | |
philpem@5 | 271 | // Make tile cache |
philpem@5 | 272 | gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1)); |
philpem@5 | 273 | |
philpem@5 | 274 | switch (run_mode) { |
philpem@5 | 275 | case GIMP_RUN_INTERACTIVE: |
philpem@5 | 276 | gimp_get_data ("plug_in_greycstoration", ¶ms); // Reset default values show preview unmodified |
philpem@5 | 277 | if (!dialog(drawable)) return; |
philpem@5 | 278 | break; |
philpem@5 | 279 | case GIMP_RUN_NONINTERACTIVE: |
philpem@5 | 280 | if (nparams != nb_parameters) { status = GIMP_PDB_CALLING_ERROR; } |
philpem@5 | 281 | else { |
philpem@5 | 282 | params.amplitude = param[3].data.d_float; |
philpem@5 | 283 | params.sharpness = param[4].data.d_float; |
philpem@5 | 284 | params.anisotropy = param[5].data.d_float; |
philpem@5 | 285 | params.alpha = param[6].data.d_float; |
philpem@5 | 286 | params.sigma = param[7].data.d_float; |
philpem@5 | 287 | params.dl = param[8].data.d_float; |
philpem@5 | 288 | params.da = param[9].data.d_float; |
philpem@5 | 289 | params.gauss_prec = param[10].data.d_float; |
philpem@5 | 290 | params.interp = param[11].data.d_int32; |
philpem@5 | 291 | params.patch_based = param[12].data.d_int32; |
philpem@5 | 292 | params.patch_size = param[13].data.d_int32; |
philpem@5 | 293 | params.sigma_p = param[14].data.d_float; |
philpem@5 | 294 | params.sigma_s = param[15].data.d_float; |
philpem@5 | 295 | params.lookup_size = param[16].data.d_int32; |
philpem@5 | 296 | params.fast_approx = param[17].data.d_int32; |
philpem@5 | 297 | params.channels = param[18].data.d_int32; |
philpem@5 | 298 | params.iterations = param[19].data.d_int32; |
philpem@5 | 299 | if((params.amplitude<0.0) || (params.sharpness<0.0)) status = GIMP_PDB_CALLING_ERROR; |
philpem@5 | 300 | } |
philpem@5 | 301 | break; |
philpem@5 | 302 | case GIMP_RUN_WITH_LAST_VALS: |
philpem@5 | 303 | gimp_get_data ("plug_in_greycstoration", ¶ms); |
philpem@5 | 304 | break; |
philpem@5 | 305 | default: |
philpem@5 | 306 | break; |
philpem@5 | 307 | } |
philpem@5 | 308 | |
philpem@5 | 309 | if(status==GIMP_PDB_SUCCESS) { |
philpem@5 | 310 | drawable = gimp_drawable_get(param[2].data.d_drawable); |
philpem@5 | 311 | |
philpem@5 | 312 | // Process image |
philpem@5 | 313 | GimpPixelRgn srcPR, destPR; |
philpem@5 | 314 | gint x1, y1, x2, y2; |
philpem@5 | 315 | |
philpem@5 | 316 | // Initialize pixel regions |
philpem@5 | 317 | gimp_pixel_rgn_init(&srcPR,drawable,0,0,drawable->width,drawable->height,false,false); |
philpem@5 | 318 | gimp_pixel_rgn_init(&destPR,drawable,0,0,drawable->width,drawable->height,true,true); |
philpem@5 | 319 | |
philpem@5 | 320 | // Get the input |
philpem@5 | 321 | gimp_drawable_mask_bounds(drawable->drawable_id,&x1,&y1,&x2,&y2); |
philpem@5 | 322 | |
philpem@5 | 323 | // Process region |
philpem@5 | 324 | process(&srcPR,&destPR,drawable->bpp,x1,x2,y1,y2,true); |
philpem@5 | 325 | |
philpem@5 | 326 | // Update image and clean |
philpem@5 | 327 | gimp_drawable_flush(drawable); |
philpem@5 | 328 | gimp_drawable_merge_shadow(drawable->drawable_id,true); |
philpem@5 | 329 | gimp_drawable_update(drawable->drawable_id,x1,y1,x2-x1,y2-y1); |
philpem@5 | 330 | gimp_displays_flush(); |
philpem@5 | 331 | |
philpem@5 | 332 | // Set data for next use of filter |
philpem@5 | 333 | gimp_set_data("plug_in_greycstoration",¶ms,sizeof(Parameters)); |
philpem@5 | 334 | gimp_drawable_detach(drawable); |
philpem@5 | 335 | values[0].data.d_status = status; |
philpem@5 | 336 | } |
philpem@5 | 337 | |
philpem@5 | 338 | #ifdef TIMER |
philpem@5 | 339 | g_printerr("%f seconds\n",g_timer_elapsed(timer,0)); |
philpem@5 | 340 | g_timer_destroy(timer); |
philpem@5 | 341 | #endif |
philpem@5 | 342 | } |
philpem@5 | 343 | |
philpem@5 | 344 | //----------------------------------- |
philpem@5 | 345 | // GIMP plug-in 'process' function |
philpem@5 | 346 | //----------------------------------- |
philpem@5 | 347 | static void process(GimpPixelRgn *srcPR, GimpPixelRgn *destPR, gint bytes, gint x1, gint x2, gint y1, gint y2, gboolean show_progress) { |
philpem@5 | 348 | gint width = x2 - x1; |
philpem@5 | 349 | gint height = y2 - y1; |
philpem@5 | 350 | guchar* row, *row_ptr; |
philpem@5 | 351 | if (show_progress) gimp_progress_init("GREYCstoration Filter..."); |
philpem@5 | 352 | |
philpem@5 | 353 | // Make CImg instance and fill it with image information |
philpem@5 | 354 | const gint channels = (bytes<3)?1:3; |
philpem@5 | 355 | img.assign(width,height,1,channels,0); |
philpem@5 | 356 | row = g_new(guchar,width*bytes); |
philpem@5 | 357 | cimg_forY(img,y) { |
philpem@5 | 358 | gimp_pixel_rgn_get_row(srcPR,row,x1,y1+y,width); |
philpem@5 | 359 | row_ptr = row; |
philpem@5 | 360 | cimg_forX(img,x) { cimg_forV(img,k) img(x,y,k) = row_ptr[k]; row_ptr+=bytes; } |
philpem@5 | 361 | } |
philpem@5 | 362 | |
philpem@5 | 363 | // run GREYCstoration processing |
philpem@5 | 364 | run_greycstoration(img,show_progress); |
philpem@5 | 365 | |
philpem@5 | 366 | // Write processed image |
philpem@5 | 367 | cimg_forY(img,y) { |
philpem@5 | 368 | gimp_pixel_rgn_get_row(srcPR,row,x1,y1+y,width); |
philpem@5 | 369 | row_ptr = row; |
philpem@5 | 370 | cimg_forX(img,x) { cimg_forV(img,k) row_ptr[k] = img(x,y,k); row_ptr+=bytes; } |
philpem@5 | 371 | gimp_pixel_rgn_set_row(destPR,row,x1,y1+y,width); |
philpem@5 | 372 | } |
philpem@5 | 373 | g_free(row); |
philpem@5 | 374 | } |
philpem@5 | 375 | |
philpem@5 | 376 | //----------------------------------------- |
philpem@5 | 377 | // Run GREYCstoration process on the image |
philpem@5 | 378 | //----------------------------------------- |
philpem@5 | 379 | static void run_greycstoration(CImg<unsigned char>& img, const gboolean show_progress) { |
philpem@5 | 380 | guint crange_beg=0, crange_end = img.dimv()-1U; |
philpem@5 | 381 | if (params.channels && img.dimv() > 1) { // Set up colour model and channel options |
philpem@5 | 382 | img.RGBtoYCbCr(); |
philpem@5 | 383 | if (params.channels == 1) { |
philpem@5 | 384 | crange_beg=1; |
philpem@5 | 385 | } else { |
philpem@5 | 386 | crange_end=0; |
philpem@5 | 387 | } |
philpem@5 | 388 | } |
philpem@5 | 389 | CImg<unsigned char> img_range = img.get_shared_channels(crange_beg, crange_end); |
philpem@5 | 390 | |
philpem@5 | 391 | for (gint iter=0; iter<params.iterations; ++iter) { |
philpem@5 | 392 | if (params.patch_based) img_range.greycstoration_patch_run(params.patch_size, |
philpem@5 | 393 | params.sigma_p, |
philpem@5 | 394 | params.sigma_s, |
philpem@5 | 395 | params.lookup_size, |
philpem@5 | 396 | params.fast_approx, |
philpem@5 | 397 | show_progress?TILESIZE:0, |
philpem@5 | 398 | TILEBORDER, |
philpem@5 | 399 | show_progress?NTHREADS:1); |
philpem@5 | 400 | else img_range.greycstoration_run(params.amplitude, |
philpem@5 | 401 | params.sharpness, |
philpem@5 | 402 | params.anisotropy, |
philpem@5 | 403 | params.alpha, |
philpem@5 | 404 | params.sigma, |
philpem@5 | 405 | 1.0f, |
philpem@5 | 406 | params.dl, |
philpem@5 | 407 | params.da, |
philpem@5 | 408 | params.gauss_prec, |
philpem@5 | 409 | params.interp, |
philpem@5 | 410 | params.fast_approx, |
philpem@5 | 411 | show_progress?TILESIZE:0, |
philpem@5 | 412 | TILEBORDER, |
philpem@5 | 413 | show_progress?NTHREADS:1); |
philpem@5 | 414 | gint tick = 0; |
philpem@5 | 415 | do { |
philpem@5 | 416 | cimg::wait(100); |
philpem@5 | 417 | ++tick; |
philpem@5 | 418 | if (tick==10 && show_progress) { // Update progress bar |
philpem@5 | 419 | const float pr_iteration = img_range.greycstoration_progress(); |
philpem@5 | 420 | const unsigned int pr_global = (unsigned int)((iter*100 + pr_iteration) / params.iterations); |
philpem@5 | 421 | gimp_progress_update(pr_global/100.0); |
philpem@5 | 422 | tick = 0; |
philpem@5 | 423 | } |
philpem@5 | 424 | } while (img_range.greycstoration_is_running()); |
philpem@5 | 425 | } |
philpem@5 | 426 | if (params.channels && img.dimv() > 1) { // Convert back to RGB if required |
philpem@5 | 427 | img.YCbCrtoRGB(); |
philpem@5 | 428 | } |
philpem@5 | 429 | } |
philpem@5 | 430 | |
philpem@5 | 431 | //---------------------- |
philpem@5 | 432 | // Update image preview |
philpem@5 | 433 | //---------------------- |
philpem@5 | 434 | static void update_preview(GimpPreview *preview) { |
philpem@5 | 435 | #ifdef ZOOMPREVIEW |
philpem@5 | 436 | // Zoomable style preview |
philpem@5 | 437 | //------------------------- |
philpem@5 | 438 | gint width, height, bytes; |
philpem@5 | 439 | guchar *src, *row_ptr; |
philpem@5 | 440 | if (img.greycstoration_is_running()) img.greycstoration_stop(); |
philpem@5 | 441 | src = gimp_zoom_preview_get_source(GIMP_ZOOM_PREVIEW(preview),&width,&height,&bytes); |
philpem@5 | 442 | const gint channels = (bytes<3)?1:3; |
philpem@5 | 443 | img.assign(width,height,1,channels,0); |
philpem@5 | 444 | row_ptr = src; |
philpem@5 | 445 | cimg_forY(img,y) { cimg_forX(img,x) { cimg_forV(img,k) img(x,y,k) = row_ptr[k]; row_ptr += bytes; }} |
philpem@5 | 446 | run_greycstoration(img,false); |
philpem@5 | 447 | row_ptr = src; |
philpem@5 | 448 | cimg_forY(img,y) { cimg_forX(img,x) { cimg_forV(img,k) row_ptr[k] = img(x,y,k); row_ptr += bytes; }} |
philpem@5 | 449 | gimp_preview_draw_buffer(preview,src,width*bytes); |
philpem@5 | 450 | g_free(src); |
philpem@5 | 451 | |
philpem@5 | 452 | #else |
philpem@5 | 453 | // Old style preview (without zoom) |
philpem@5 | 454 | //---------------------------------- |
philpem@5 | 455 | GimpDrawable *drawable; |
philpem@5 | 456 | gint x, y, width, height; |
philpem@5 | 457 | GimpPixelRgn srcPR, destPR; |
philpem@5 | 458 | drawable = gimp_drawable_preview_get_drawable(GIMP_DRAWABLE_PREVIEW(preview)); |
philpem@5 | 459 | gimp_pixel_rgn_init(&srcPR,drawable,0,0,drawable->width,drawable->height,false,false); |
philpem@5 | 460 | gimp_pixel_rgn_init(&destPR,drawable,0,0,drawable->width,drawable->height,true,true); |
philpem@5 | 461 | gimp_preview_get_position(preview,&x,&y); |
philpem@5 | 462 | gimp_preview_get_size(preview,&width,&height); |
philpem@5 | 463 | if(img.greycstoration_is_running()) img.greycstoration_stop(); |
philpem@5 | 464 | process(&srcPR,&destPR,drawable->bpp,x,x+width,y,y+height,false); |
philpem@5 | 465 | gimp_pixel_rgn_init(&destPR,drawable,x,y,width,height,false,true); |
philpem@5 | 466 | gimp_drawable_preview_draw_region(GIMP_DRAWABLE_PREVIEW(preview),&destPR); |
philpem@5 | 467 | #endif |
philpem@5 | 468 | } |
philpem@5 | 469 | |
philpem@5 | 470 | //---------------------- |
philpem@5 | 471 | // Define dialog window |
philpem@5 | 472 | //---------------------- |
philpem@5 | 473 | static gboolean dialog (GimpDrawable *drawable) { |
philpem@5 | 474 | GtkWidget *dialog; |
philpem@5 | 475 | GtkWidget *main_hbox; |
philpem@5 | 476 | GtkWidget *table; |
philpem@5 | 477 | |
philpem@5 | 478 | #define SCALE_WIDTH 150 |
philpem@5 | 479 | #define ENTRY_WIDTH 4 |
philpem@5 | 480 | #define RESPONSE_RESET 1 |
philpem@5 | 481 | |
philpem@5 | 482 | gimp_ui_init("greycstoration",true); |
philpem@5 | 483 | runflag = false; |
philpem@5 | 484 | dialog = gimp_dialog_new("GREYCstoration", "greycstoration",0,(GtkDialogFlags)0,gimp_standard_help_func,"plug-in-greycstoration", |
philpem@5 | 485 | GIMP_STOCK_RESET,RESPONSE_RESET,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OK,GTK_RESPONSE_OK,NULL); |
philpem@5 | 486 | gtk_dialog_set_alternative_button_order(GTK_DIALOG(dialog),RESPONSE_RESET,GTK_RESPONSE_OK,GTK_RESPONSE_CANCEL,-1); |
philpem@5 | 487 | |
philpem@5 | 488 | #ifdef ZOOMPREVIEW |
philpem@5 | 489 | gimp_window_set_transient(GTK_WINDOW (dialog)); |
philpem@5 | 490 | #endif |
philpem@5 | 491 | |
philpem@5 | 492 | g_signal_connect(dialog,"response",G_CALLBACK(callback_response),preview); |
philpem@5 | 493 | g_signal_connect(dialog, "destroy",G_CALLBACK(gtk_main_quit),0); |
philpem@5 | 494 | |
philpem@5 | 495 | main_hbox = gtk_hbox_new(false,12); |
philpem@5 | 496 | gtk_container_set_border_width(GTK_CONTAINER(main_hbox),12); |
philpem@5 | 497 | gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox),main_hbox); |
philpem@5 | 498 | gtk_widget_show(main_hbox); |
philpem@5 | 499 | |
philpem@5 | 500 | #ifdef ZOOMPREVIEW |
philpem@5 | 501 | preview = gimp_zoom_preview_new(drawable); |
philpem@5 | 502 | #else |
philpem@5 | 503 | preview = gimp_drawable_preview_new(drawable,¶ms.update_preview); |
philpem@5 | 504 | #endif |
philpem@5 | 505 | gtk_box_pack_start(GTK_BOX(main_hbox),preview,true,true,0); |
philpem@5 | 506 | gtk_widget_show(preview); |
philpem@5 | 507 | g_signal_connect(preview,"invalidated",G_CALLBACK(update_preview),0); |
philpem@5 | 508 | |
philpem@5 | 509 | table = gtk_table_new(3,3,false); |
philpem@5 | 510 | gtk_table_set_col_spacings(GTK_TABLE(table),6); |
philpem@5 | 511 | gtk_table_set_row_spacings(GTK_TABLE(table),6); |
philpem@5 | 512 | gtk_box_pack_start(GTK_BOX(main_hbox),table,false,false,0); |
philpem@5 | 513 | gtk_widget_show(table); |
philpem@5 | 514 | |
philpem@5 | 515 | // 'Amplitude' slider |
philpem@5 | 516 | adj_amplitude = gimp_scale_entry_new(GTK_TABLE(table),0,0,"_Strength :",SCALE_WIDTH,ENTRY_WIDTH, |
philpem@5 | 517 | params.amplitude,0.0,200.0,1,10,1,true,0,0,0,0); |
philpem@5 | 518 | g_signal_connect(adj_amplitude,"value_changed",G_CALLBACK(gimp_double_adjustment_update),¶ms.amplitude); |
philpem@5 | 519 | g_signal_connect_swapped(adj_amplitude,"value_changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 520 | |
philpem@5 | 521 | // 'Sharpness' slider |
philpem@5 | 522 | adj_sharpness = gimp_scale_entry_new(GTK_TABLE(table),0,1,"Contour preser_vation :",SCALE_WIDTH,ENTRY_WIDTH, |
philpem@5 | 523 | params.sharpness,0.0,5.0,0.05,0.5,2,true,0,0,0,0); |
philpem@5 | 524 | g_signal_connect(adj_sharpness,"value_changed",G_CALLBACK(gimp_double_adjustment_update),¶ms.sharpness); |
philpem@5 | 525 | g_signal_connect_swapped(adj_sharpness,"value_changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 526 | |
philpem@5 | 527 | // 'Anisotropy' slider |
philpem@5 | 528 | adj_anisotropy = gimp_scale_entry_new(GTK_TABLE(table),0,2,"_Anisotropy :",SCALE_WIDTH,ENTRY_WIDTH, |
philpem@5 | 529 | params.anisotropy,0.0,1.0,0.05,0.5,2,true,0,0,0,0); |
philpem@5 | 530 | g_signal_connect(adj_anisotropy,"value_changed",G_CALLBACK(gimp_double_adjustment_update),¶ms.anisotropy); |
philpem@5 | 531 | g_signal_connect_swapped(adj_anisotropy,"value_changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 532 | |
philpem@5 | 533 | // 'Alpha' slider |
philpem@5 | 534 | adj_alpha = gimp_scale_entry_new(GTK_TABLE(table),0,3,"_Noise scale :",SCALE_WIDTH,ENTRY_WIDTH, |
philpem@5 | 535 | params.alpha,0.0,16.0,0.1,0.5, 1,true,0,0,0,0); |
philpem@5 | 536 | g_signal_connect(adj_alpha,"value_changed",G_CALLBACK(gimp_double_adjustment_update),¶ms.alpha); |
philpem@5 | 537 | g_signal_connect_swapped(adj_alpha,"value_changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 538 | |
philpem@5 | 539 | // 'Sigma' slider |
philpem@5 | 540 | adj_sigma = gimp_scale_entry_new(GTK_TABLE(table),0,4,"Geometry _regularity :",SCALE_WIDTH,ENTRY_WIDTH, |
philpem@5 | 541 | params.sigma,0,8.0,0.1,0.5,2,true,0,0,0,0); |
philpem@5 | 542 | g_signal_connect(adj_sigma,"value_changed",G_CALLBACK(gimp_double_adjustment_update),¶ms.sigma); |
philpem@5 | 543 | g_signal_connect_swapped(adj_sigma,"value_changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 544 | |
philpem@5 | 545 | // 'Spatial step' slider |
philpem@5 | 546 | adj_dl = gimp_scale_entry_new(GTK_TABLE (table),0,5,"Spatial step :",SCALE_WIDTH,ENTRY_WIDTH, |
philpem@5 | 547 | params.dl,0.1,1.0,0.01,0.1,2,true,0,0,0,0); |
philpem@5 | 548 | g_signal_connect(adj_dl,"value_changed",G_CALLBACK(gimp_double_adjustment_update),¶ms.dl); |
philpem@5 | 549 | g_signal_connect_swapped(adj_dl,"value_changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 550 | |
philpem@5 | 551 | // 'Angular step' slider |
philpem@5 | 552 | adj_da = gimp_scale_entry_new(GTK_TABLE(table),0,6,"Angu_lar step :",SCALE_WIDTH,ENTRY_WIDTH, |
philpem@5 | 553 | params.da,1.0,90.0,1.0,10.0,1,true,0,0,0,0); |
philpem@5 | 554 | g_signal_connect(adj_da,"value_changed",G_CALLBACK(gimp_double_adjustment_update),¶ms.da); |
philpem@5 | 555 | g_signal_connect_swapped(adj_da,"value_changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 556 | |
philpem@5 | 557 | // 'Interpolation' choice |
philpem@5 | 558 | combo_interp = gimp_int_combo_box_new("Nearest neighbor",0,"Linear",1,"Runge-Kutta",2,NULL); |
philpem@5 | 559 | gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(combo_interp),params.interp); |
philpem@5 | 560 | gimp_table_attach_aligned(GTK_TABLE(table),0,8,"Interpolation _type :",0.0,0.5,combo_interp,2,false); |
philpem@5 | 561 | g_signal_connect(combo_interp,"changed",G_CALLBACK(gimp_int_combo_box_get_active),¶ms.interp); |
philpem@5 | 562 | g_signal_connect_swapped(combo_interp,"changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 563 | |
philpem@5 | 564 | // 'Patch-based' button |
philpem@5 | 565 | button_patch_based = gtk_check_button_new_with_mnemonic("_Patch-based"); |
philpem@5 | 566 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_patch_based),params.patch_based); |
philpem@5 | 567 | gimp_table_attach_aligned(GTK_TABLE(table),0,9,"Patch-based :",0.0,0.5,button_patch_based,2,false); |
philpem@5 | 568 | g_signal_connect(button_patch_based,"toggled",G_CALLBACK(gimp_toggle_button_update),¶ms.patch_based); |
philpem@5 | 569 | g_signal_connect_swapped(button_patch_based,"toggled",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 570 | |
philpem@5 | 571 | // 'Patch size' slider |
philpem@5 | 572 | adj_patch_size = gimp_scale_entry_new(GTK_TABLE(table),0,10,"Patch size :",SCALE_WIDTH,ENTRY_WIDTH, |
philpem@5 | 573 | params.patch_size,1.0,9.0,1.0,1.0,0,true,0,0,0,0); |
philpem@5 | 574 | g_signal_connect(adj_patch_size,"value_changed",G_CALLBACK(gimp_int_adjustment_update),¶ms.patch_size); |
philpem@5 | 575 | g_signal_connect_swapped(adj_patch_size,"value_changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 576 | |
philpem@5 | 577 | // 'Sigma_p' slider |
philpem@5 | 578 | adj_sigma_p = gimp_scale_entry_new(GTK_TABLE(table),0,11,"_Sigma-p :",SCALE_WIDTH,ENTRY_WIDTH, |
philpem@5 | 579 | params.sigma_p,0.0,30.0,0.1,0.5,1,true,0,0,0,0); |
philpem@5 | 580 | g_signal_connect(adj_sigma_p,"value_changed",G_CALLBACK(gimp_double_adjustment_update),¶ms.sigma_p); |
philpem@5 | 581 | g_signal_connect_swapped(adj_sigma_p,"value_changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 582 | |
philpem@5 | 583 | // 'Sigma_s' slider |
philpem@5 | 584 | adj_sigma_s = gimp_scale_entry_new(GTK_TABLE(table),0,12,"_Sigma-s :",SCALE_WIDTH,ENTRY_WIDTH, |
philpem@5 | 585 | params.sigma_s,0.0,30.0,0.1,0.5,1,true,0,0,0,0); |
philpem@5 | 586 | g_signal_connect(adj_sigma_s,"value_changed",G_CALLBACK(gimp_double_adjustment_update),¶ms.sigma_s); |
philpem@5 | 587 | g_signal_connect_swapped(adj_sigma_s,"value_changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 588 | |
philpem@5 | 589 | // 'Lookup size' slider |
philpem@5 | 590 | adj_lookup_size = gimp_scale_entry_new(GTK_TABLE(table),0,13,"Lookup size :",SCALE_WIDTH,ENTRY_WIDTH, |
philpem@5 | 591 | params.lookup_size,1.0,40.0,1.0,1.0,0,true,0,0,0,0); |
philpem@5 | 592 | g_signal_connect(adj_lookup_size,"value_changed",G_CALLBACK(gimp_int_adjustment_update),¶ms.lookup_size); |
philpem@5 | 593 | g_signal_connect_swapped(adj_lookup_size,"value_changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 594 | |
philpem@5 | 595 | // 'Fast approximation' button |
philpem@5 | 596 | button_fast_approx = gtk_check_button_new_with_mnemonic("_Enable"); |
philpem@5 | 597 | gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button_fast_approx),params.fast_approx); |
philpem@5 | 598 | gimp_table_attach_aligned(GTK_TABLE(table),0,14,"Approximation :",0.0,0.5,button_fast_approx,2,false); |
philpem@5 | 599 | g_signal_connect(button_fast_approx,"toggled",G_CALLBACK(gimp_toggle_button_update),¶ms.fast_approx); |
philpem@5 | 600 | g_signal_connect_swapped(button_fast_approx,"toggled",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 601 | |
philpem@5 | 602 | // 'Channels' choice |
philpem@5 | 603 | combo_channels = gimp_int_combo_box_new("All",0,"Chroma",1,"Luminance",2,NULL); |
philpem@5 | 604 | gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(combo_channels),params.channels); |
philpem@5 | 605 | gimp_table_attach_aligned(GTK_TABLE(table),0,15,"Channels",0.0,0.5,combo_channels,2,false); |
philpem@5 | 606 | g_signal_connect(combo_channels,"changed",G_CALLBACK(gimp_int_combo_box_get_active),¶ms.channels); |
philpem@5 | 607 | g_signal_connect_swapped(combo_channels,"changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 608 | if (drawable->bpp < 3) gtk_widget_set_sensitive(combo_channels, FALSE); |
philpem@5 | 609 | |
philpem@5 | 610 | // 'Number of iterations' slider |
philpem@5 | 611 | adj_iterations = gimp_scale_entry_new(GTK_TABLE(table),0,16,"Number of _iterations :",SCALE_WIDTH,ENTRY_WIDTH, |
philpem@5 | 612 | params.iterations,1.0,30.0,1.0,1.0,0,true,0,0,0,0); |
philpem@5 | 613 | g_signal_connect(adj_iterations,"value_changed",G_CALLBACK(gimp_int_adjustment_update),¶ms.iterations); |
philpem@5 | 614 | g_signal_connect_swapped(adj_iterations,"value_changed",G_CALLBACK(gimp_preview_invalidate),preview); |
philpem@5 | 615 | |
philpem@5 | 616 | // Show dialog window |
philpem@5 | 617 | gtk_widget_show (dialog); |
philpem@5 | 618 | gtk_main (); |
philpem@5 | 619 | |
philpem@5 | 620 | return runflag; |
philpem@5 | 621 | } |
philpem@5 | 622 | |
philpem@5 | 623 | static void callback_response(GtkWidget *widget, gint response_id, gpointer data) { |
philpem@5 | 624 | data = 0; |
philpem@5 | 625 | switch (response_id) { |
philpem@5 | 626 | case RESPONSE_RESET: // Reset parameters to default values & update window |
philpem@5 | 627 | params = defaults_parameters; |
philpem@5 | 628 | gtk_adjustment_set_value(GTK_ADJUSTMENT(adj_amplitude), params.amplitude); |
philpem@5 | 629 | gtk_adjustment_set_value(GTK_ADJUSTMENT(adj_sharpness), params.sharpness); |
philpem@5 | 630 | gtk_adjustment_set_value(GTK_ADJUSTMENT(adj_anisotropy), params.anisotropy); |
philpem@5 | 631 | gtk_adjustment_set_value(GTK_ADJUSTMENT(adj_alpha), params.alpha); |
philpem@5 | 632 | gtk_adjustment_set_value(GTK_ADJUSTMENT(adj_sigma), params.sigma); |
philpem@5 | 633 | gtk_adjustment_set_value(GTK_ADJUSTMENT(adj_dl), params.dl); |
philpem@5 | 634 | gtk_adjustment_set_value(GTK_ADJUSTMENT(adj_da), params.da); |
philpem@5 | 635 | gtk_adjustment_set_value(GTK_ADJUSTMENT(adj_iterations), params.iterations); |
philpem@5 | 636 | gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(combo_channels), params.channels); |
philpem@5 | 637 | gimp_int_combo_box_set_active(GIMP_INT_COMBO_BOX(combo_interp), params.interp); |
philpem@5 | 638 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button_fast_approx), params.fast_approx); |
philpem@5 | 639 | gimp_preview_invalidate((GimpPreview*)preview); |
philpem@5 | 640 | break; |
philpem@5 | 641 | case GTK_RESPONSE_OK: |
philpem@5 | 642 | runflag = TRUE; |
philpem@5 | 643 | gtk_widget_destroy (widget); |
philpem@5 | 644 | break; |
philpem@5 | 645 | default: |
philpem@5 | 646 | gtk_widget_destroy (widget); |
philpem@5 | 647 | break; |
philpem@5 | 648 | } |
philpem@5 | 649 | } |