static GValueArray * buffer_get_image_type_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; const gchar *buffer_name; gint32 image_type = 0; buffer_name = g_value_get_string (&args->values[0]); if (success) { GimpBuffer *buffer = (GimpBuffer *) gimp_container_get_child_by_name (gimp->named_buffers, buffer_name); if (buffer) image_type = gimp_buffer_get_image_type (buffer); else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success); if (success) g_value_set_enum (&return_vals->values[1], image_type); return return_vals; }
static void gimp_brush_clipboard_buffer_changed (Gimp *gimp, GimpBrush *brush) { gint width; gint height; if (brush->mask) { temp_buf_free (brush->mask); brush->mask = NULL; } if (brush->pixmap) { temp_buf_free (brush->pixmap); brush->pixmap = NULL; } if (gimp->global_buffer) { TileManager *tiles = gimp_buffer_get_tiles (gimp->global_buffer); GimpImageType type = gimp_buffer_get_image_type (gimp->global_buffer); width = MIN (gimp_buffer_get_width (gimp->global_buffer), 1024); height = MIN (gimp_buffer_get_height (gimp->global_buffer), 1024); brush->mask = temp_buf_new (width, height, 1, 0, 0, NULL); brush->pixmap = temp_buf_new (width, height, 3, 0, 0, NULL); /* copy the alpha channel into the brush's mask */ if (GIMP_IMAGE_TYPE_HAS_ALPHA (type)) { PixelRegion bufferPR; PixelRegion maskPR; pixel_region_init (&bufferPR, tiles, 0, 0, width, height, FALSE); pixel_region_init_temp_buf (&maskPR, brush->mask, 0, 0, width, height); extract_alpha_region (&bufferPR, NULL, &maskPR); } else { PixelRegion maskPR; guchar opaque = OPAQUE_OPACITY; pixel_region_init_temp_buf (&maskPR, brush->mask, 0, 0, width, height); color_region (&maskPR, &opaque); } /* copy the color channels into the brush's pixmap */ if (GIMP_IMAGE_TYPE_IS_RGB (type)) { PixelRegion bufferPR; PixelRegion pixmapPR; pixel_region_init (&bufferPR, tiles, 0, 0, width, height, FALSE); pixel_region_init_temp_buf (&pixmapPR, brush->pixmap, 0, 0, width, height); if (GIMP_IMAGE_TYPE_HAS_ALPHA (type)) copy_color (&bufferPR, &pixmapPR); else copy_region (&bufferPR, &pixmapPR); } else { PixelRegion bufferPR; PixelRegion tempPR; TempBuf *temp = temp_buf_new (width, height, 1, 0, 0, NULL); pixel_region_init (&bufferPR, tiles, 0, 0, width, height, FALSE); pixel_region_init_temp_buf (&tempPR, temp, 0, 0, width, height); if (GIMP_IMAGE_TYPE_HAS_ALPHA (type)) copy_component (&bufferPR, &tempPR, 0); else copy_region (&bufferPR, &tempPR); temp_buf_copy (temp, brush->pixmap); temp_buf_free (temp); } } else { guchar color = 0; width = 17; height = 17; brush->mask = temp_buf_new (width, height, 1, 0, 0, &color); } brush->x_axis.x = width / 2; brush->x_axis.y = 0; brush->y_axis.x = 0; brush->y_axis.y = height / 2; gimp_data_dirty (GIMP_DATA (brush)); }