static void preview_ambient_occlusion_only(gint32 image_ID) { gint32 drawable_ID = -1; gint32 drawableAO_ID = -1; gtk_label_set_text(GTK_LABEL(progress_label), "Mixing Colors"); // preview_diffuse_only(image_ID); preview_normal_only(image_ID); // if (preview_normal_only(image_ID) != NULL) return NULL; drawable_ID = gimp_image_get_active_layer(image_ID); /** Copy active layer. */ /** LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL */ drawableAO_ID = gimp_layer_copy (drawable_ID); /** Add new layer to image. */ gimp_image_add_layer(image_ID, drawableAO_ID, -1); /** Set new layer as active. */ gimp_image_set_active_layer(image_ID, drawableAO_ID); /** * Colors -> Components -> "Channel Mixer" applied * Standard plug-in. Source code ships with GIMP. * * Add the "f" here to signify float in c language. * Removed 0.0 on first param and changed to 0 because boolean. */ /** Explained on line ~1300 of InsaneBump.c */ // if (plug_in_colors_channel_mixer_connector(image_ID, drawableAO_ID, 0, -200.0f, 0.0f, 0.0f, 0.0f, -200.0f, 0.0f, 0.0f, 0.0f, 1.0f) != 1) return; if (plug_in_colors_channel_mixer_connector(image_ID, drawableAO_ID, 0, -1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f) != 1) return; gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.87); gimp_desaturate(drawableAO_ID); gimp_levels_stretch(drawableAO_ID); pDrawables.drawable_ao = gimp_drawable_get(drawableAO_ID); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(progress), 0.90); }
static gboolean apply_color(color_settings settings, image_output out) { gboolean success = TRUE; int default_drawable = out->drawable_ids[0]; if (settings->brightness != 0 || settings->contrast != 0) { // brightness or contrast have been modified, apply the manipulation if (!gimp_drawable_is_rgb(default_drawable)) { gimp_image_convert_rgb(out->image_id); } int i; for (i = 0; i < out->drawable_count; i++) { success = gimp_brightness_contrast( out->drawable_ids[i], settings->brightness, settings->contrast ); } } if (settings->grayscale && !gimp_drawable_is_gray(default_drawable)) { // do grayscale conversion success = gimp_image_convert_grayscale(out->image_id); } if (settings->levels_auto) { // do levels correction int i; for (i = 0; i < out->drawable_count; i++) { success = gimp_levels_stretch(out->drawable_ids[i]); } } if (settings->curve_file != NULL && !gimp_drawable_is_indexed(default_drawable)) { // apply curve if (!colorcurve_init) { // read from the curve file only the first time success = parse_curve_file( settings->curve_file, &colorcurve_num_points_v, &colorcurve_ctr_points_v, &colorcurve_num_points_r, &colorcurve_ctr_points_r, &colorcurve_num_points_g, &colorcurve_ctr_points_g, &colorcurve_num_points_b, &colorcurve_ctr_points_b, &colorcurve_num_points_a, &colorcurve_ctr_points_a ); colorcurve_init = TRUE; } else success = TRUE; if (success) { int i; for (i = 0; i < out->drawable_count; i++) { if (colorcurve_num_points_v >= 4 && colorcurve_num_points_v <= 34) { success = gimp_curves_spline(out->drawable_ids[i], GIMP_HISTOGRAM_VALUE, colorcurve_num_points_v, colorcurve_ctr_points_v); } if (colorcurve_num_points_r >= 4 && colorcurve_num_points_r <= 34) { success = gimp_curves_spline(out->drawable_ids[i], GIMP_HISTOGRAM_RED, colorcurve_num_points_r, colorcurve_ctr_points_r); } if (colorcurve_num_points_g >= 4 && colorcurve_num_points_g <= 34) { success = gimp_curves_spline(out->drawable_ids[i], GIMP_HISTOGRAM_GREEN, colorcurve_num_points_g, colorcurve_ctr_points_g); } if (colorcurve_num_points_b >= 4 && colorcurve_num_points_b <= 34) { success = gimp_curves_spline(out->drawable_ids[i], GIMP_HISTOGRAM_BLUE, colorcurve_num_points_b, colorcurve_ctr_points_b); } if (colorcurve_num_points_a >= 4 && colorcurve_num_points_a <= 34) { success = gimp_curves_spline(out->drawable_ids[i], GIMP_HISTOGRAM_ALPHA, colorcurve_num_points_a, colorcurve_ctr_points_a); } } } } return success; }
/* --------------------------------- * gap_edgeDetectionByBlurDiff * --------------------------------- */ gint32 gap_edgeDetectionByBlurDiff(gint32 activeDrawableId, gdouble blurRadius, gdouble blurResultRadius , gdouble threshold, gint32 shift, gboolean doLevelsAutostretch , gboolean invert) { gint32 blurLayerId; gint32 edgeLayerId; gint32 imageId; GimpDrawable *edgeDrawable; GimpDrawable *refDrawable; GimpDrawable *blurDrawable; imageId = gimp_drawable_get_image(activeDrawableId); edgeLayerId = gimp_layer_copy(activeDrawableId); gimp_image_add_layer (imageId, edgeLayerId, 0 /* stackposition */ ); edgeDrawable = gimp_drawable_get(edgeLayerId); refDrawable = gimp_drawable_get(activeDrawableId); if(blurRadius > 0.0) { p_call_plug_in_gauss_iir2(imageId, edgeLayerId, blurRadius, blurRadius); } blurDrawable = NULL; // blurLayerId = gimp_layer_copy(edgeLayerId); // gimp_image_add_layer (imageId, blurLayerId, 0 /* stackposition */ ); // blurDrawable = gimp_drawable_get(blurLayerId); p_subtract_ref_layer(imageId, edgeDrawable, refDrawable, threshold, shift, invert); //p_subtract_ref_layer(imageId, edgeDrawable, blurDrawable, threshold, shift, invert); if (doLevelsAutostretch) { gimp_levels_stretch(edgeLayerId); } if(blurResultRadius > 0.0) { p_call_plug_in_gauss_iir2(imageId, edgeLayerId, blurResultRadius, blurResultRadius); } if(refDrawable) { gimp_drawable_detach(refDrawable); } if(edgeDrawable) { gimp_drawable_detach(edgeDrawable); } if(blurDrawable) { gimp_drawable_detach(blurDrawable); } return (edgeLayerId); } /* end gap_edgeDetectionByBlurDiff */
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); }