void removeAllLayersExceptMain(void) { gint *pnLayers = NULL; gint numLayers = 0 ; gint nIndex = 0 ; gimp_image_set_active_layer(local_vals.image_ID, drawableBeginActiveLayer); pnLayers = gimp_image_get_layers(local_vals.image_ID, &numLayers); for (nIndex=0;nIndex< numLayers;nIndex++) { if (pnLayers[nIndex] != drawableBeginActiveLayer) { if (gimp_layer_is_floating_sel(pnLayers[nIndex])) { gimp_floating_sel_remove(pnLayers[nIndex]); } else { gimp_image_remove_layer(local_vals.image_ID, pnLayers[nIndex]); } } } gimp_drawable_set_visible(drawableBeginActiveLayer, TRUE); }
static void dog (gint32 image_ID, GimpDrawable *drawable, gdouble inner, gdouble outer, gboolean show_progress) { GimpDrawable *drawable1; GimpDrawable *drawable2; gint32 drawable_id = drawable->drawable_id; gint32 layer1; gint32 layer2; gint width, height; gint x1, y1, x2, y2; guchar maxval = 255; gimp_drawable_mask_bounds (drawable_id, &x1, &y1, &x2, &y2); width = (x2 - x1); height = (y2 - y1); gimp_drawable_flush (drawable); layer1 = gimp_layer_copy (drawable_id); gimp_drawable_set_visible (layer1, FALSE); gimp_drawable_set_name (layer1, "dog_scratch_layer1"); gimp_image_add_layer (image_ID, layer1, 0); layer2 = gimp_layer_copy (drawable_id); gimp_drawable_set_visible (layer2, FALSE); gimp_drawable_set_name (layer2, "dog_scratch_layer2"); gimp_image_add_layer (image_ID, layer2, 0); drawable1 = gimp_drawable_get (layer1); drawable2 = gimp_drawable_get (layer2); gauss_rle (drawable1, inner, 0, show_progress); gauss_rle (drawable2, outer, 1, show_progress); compute_difference (drawable, drawable1, drawable2, &maxval); gimp_drawable_detach (drawable1); gimp_drawable_detach (drawable2); gimp_image_remove_layer (image_ID, layer1); gimp_image_remove_layer (image_ID, layer2); gimp_drawable_flush (drawable); gimp_drawable_merge_shadow (drawable_id, TRUE); gimp_drawable_update (drawable_id, x1, y1, width, height); if (dogvals.normalize) { normalize (drawable, maxval); gimp_drawable_flush (drawable); gimp_drawable_merge_shadow (drawable_id, TRUE); gimp_drawable_update (drawable_id, x1, y1, width, height); } if (dogvals.invert) gimp_invert (drawable_id); }
static void preview_alt_normal(gint32 image_ID) { /******************************************************************************* * Begin H and Normal ******************************************************************************/ gint32 mergedLayer_ID = -1; gint32 normalmap_ID = -1; gfloat wsize = (gfloat)gimp_image_width(image_ID); gfloat hsize = (gfloat)gimp_image_width(image_ID); /** Get active layer. */ gint32 drawable_temp_ID = gimp_image_get_active_layer(image_ID); /** Copy active layer. */ /** LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL */ gint32 diffuse_ID = gimp_layer_copy (drawable_temp_ID); /** Add new layer to image. */ gimp_image_add_layer(image_ID, diffuse_ID, -1); /** Set new layer as active. */ gimp_image_set_active_layer(image_ID, diffuse_ID); /** Here I should hide previous active layer, make not visible. */ gtk_label_set_text(GTK_LABEL(progress_label), "Smoothing"); /** * Since copied, don't need this here. * blur seems to not create an extra layer. */ blur(image_ID, diffuse_ID, wsize, hsize, local_vals.LargeDetails, 0, local_vals.ao); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.15); normalmap_ID = gimp_image_get_active_layer(image_ID); if(local_vals.smoothstep) { gtk_label_set_text(GTK_LABEL(progress_label), "Smoothing"); /** * Filter "Blur" applied * Standard plug-in. Source code ships with GIMP. */ if (plug_in_blur_connector(image_ID, normalmap_ID) != 1) return; gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.20); } else { gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.20); } if(local_vals.invh) { /** * Colors Menu->Invert * Standard plug-in. Source code ships with GIMP. */ if (plug_in_vinvert_connector(image_ID, normalmap_ID) != 1) return; gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.25); } else { gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.25); } /** Here is _p Displacement drawable. */ pDrawables.drawable_p = gimp_drawable_get(normalmap_ID); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.30); /** Extra layer here. */ /** LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL */ gtk_label_set_text(GTK_LABEL(progress_label), "Base Mapping"); doBaseMap(image_ID, diffuse_ID, local_vals.Depth, local_vals.LargeDetails, local_vals.ao); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.35); normalmap_ID = gimp_image_get_active_layer(image_ID); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.40); /** Here is _ln low normal. l l l l l l l l l l l l l l l l */ if (gcNeedNormal == 'l') { pDrawables.drawable_n = gimp_drawable_get(normalmap_ID); } /** Creates an extra layer. */ /** LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL */ shapeRecognise(image_ID, normalmap_ID, local_vals.ShapeRecog, local_vals.ao); if(local_vals.smoothstep) { normalmap_ID = gimp_image_get_active_layer(image_ID); gtk_label_set_text(GTK_LABEL(progress_label), "Smoothing"); /** * Filter "Blur" applied * Standard plug-in. Source code ships with GIMP. */ if (plug_in_blur_connector(image_ID, normalmap_ID) != 1) return; gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.45); } else { gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.45); } /** Here is _sn super normal. s s s s s s s s s s s s s s s s */ if (gcNeedNormal == 's') { pDrawables.drawable_n = gimp_drawable_get(normalmap_ID); } gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.50); gtk_label_set_text(GTK_LABEL(progress_label), "Sharpen"); /** Creates an extra layer. */ /** LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL */ sharpen(image_ID, diffuse_ID, local_vals.Depth, 0, local_vals.SmallDetails); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.55); normalmap_ID = gimp_image_get_active_layer(image_ID); gtk_label_set_text(GTK_LABEL(progress_label), "Sharpen more"); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.65); /** * Filter Enhance "Sharpen" applied * Standard plug-in. Source code ships with GIMP. */ if (plug_in_sharpen_connector(image_ID, normalmap_ID, 20) != 1) return; /** Here is _hn high normal. h h h h h h h h h h h h h h h h */ if (gcNeedNormal == 'h') { pDrawables.drawable_n = gimp_drawable_get(normalmap_ID); } gtk_label_set_text(GTK_LABEL(progress_label), "Sharpen again"); /** Creates an extra layer. */ /** LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL */ sharpen(image_ID, diffuse_ID, local_vals.Depth, 6, local_vals.MediumDetails); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.70); normalmap_ID = gimp_image_get_active_layer(image_ID); gtk_label_set_text(GTK_LABEL(progress_label), "Smoothing"); /** * Filter "Blur" applied * Standard plug-in. Source code ships with GIMP. */ if (plug_in_blur_connector(image_ID, normalmap_ID) != 1) return; gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.75); /** Here is _mn medium normal m m m m m m m m m m m m m m m m */ if (gcNeedNormal == 'm') { pDrawables.drawable_n = gimp_drawable_get(normalmap_ID); } gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.78); gimp_drawable_set_visible(diffuse_ID, 0); /** * Don't do the next line: * * gimp_image_merge_visible_layers(image_ID, 0); * * Do this instead for preview: */ mergedLayer_ID = gimp_layer_new_from_visible(image_ID, image_ID, "temp"); /** Add copied layer to image. */ gimp_image_add_layer(image_ID, mergedLayer_ID, -1); }
static void preview_diffuse_only(gint32 image_ID) { gint32 noiselayer_ID = -1; gint32 drawable_ID = -1; gint32 drawableDiffuse_ID = -1; gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.0); gtk_label_set_text(GTK_LABEL(progress_label), "Begin"); drawableBeginActiveLayer = gimp_image_get_active_layer(image_ID); drawable_ID = gimp_layer_copy (drawableBeginActiveLayer); gimp_image_add_layer(image_ID, drawable_ID, -1); gimp_image_set_active_layer(image_ID, drawable_ID); /** Here I should hide previous active layer, make not visible. */ gimp_drawable_set_visible(drawableBeginActiveLayer, FALSE); /** * For preview do nothing here. * if(local_vals.Resizie) * { * } */ if (local_vals.Noise) { /** Already have active layer in drawable_ID. */ noiselayer_ID = gimp_layer_copy (drawable_ID); gimp_image_add_layer(image_ID, noiselayer_ID, -1); gimp_image_set_active_layer(image_ID, noiselayer_ID); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.03); gtk_label_set_text(GTK_LABEL(progress_label), "Noise"); /** * Filter "RGB Noise" applied * Standard plug-in. Source code ships with GIMP. * * Add the "f" here to signify float in c language. */ if (plug_in_rgb_noise_connector(image_ID, noiselayer_ID, 1, 1, 0.20f, 0.20f, 0.20f, 0.0f) != 1) return; gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.04); gimp_layer_set_mode(noiselayer_ID, GIMP_VALUE_MODE); gimp_image_merge_down(image_ID, noiselayer_ID, 0); gtk_label_set_text(GTK_LABEL(gwNormalLabel), "Noise affects every redraw!"); } else { gtk_label_set_text(GTK_LABEL(gwNormalLabel), ""); gtk_label_set_text(GTK_LABEL(progress_label), "Noise added"); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.04); } if(local_vals.RemoveLighting) { gtk_label_set_text(GTK_LABEL(progress_label), "Remove Shading"); removeShadingPreview(image_ID, local_vals.Noise); /** * See notes inside of removeShadingPreview * for explanation of next line. */ /** * If Noise is on, then noiselayer_ID was merged down into drawable_ID. * You cannot remove drawable_ID in this case, as it is the only * layer left! * * However, if Noise is Yes and RemoveLighting is Yes, * Then there is an extra layer floating around! * Delete noiselayer_ID? I thought it was merged! * No, I was right noiselayer_ID is already gone! */ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.05); } else { gtk_label_set_text(GTK_LABEL(progress_label), "Stretch"); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.05); } drawableDiffuse_ID = gimp_image_get_active_layer(image_ID); gimp_levels_stretch(drawableDiffuse_ID); if(local_vals.Tile) { gtk_label_set_text(GTK_LABEL(progress_label), "Making Seamless"); /** * Filter "Tile Seamless" applied * Standard plug-in. Source code ships with GIMP. */ if (plug_in_make_seamless_connector(image_ID, drawableDiffuse_ID) != 1) return; gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.07); } else { gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.07); } /** Here I should un hide previously hidden layer, make visible. */ pDrawables.drawable_d = gimp_drawable_get(drawableDiffuse_ID); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.1); }