//redrawImage shifts the existing pixels down by one row, and draws // the newest row at the top of the image void redrawImage() { numLines++; //copy the existing image, without the topmost row buf = gdk_pixbuf_new_subpixbuf(imagebuf, 0, 0, WIDTH, HEIGHT - PIX_PER_CELL); //place that copy into a new buffer buf2 = gdk_pixbuf_copy(buf); //release the memory of the first buffer gdk_pixbuf_unref(buf); //copy the second buffer gdk_pixbuf_copy_area(buf2, 0, 0, WIDTH, HEIGHT - PIX_PER_CELL, imagebuf, 0, PIX_PER_CELL); //release the second buffer gdk_pixbuf_unref(buf2); //get the new row std::vector<bool> *data = ca1->getNewRow(); //draw the new row on imagebuf for (unsigned int i = 0; i < ca1->getWidth(); i++) { if ((*data)[i]) { color = black; } else { color = white; } gdk_pixbuf_copy_area(color, 0, 0, PIX_PER_CELL, PIX_PER_CELL, imagebuf, i * PIX_PER_CELL, 0); } //copy imagebuf onto the screen gtk_image_set_from_pixbuf(GTK_IMAGE(mainImage),imagebuf); }
GdkPixbuf *preview_theme(const gchar *name, const gchar *titlelayout, RrFont *active_window_font, RrFont *inactive_window_font, RrFont *menu_title_font, RrFont *menu_item_font, RrFont *osd_active_font, RrFont *osd_inactive_font) { GdkPixbuf *preview; GdkPixbuf *menu; GdkPixbuf *window; gint window_w; gint menu_w; gint w, h; RrTheme *theme = RrThemeNew(rrinst, name, FALSE, active_window_font, inactive_window_font, menu_title_font, menu_item_font, osd_active_font, osd_inactive_font); if (!theme) return NULL; menu = preview_menu(theme); window_w = theme_window_min_width(theme, titlelayout); menu_w = gdk_pixbuf_get_width(menu); h = gdk_pixbuf_get_height(menu); w = MAX(window_w, menu_w) + 20; /* we don't want windows disappearing on us */ if (!window_w) window_w = menu_w; preview = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, w, h + 2*(theme->title_height +5) + 1); gdk_pixbuf_fill(preview, 0); /* clear */ window = preview_window(theme, titlelayout, FALSE, window_w, h); gdk_pixbuf_copy_area(window, 0, 0, window_w, h, preview, 20, 0); g_object_unref(window); window = preview_window(theme, titlelayout, TRUE, window_w, h); gdk_pixbuf_copy_area(window, 0, 0, window_w, h, preview, 10, theme->title_height + 5); g_object_unref(window); gdk_pixbuf_copy_area(menu, 0, 0, menu_w, h, preview, 0, 2 * (theme->title_height + 5)); g_object_unref(menu); RrThemeFree(theme); return preview; }
GdkPixbuf * eel_stretch_frame_image (GdkPixbuf *frame_image, int left_offset, int top_offset, int right_offset, int bottom_offset, int dest_width, int dest_height, gboolean fill_flag) { GdkPixbuf *result_pixbuf; guchar *pixels_ptr; int frame_width, frame_height; int y, row_stride; int target_width, target_frame_width; int target_height, target_frame_height; frame_width = gdk_pixbuf_get_width (frame_image); frame_height = gdk_pixbuf_get_height (frame_image ); if (fill_flag) { result_pixbuf = gdk_pixbuf_scale_simple (frame_image, dest_width, dest_height, GDK_INTERP_NEAREST); } else { result_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, dest_width, dest_height); } row_stride = gdk_pixbuf_get_rowstride (result_pixbuf); pixels_ptr = gdk_pixbuf_get_pixels (result_pixbuf); /* clear the new pixbuf */ if (!fill_flag) { for (y = 0; y < dest_height; y++) { memset (pixels_ptr, 255, row_stride); pixels_ptr += row_stride; } } target_width = dest_width - left_offset - right_offset; target_frame_width = frame_width - left_offset - right_offset; target_height = dest_height - top_offset - bottom_offset; target_frame_height = frame_height - top_offset - bottom_offset; /* draw the left top corner and top row */ gdk_pixbuf_copy_area (frame_image, 0, 0, left_offset, top_offset, result_pixbuf, 0, 0); draw_frame_row (frame_image, target_width, target_frame_width, 0, 0, result_pixbuf, left_offset, top_offset); /* draw the right top corner and left column */ gdk_pixbuf_copy_area (frame_image, frame_width - right_offset, 0, right_offset, top_offset, result_pixbuf, dest_width - right_offset, 0); draw_frame_column (frame_image, target_height, target_frame_height, 0, 0, result_pixbuf, top_offset, left_offset); /* draw the bottom right corner and bottom row */ gdk_pixbuf_copy_area (frame_image, frame_width - right_offset, frame_height - bottom_offset, right_offset, bottom_offset, result_pixbuf, dest_width - right_offset, dest_height - bottom_offset); draw_frame_row (frame_image, target_width, target_frame_width, frame_height - bottom_offset, dest_height - bottom_offset, result_pixbuf, left_offset, bottom_offset); /* draw the bottom left corner and the right column */ gdk_pixbuf_copy_area (frame_image, 0, frame_height - bottom_offset, left_offset, bottom_offset, result_pixbuf, 0, dest_height - bottom_offset); draw_frame_column (frame_image, target_height, target_frame_height, frame_width - right_offset, dest_width - right_offset, result_pixbuf, top_offset, right_offset); return result_pixbuf; }
static void x_pixbuf_tmp_draw_tile(int tile, int ofsx, int ofsy) { int i, j, n; guint32 pixel; int width, height; int srcx, srcy; int dstx = ofsx, dsty = ofsy; width = Tile->unit_width; height = Tile->unit_height; srcx = (tile % tiles_per_row) * width; srcy = (tile / tiles_per_row) * height; if (dstx < 0) { srcx -= dstx; width += dstx; dstx = 0; } if (dsty < 0) { srcy -= dsty; height += dsty; dsty = 0; } if (dstx > 0) width -= dstx; if (dsty > 0) height -= dsty; if (!tmp_pixbuf) { tmp_pixbuf = gdk_pixbuf_new(gdk_pixbuf_get_colorspace(tile_pixbuf), gdk_pixbuf_get_has_alpha(tile_pixbuf), gdk_pixbuf_get_bits_per_sample(tile_pixbuf), Tile->unit_width, Tile->unit_height); memset(gdk_pixbuf_get_pixels(tmp_pixbuf), 0, Tile->unit_height * gdk_pixbuf_get_rowstride(tmp_pixbuf)); gdk_pixbuf_copy_area(tile_pixbuf, srcx, srcy, width, height, tmp_pixbuf, dstx, dsty); { guchar *pixels; int rowstride; int n_channels; guchar rgba[4]; g_return_if_fail(gdk_pixbuf_get_bits_per_sample(tmp_pixbuf) == 8 && gdk_pixbuf_get_colorspace(tmp_pixbuf) == GDK_COLORSPACE_RGB); pixels = gdk_pixbuf_get_pixels(tmp_pixbuf); rowstride = gdk_pixbuf_get_rowstride(tmp_pixbuf); n_channels = gdk_pixbuf_get_n_channels(tmp_pixbuf); for(j = 0; j < Tile->unit_height; j++) for(i = 0; i < Tile->unit_width; i++) { nh_pixbuf_get_pixel(i, j, rgba); rgba[3] = 255; nh_pixbuf_put_pixel(i, j, rgba); } } } else gdk_pixbuf_composite(tile_pixbuf, tmp_pixbuf, dstx, dsty, width, height, -srcx, -srcy, 1.0, 1.0, GDK_INTERP_NEAREST, 255.0); }
static GdkPixbuf * gsearchtool_embed_image_in_frame (GdkPixbuf * source_image, GdkPixbuf * frame_image, gint left_offset, gint top_offset, gint right_offset, gint bottom_offset) { GdkPixbuf * result_pixbuf; gint source_width, source_height; gint dest_width, dest_height; source_width = gdk_pixbuf_get_width (source_image); source_height = gdk_pixbuf_get_height (source_image); dest_width = source_width + left_offset + right_offset; dest_height = source_height + top_offset + bottom_offset; result_pixbuf = gsearchtool_stretch_frame_image (frame_image, left_offset, top_offset, right_offset, bottom_offset, dest_width, dest_height, FALSE); gdk_pixbuf_copy_area (source_image, 0, 0, source_width, source_height, result_pixbuf, left_offset, top_offset); return result_pixbuf; }
static GdkPixbuf * pixbuf_round_corners (GdkPixbuf *pixbuf) { GdkPixbuf *result; if (!gdk_pixbuf_get_has_alpha (pixbuf)) { result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf)); gdk_pixbuf_copy_area (pixbuf, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), result, 0, 0); } else { result = g_object_ref (pixbuf); } if (empathy_gdk_pixbuf_is_opaque (result)) empathy_avatar_pixbuf_roundify (result); return result; }
/** * eog_thumbnail_add_frame: * @thumbnail: a #GdkPixbuf * * Adds a frame to @thumbnail * * Returns: (transfer full): a new #GdkPixbuf, storing @thumbnail nicely framed. **/ GdkPixbuf * eog_thumbnail_add_frame (GdkPixbuf *thumbnail) { GdkPixbuf *result_pixbuf; gint source_width, source_height; gint dest_width, dest_height; source_width = gdk_pixbuf_get_width (thumbnail); source_height = gdk_pixbuf_get_height (thumbnail); dest_width = source_width + 9; dest_height = source_height + 9; result_pixbuf = eog_thumbnail_stretch_frame_image (frame, 3, 3, 6, 6, dest_width, dest_height, FALSE); gdk_pixbuf_copy_area (thumbnail, 0, 0, source_width, source_height, result_pixbuf, 3, 3); return result_pixbuf; }
static GdkPixbuf * gimp_page_selector_add_frame (GtkWidget *widget, GdkPixbuf *pixbuf) { GdkPixbuf *frame; gint width, height; width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); frame = g_object_get_data (G_OBJECT (widget), "frame"); if (! frame) { frame = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), GIMP_STOCK_FRAME, 64, 0, NULL); g_object_set_data_full (G_OBJECT (widget), "frame", frame, (GDestroyNotify) g_object_unref); } frame = stretch_frame_image (frame, FRAME_LEFT, FRAME_TOP, FRAME_RIGHT, FRAME_BOTTOM, width + FRAME_LEFT + FRAME_RIGHT, height + FRAME_TOP + FRAME_BOTTOM); gdk_pixbuf_copy_area (pixbuf, 0, 0, width, height, frame, FRAME_LEFT, FRAME_TOP); return frame; }
void cheese_thumbnail_add_frame (GdkPixbuf **pixbuf) { GdkPixbuf *result; int source_width, source_height; int dest_width, dest_height; int left_offset, right_offset, top_offset, bottom_offset; left_offset = CHEESE_THUMBNAIL_FRAME_LEFT; right_offset = CHEESE_THUMBNAIL_FRAME_RIGHT; top_offset = CHEESE_THUMBNAIL_FRAME_TOP; bottom_offset = CHEESE_THUMBNAIL_FRAME_BOTTOM; source_width = gdk_pixbuf_get_width (*pixbuf); source_height = gdk_pixbuf_get_height (*pixbuf); dest_width = source_width + left_offset + right_offset; dest_height = source_height + top_offset + bottom_offset; result = cheese_thumbnail_stretch_frame_image (frame, left_offset, top_offset, right_offset, bottom_offset, dest_width, dest_height, FALSE); gdk_pixbuf_copy_area (*pixbuf, 0, 0, source_width, source_height, result, left_offset, top_offset); g_object_unref (*pixbuf); *pixbuf = result; }
static void draw_frame_row (GdkPixbuf *frame_image, gint target_width, gint source_width, gint source_v_position, gint dest_v_position, GdkPixbuf *result_pixbuf, gint left_offset, gint height) { gint remaining_width, h_offset, slab_width; remaining_width = target_width; h_offset = 0; while (remaining_width > 0) { slab_width = remaining_width > source_width ? source_width : remaining_width; gdk_pixbuf_copy_area (frame_image, left_offset, source_v_position, slab_width, height, result_pixbuf, left_offset + h_offset, dest_v_position); remaining_width -= slab_width; h_offset += slab_width; } }
GdkPixbuf * photos_utils_center_pixbuf (GdkPixbuf *pixbuf, gint size) { GdkPixbuf *ret_val; gint height; gint pixbuf_size; gint width; height = gdk_pixbuf_get_height (pixbuf); width = gdk_pixbuf_get_width (pixbuf); pixbuf_size = MAX (height, width); if (pixbuf_size >= size) { ret_val = g_object_ref (pixbuf); goto out; } ret_val = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, size, size); gdk_pixbuf_fill (ret_val, 0x00000000); gdk_pixbuf_copy_area (pixbuf, 0, 0, width, height, ret_val, (size - width) / 2, (size - height) / 2); out: return ret_val; }
static void draw_frame_column (GdkPixbuf *frame_image, gint target_height, gint source_height, gint source_h_position, gint dest_h_position, GdkPixbuf *result_pixbuf, gint top_offset, gint width) { gint remaining_height, v_offset, slab_height; remaining_height = target_height; v_offset = 0; while (remaining_height > 0) { slab_height = remaining_height > source_height ? source_height : remaining_height; gdk_pixbuf_copy_area (frame_image, source_h_position, top_offset, width, slab_height, result_pixbuf, dest_h_position, top_offset + v_offset); remaining_height -= slab_height; v_offset += slab_height; } }
/* Pads a pixbuf to the specified size, by centering it in a larger transparent * pixbuf. Returns a new ref. */ static GdkPixbuf * theme_boxes_pad_to_size (GdkPixbuf *pixbuf, gint width, gint height, gint extra_padding_right) { gint src_width, src_height; GdkPixbuf *padded; gint x_offset, y_offset; src_width = gdk_pixbuf_get_width (pixbuf); src_height = gdk_pixbuf_get_height (pixbuf); x_offset = (width - src_width) / 2; y_offset = (height - src_height) / 2; padded = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (pixbuf), TRUE, /* alpha */ gdk_pixbuf_get_bits_per_sample (pixbuf), width + extra_padding_right, height); gdk_pixbuf_fill (padded, 0); gdk_pixbuf_copy_area (pixbuf, 0, /* source coords */ 0, src_width, src_height, padded, x_offset, /* dest coords */ y_offset); return padded; }
/** * Returns a new GdkPixbuf that is suitable for placing in the thumbnail view. * If source_pixbuf is not NULL, then it will fill the return pixbuf with the * contents of source_pixbuf. */ static GdkPixbuf * create_thumbnail_frame (int width, int height, GdkPixbuf *source_pixbuf, gboolean fill_bg) { GdkPixbuf *retval; int width_r, height_r; if (source_pixbuf) g_return_val_if_fail (GDK_IS_PIXBUF (source_pixbuf), NULL); width_r = gdk_pixbuf_get_width (source_pixbuf); height_r = gdk_pixbuf_get_height (source_pixbuf); /* make sure no one is passing us garbage */ g_return_val_if_fail (width_r >= 0 && height_r >= 0, NULL); retval = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width_r, height_r); gdk_pixbuf_fill (retval, 0x000000ff); /* copy the source pixbuf */ gdk_pixbuf_copy_area (source_pixbuf, 0, 0, width_r, height_r, retval, 0, 0); return retval; }
static void mpris2_album_art_update_image (Mpris2AlbumArt *albumart) { Mpris2AlbumArtPrivate *priv; GdkPixbuf *pixbuf, *album_art, *frame; GError *error = NULL; g_return_if_fail(MPRIS2_IS_ALBUM_ART(albumart)); priv = albumart->priv; frame = gdk_pixbuf_new_from_file (BASEICONDIR"/128x128/apps/mpris2-status-icon.png", &error); if(priv->path != NULL) { album_art = gdk_pixbuf_new_from_file_at_scale (priv->path, 112, 112, FALSE, &error); if (album_art) { gdk_pixbuf_copy_area(album_art, 0, 0, 112, 112, frame, 12, 8); g_object_unref(G_OBJECT(album_art)); } else { g_critical("Unable to open image file: %s\n", priv->path); g_error_free(error); } } pixbuf = gdk_pixbuf_scale_simple (frame, priv->size, priv->size, GDK_INTERP_BILINEAR); mpris2_album_art_set_pixbuf (albumart, pixbuf); g_object_unref (G_OBJECT(pixbuf)); g_object_unref (G_OBJECT(frame)); }
/** * eel_gdk_pixbuf_draw_to_pixbuf: * @pixbuf: The source pixbuf to draw. * @destination_pixbuf: The destination pixbuf. * @source_x: The source pixbuf x coordiate to composite from. * @source_y: The source pixbuf y coordiate to composite from. * @destination_area: The destination area within the destination pixbuf. * This area will be clipped if invalid in any way. * * Copy one pixbuf onto another another.. This function has some advantages * over plain gdk_pixbuf_copy_area(): * * Composition paramters (source coordinate, destination area) are * given in a way that is consistent with the rest of the extensions * in this file. That is, it matches the declaration of * eel_gdk_pixbuf_draw_to_pixbuf_alpha() and * eel_gdk_pixbuf_draw_to_drawable() very closely. * * All values are clipped to make sure they are valid. * */ void eel_gdk_pixbuf_draw_to_pixbuf (const GdkPixbuf *pixbuf, GdkPixbuf *destination_pixbuf, int source_x, int source_y, EelIRect destination_area) { EelDimensions dimensions; EelIRect target; EelIRect source; int target_width; int target_height; int source_width; int source_height; g_return_if_fail (eel_gdk_pixbuf_is_valid (pixbuf)); g_return_if_fail (eel_gdk_pixbuf_is_valid (destination_pixbuf)); g_return_if_fail (!eel_irect_is_empty (&destination_area)); dimensions = eel_gdk_pixbuf_get_dimensions (pixbuf); g_return_if_fail (source_x >= 0); g_return_if_fail (source_y >= 0); g_return_if_fail (source_x < dimensions.width); g_return_if_fail (source_y < dimensions.height); /* Clip the destination area to the pixbuf dimensions; bail if no work */ target = eel_gdk_pixbuf_intersect (destination_pixbuf, 0, 0, destination_area); if (eel_irect_is_empty (&target)) { return; } /* Assign the source area */ source = eel_irect_assign (source_x, source_y, dimensions.width - source_x, dimensions.height - source_y); /* Adjust the target width if the source area is smaller than the * source pixbuf dimensions */ target_width = target.x1 - target.x0; target_height = target.y1 - target.y0; source_width = source.x1 - source.x0; source_height = source.y1 - source.y0; target.x1 = target.x0 + MIN (target_width, source_width); target.y1 = target.y0 + MIN (target_height, source_height); gdk_pixbuf_copy_area (pixbuf, source.x0, source.y0, target.x1 - target.x0, target.y1 - target.y0, destination_pixbuf, target.x0, target.y0); }
void ZLGtkImageData::copyFrom(const ZLImageData &source, unsigned int targetX, unsigned int targetY) { gdk_pixbuf_copy_area( ((const ZLGtkImageData&)source).myPixbuf, 0, 0, source.width(), source.height(), myPixbuf, targetX, targetY ); }
GdkPixbuf *RecuperaQuadTree(node **raiz) { GdkPixbuf *img = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, (*raiz)->width, (*raiz)->height); if ( Opaco ( &(*raiz) ) ) { gdk_pixbuf_fill(img, (*raiz)->cor); return img; } else { GdkPixbuf *temp; gdk_pixbuf_fill(img, 0xffffff00); temp = RecuperaQuadTree( &(*raiz)->EsqSuperior ); gdk_pixbuf_copy_area (temp, 0, 0, gdk_pixbuf_get_width (temp), gdk_pixbuf_get_height (temp), img, 0, 0); temp = RecuperaQuadTree( &(*raiz)->EsqInferior ); gdk_pixbuf_copy_area (temp, 0, 0, gdk_pixbuf_get_width (temp), gdk_pixbuf_get_height (temp), img, 0, gdk_pixbuf_get_height (img) - gdk_pixbuf_get_height (temp)); temp = RecuperaQuadTree( &(*raiz)->DirSuperior ); gdk_pixbuf_copy_area (temp, 0, 0, gdk_pixbuf_get_width (temp), gdk_pixbuf_get_height (temp), img, gdk_pixbuf_get_width (img) - gdk_pixbuf_get_width (temp), 0); temp = RecuperaQuadTree( &(*raiz)->DirInferior ); gdk_pixbuf_copy_area (temp, 0, 0, gdk_pixbuf_get_width (temp), gdk_pixbuf_get_height (temp), img, gdk_pixbuf_get_width (img) - gdk_pixbuf_get_width (temp), gdk_pixbuf_get_height (img) - gdk_pixbuf_get_height (temp)); return img; } }
static cairo_surface_t * get_content_loading_icon (BgSource *source) { GtkIconTheme *theme; GtkIconInfo *icon_info; GdkPixbuf *pixbuf, *ret; GError *error = NULL; int scale_factor; cairo_surface_t *surface; int thumbnail_height; int thumbnail_width; theme = gtk_icon_theme_get_default (); icon_info = gtk_icon_theme_lookup_icon (theme, "content-loading-symbolic", 16, GTK_ICON_LOOKUP_FORCE_SIZE | GTK_ICON_LOOKUP_GENERIC_FALLBACK); if (icon_info == NULL) { g_warning ("Failed to find placeholder icon"); return NULL; } pixbuf = gtk_icon_info_load_icon (icon_info, &error); if (pixbuf == NULL) { g_warning ("Failed to load placeholder icon: %s", error->message); g_clear_error (&error); g_clear_object (&icon_info); return NULL; } thumbnail_height = bg_source_get_thumbnail_height (source); thumbnail_width = bg_source_get_thumbnail_width (source); ret = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, thumbnail_width, thumbnail_height); gdk_pixbuf_fill (ret, 0x00000000); /* Put the icon in the middle */ gdk_pixbuf_copy_area (pixbuf, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), ret, (thumbnail_width - gdk_pixbuf_get_width (pixbuf)) / 2, (thumbnail_height - gdk_pixbuf_get_height (pixbuf)) / 2); g_object_unref (pixbuf); scale_factor = bg_source_get_scale_factor (source); surface = gdk_cairo_surface_create_from_pixbuf (ret, scale_factor, NULL); g_object_unref (ret); g_clear_object (&icon_info); return surface; }
static void prepared_callback (GdkPixbufLoader *loader, gpointer data) { AniLoaderContext *context = (AniLoaderContext*)data; #ifdef DEBUG_ANI g_print ("%d pixbuf prepared\n", context->pos); #endif GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); if (!pixbuf) return; if (gdk_pixbuf_get_width (pixbuf) > context->animation->width) context->animation->width = gdk_pixbuf_get_width (pixbuf); if (gdk_pixbuf_get_height (pixbuf) > context->animation->height) context->animation->height = gdk_pixbuf_get_height (pixbuf); if (context->title != NULL) gdk_pixbuf_set_option (pixbuf, "Title", context->title); if (context->author != NULL) gdk_pixbuf_set_option (pixbuf, "Author", context->author); g_object_ref (pixbuf); context->animation->pixbufs[context->pos] = pixbuf; if (context->pos == 0) { if (context->prepared_func) (* context->prepared_func) (pixbuf, GDK_PIXBUF_ANIMATION (context->animation), context->user_data); } else { /* FIXME - this is necessary for nice display of loading animations because GtkImage ignores gdk_pixbuf_animation_iter_on_currently_loading_frame() and always exposes the full frame */ GdkPixbuf *last = context->animation->pixbufs[context->pos - 1]; gint width = MIN (gdk_pixbuf_get_width (last), gdk_pixbuf_get_width (pixbuf)); gint height = MIN (gdk_pixbuf_get_height (last), gdk_pixbuf_get_height (pixbuf)); gdk_pixbuf_copy_area (last, 0, 0, width, height, pixbuf, 0, 0); } context->pos++; }
static void callback_area_updated (GdkPixbufLoader *loader, int x, int y, int width, int height, GdkPixbuf *pixbuf_old) { GdkPixbuf *pixbuf_new; pixbuf_new = gdk_pixbuf_loader_get_pixbuf (loader); pixbuf_not_changed_outside_area (pixbuf_new, pixbuf_old, x, y, width, height); /* update copy of pixbuf */ gdk_pixbuf_copy_area (pixbuf_new, x, y, width, height, pixbuf_old, x, y); }
GdkPixbuf * gnac_ui_utils_add_border_to_pixbuf(GdkPixbuf *pixbuf) { g_return_val_if_fail(GDK_IS_PIXBUF(pixbuf), NULL); gint width = gdk_pixbuf_get_width(pixbuf); gint height = gdk_pixbuf_get_height(pixbuf); GdkPixbuf *bordered = gdk_pixbuf_new(gdk_pixbuf_get_colorspace(pixbuf), gdk_pixbuf_get_has_alpha(pixbuf), gdk_pixbuf_get_bits_per_sample(pixbuf), width + (GNAC_UTILS_ICON_BORDER_WIDTH*2), height +(GNAC_UTILS_ICON_BORDER_WIDTH*2)); gdk_pixbuf_fill(bordered, 0xff); gdk_pixbuf_copy_area(pixbuf, 0, 0, width, height, bordered, GNAC_UTILS_ICON_BORDER_WIDTH, GNAC_UTILS_ICON_BORDER_WIDTH); g_object_unref(pixbuf); return bordered; }
static void callback_area_updated_anim (GdkPixbufLoader *loader, int x, int y, int width, int height, FrameData *frame_old) { GdkPixbuf *pixbuf_new; /* "area-updated" signal was emitted after animation had fully loaded. */ g_assert_nonnull (frame_old->pixbuf); pixbuf_new = gdk_pixbuf_animation_iter_get_pixbuf (frame_old->iter); pixbuf_not_changed_outside_area (pixbuf_new, frame_old->pixbuf, x, y, width, height); gdk_pixbuf_copy_area (pixbuf_new, x, y, width, height, frame_old->pixbuf, x, y); update_currently_loaded_frame (frame_old); }
static void simple_gdk_pixbuf_scale_or_copy(GdkPixbuf *source, GdkPixbuf *dest) { gint height, width, src_height, src_width; src_height = gdk_pixbuf_get_height(source); src_width = gdk_pixbuf_get_width(source); height = gdk_pixbuf_get_height(dest); width = gdk_pixbuf_get_width(dest); if (src_width == width && src_height == height) gdk_pixbuf_copy_area(source, 0, 0, src_width, src_height, dest, 0, 0); else gdk_pixbuf_scale(source, dest, 0, 0, width, height, 0.0, 0.0, (gdouble)width/src_width, (gdouble)height/src_height, GDK_INTERP_TILES); }
static GdkPixbuf * add_border_to_shot (GdkPixbuf *pixbuf) { GdkPixbuf *retval; retval = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, gdk_pixbuf_get_width (pixbuf) + 2, gdk_pixbuf_get_height (pixbuf) + 2); /* Fill with solid black */ gdk_pixbuf_fill (retval, 0x000000FF); gdk_pixbuf_copy_area (pixbuf, 0, 0, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), retval, 1, 1); return retval; }
/* draw an arbitrary frame around an image, with the result passed back in a newly allocated pixbuf */ GdkPixbuf * eel_embed_image_in_frame (GdkPixbuf *source_image, GdkPixbuf *frame_image, int left_offset, int top_offset, int right_offset, int bottom_offset) { GdkPixbuf *result_pixbuf; int source_width, source_height; int dest_width, dest_height; source_width = gdk_pixbuf_get_width (source_image); source_height = gdk_pixbuf_get_height (source_image); dest_width = source_width + left_offset + right_offset; dest_height = source_height + top_offset + bottom_offset; result_pixbuf = eel_stretch_frame_image (frame_image, left_offset, top_offset, right_offset, bottom_offset, dest_width, dest_height, FALSE); /* Finally, copy the source image into the framed area */ gdk_pixbuf_copy_area (source_image, 0, 0, source_width, source_height, result_pixbuf, left_offset, top_offset); return result_pixbuf; }
static GdkPixbuf* create_slide (GdkPixbuf *base, int steps) { GdkPixbuf *result; int rw, rh; int bw, bh; int i; guchar *pixels, *p; int rowstride; int n_channels; int x, y; bw = gdk_pixbuf_get_width (base); bh = gdk_pixbuf_get_height (base); rw = bw * steps; rh = bh; result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, rw, rh); rowstride = gdk_pixbuf_get_rowstride (result); pixels = gdk_pixbuf_get_pixels (result); n_channels = gdk_pixbuf_get_n_channels (result); for (i = 0; i < steps; ++i) { gdk_pixbuf_copy_area (base, 0, 0, bw, bh, result, i * bw, 0); for (x = 0; x < bw; ++x) { for (y = 0; y < bh; ++y) { p = pixels + y * rowstride + (i * bw + x) * n_channels; p[3] = ((i + 1) * p[3]) / (steps + 1); } } } return result; }
static void pixbuf_changed (GtkIImageTool *tool, gboolean reset_fit, GdkRectangle *rect) { GtkImageToolSelector *selector = GTK_IMAGE_TOOL_SELECTOR (tool); if (reset_fit) selector->sel_rect = (GdkRectangle){0, 0, 0, 0}; GdkPixbuf *pixbuf = gtk_image_view_get_pixbuf (selector->view); if (!pixbuf) return; if (rect) { // Copy the damaged area from the foreground to the // background. gdk_pixbuf_copy_area (pixbuf, rect->x, rect->y, rect->width, rect->height, selector->background, rect->x, rect->y); } else { if (selector->background) g_object_unref (selector->background); selector->background = gdk_pixbuf_copy (pixbuf); } // Update the relevant area of the background. gdk_pixbuf_shade (selector->background, rect); // Clear caches gdk_pixbuf_draw_cache_invalidate (selector->bg_cache); gdk_pixbuf_draw_cache_invalidate (selector->fg_cache); }
GdkPixbuf * nautilus_thumbnail_unframe_image (GdkPixbuf *pixbuf) { GdkPixbuf *pixbuf_without_frame, *frame; int left_offset, top_offset, right_offset, bottom_offset; int w, h; /* The pixbuf isn't already framed (i.e., it was not made by * an old Nautilus), so we must embed it in a frame. */ frame = nautilus_get_thumbnail_frame (); if (frame == NULL) { return NULL; } left_offset = NAUTILUS_THUMBNAIL_FRAME_LEFT; top_offset = NAUTILUS_THUMBNAIL_FRAME_TOP; right_offset = NAUTILUS_THUMBNAIL_FRAME_RIGHT; bottom_offset = NAUTILUS_THUMBNAIL_FRAME_BOTTOM; w = gdk_pixbuf_get_width (pixbuf) - left_offset - right_offset; h = gdk_pixbuf_get_height (pixbuf) - top_offset - bottom_offset; pixbuf_without_frame = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (pixbuf), gdk_pixbuf_get_has_alpha (pixbuf), gdk_pixbuf_get_bits_per_sample (pixbuf), w, h); gdk_pixbuf_copy_area (pixbuf, left_offset, top_offset, w, h, pixbuf_without_frame, 0, 0); return pixbuf_without_frame; }
/* utility to make an attractive pattern image by compositing with a frame */ GdkPixbuf* nautilus_customization_make_pattern_chit (GdkPixbuf *pattern_tile, GdkPixbuf *frame, gboolean dragging, gboolean is_reset) { GdkPixbuf *pixbuf, *temp_pixbuf; int frame_width, frame_height; int pattern_width, pattern_height; g_assert (pattern_tile != NULL); g_assert (frame != NULL); frame_width = gdk_pixbuf_get_width (frame); frame_height = gdk_pixbuf_get_height (frame); pattern_width = gdk_pixbuf_get_width (pattern_tile); pattern_height = gdk_pixbuf_get_height (pattern_tile); pixbuf = gdk_pixbuf_copy (frame); /* scale the pattern tile to the proper size */ gdk_pixbuf_scale (pattern_tile, pixbuf, 2, 2, frame_width - 8, frame_height - 8, 0, 0, (double)(frame_width - 8 + 1)/pattern_width, (double)(frame_height - 8 + 1)/pattern_height, GDK_INTERP_BILINEAR); /* if we're dragging, get rid of the light-colored halo */ if (dragging) { temp_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, frame_width - 8, frame_height - 8); gdk_pixbuf_copy_area (pixbuf, 2, 2, frame_width - 8, frame_height - 8, temp_pixbuf, 0, 0); g_object_unref (pixbuf); pixbuf = temp_pixbuf; } return pixbuf; }