コード例 #1
0
ファイル: picframe.c プロジェクト: ZarniHtet13/GIMPplugintest
static void modos (GimpDrawable *drawable ,gint image)
{
  gint width, height;

  // getting the image size
  width = gimp_image_width(image);
  height = gimp_image_height(image);

  // filling in the various parameters of rect_select which is image, x-cord, y-cord, width, height, Operation, feather, feather_radius
  gimp_rect_select(image, 0, 0, width, height, 0, 0, 0);
  // filling the various parameters of ellipse_select which is image, x-cord, y-cord (in this thickness of the frame), adjusted width and height with regards to thickness, SUBTRACT operation, Making the pic clear, feather, feather-radius
  gimp_ellipse_select (image, vals.xcord,vals.ycord, width - (2*vals.xcord), height - (2*vals.ycord), 1, TRUE, vals.xcord/4, vals.ycord/8);
  //Two parameters: drawable id, and fill type. (0-Foreground, 1-Background, 2-Whitefill, 3-Transparentfill, 4-Patterfill)
  gimp_edit_fill (drawable->drawable_id, vals.framecolor);
}
コード例 #2
0
ファイル: screenshot.c プロジェクト: Minoos/gimp
static void
image_select_shape (gint32     image,
                    GdkRegion *shape)
{
  GdkRectangle *rects;
  gint          num_rects;
  gint          i;

  gimp_selection_none (image);

  gdk_region_get_rectangles (shape, &rects, &num_rects);

  for (i = 0; i < num_rects; i++)
    {
      gimp_rect_select (image,
                        rects[i].x, rects[i].y, rects[i].width, rects[i].height,
                        GIMP_CHANNEL_OP_ADD, FALSE, 0);
    }

  g_free (rects);

  gimp_selection_invert (image);
}
コード例 #3
0
static void
border (gint32 image_ID)
{
  GdkPixbuf *pixbuf = NULL;
  int        texture_width;
  int        texture_height;
  gdouble    margin_x;
  gdouble    margin_y;

  pixbuf = gdk_pixbuf_new_from_inline (-1, bvals.border->texture, FALSE, NULL);

  if (pixbuf)
  {
    texture_width = gdk_pixbuf_get_width (pixbuf);
    texture_height = gdk_pixbuf_get_height (pixbuf);

    gint32 texture_image = gimp_image_new (texture_width, texture_height, GIMP_RGB);
    gint32 texture_layer = gimp_layer_new_from_pixbuf (texture_image, "texture", pixbuf, 100, GIMP_NORMAL_MODE, 0, 0);
    gimp_image_add_layer (texture_image, texture_layer, -1);

    gint width = gimp_image_width (image_ID);
    gint height = gimp_image_height (image_ID);

    if (bvals.border->top || bvals.border->bottom || bvals.border->left || bvals.border->right)
    {
      width += bvals.border->left + bvals.border->right;
      height += bvals.border->top + bvals.border->bottom;
      gimp_image_resize (image_ID,
                         width,
                         height,
                         bvals.border->left,
                         bvals.border->top);
    }

    gint32 layer = gimp_layer_new (image_ID, "border",
                                   width, height,
                                   GIMP_RGBA_IMAGE,
                                   100,
                                   GIMP_NORMAL_MODE);
    gimp_image_add_layer (image_ID, layer, -1);

    if (width > texture_width - bvals.border->length)
      margin_x = (texture_width - bvals.border->length) / 2;
    else
      margin_x = (gdouble) width / 2;
    if (height > texture_height - bvals.border->length)
      margin_y = (texture_height - bvals.border->length) / 2;
    else
      margin_y = (gdouble) height / 2;

    /* fix gimp_context_set_pattern ("Clipboard") only works on English versions of Gimp */
    //gimp_context_set_pattern ("Clipboard");
    INIT_I18N ();
    gimp_context_set_pattern (_("Clipboard"));

    if (width > margin_x * 2) {
      /* top */
      gimp_rect_select (texture_image,
                        margin_x,
                        0,
                        texture_width - margin_x * 2,
                        margin_y,
                        GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
      gimp_edit_copy (texture_layer);
      gimp_rect_select (image_ID,
                        margin_x,
                        0,
                        width - margin_x * 2,
                        margin_y,
                        GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
      gimp_edit_fill (layer, GIMP_PATTERN_FILL);

      /* bottom */
      gimp_rect_select (texture_image,
                        margin_x,
                        texture_height - margin_y,
                        texture_width - margin_x * 2,
                        texture_height,
                        GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
      gimp_edit_copy (texture_layer);
      gimp_rect_select (image_ID,
                        margin_x,
                        height - margin_y,
                        width - margin_x * 2,
                        height,
                        GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
      gimp_edit_fill (layer, GIMP_PATTERN_FILL);
    }

    if (height > margin_y * 2) {
      /* left */
      gimp_rect_select (texture_image,
                        0,
                        margin_y,
                        margin_x,
                        texture_height - margin_y * 2,
                        GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
      gimp_edit_copy (texture_layer);
      gimp_rect_select (image_ID,
                        0,
                        margin_y,
                        margin_x,
                        height - margin_y * 2,
                        GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
      gimp_edit_fill (layer, GIMP_PATTERN_FILL);

      /* right */
      gimp_rect_select (texture_image,
                        texture_width - margin_x,
                        margin_y,
                        margin_x,
                        texture_height - margin_y * 2,
                        GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
      gimp_edit_copy (texture_layer);
      gimp_rect_select (image_ID,
                        width - margin_x,
                        margin_y,
                        margin_x,
                        height - margin_y * 2,
                        GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
      gimp_edit_fill (layer, GIMP_PATTERN_FILL);
    }

    /* top left */
    gimp_rect_select (texture_image,
                      0,
                      0,
                      margin_x,
                      margin_y,
                      GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
    gimp_edit_copy (texture_layer);
    gimp_rect_select (image_ID,
                      0,
                      0,
                      margin_x,
                      margin_y,
                      GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
    gimp_edit_fill (layer, GIMP_PATTERN_FILL);

    /* top right */
    gimp_rect_select (texture_image,
                      texture_width - margin_x,
                      0,
                      margin_x,
                      margin_y,
                      GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
    gimp_edit_copy (texture_layer);
    gimp_rect_select (image_ID,
                      width - margin_x,
                      0,
                      margin_x,
                      margin_y,
                      GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
    gimp_edit_fill (layer, GIMP_PATTERN_FILL);

    /* bottom left */
    gimp_rect_select (texture_image,
                      0,
                      texture_height - margin_y,
                      margin_x,
                      margin_y,
                      GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
    gimp_edit_copy (texture_layer);
    gimp_rect_select (image_ID,
                      0,
                      height - margin_y,
                      margin_x,
                      margin_y,
                      GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
    gimp_edit_fill (layer, GIMP_PATTERN_FILL);

    /* bottom right */
    gimp_rect_select (texture_image,
                      texture_width - margin_x,
                      texture_height - margin_y,
                      margin_x,
                      margin_y,
                      GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
    gimp_edit_copy (texture_layer);
    gimp_rect_select (image_ID,
                      width - margin_x,
                      height - margin_y,
                      margin_x,
                      margin_y,
                      GIMP_CHANNEL_OP_REPLACE, FALSE, 0);
    gimp_edit_fill (layer, GIMP_PATTERN_FILL);

    gimp_image_merge_down(image_ID, layer, GIMP_CLIP_TO_IMAGE);

    gimp_selection_none (image_ID);
  }
}