static GdkPixbuf * add_slideshow_frame (GdkPixbuf *pixbuf) { GdkPixbuf *sheet, *sheet2; GdkPixbuf *tmp; gint w, h; w = gdk_pixbuf_get_width (pixbuf); h = gdk_pixbuf_get_height (pixbuf); sheet = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, w, h); gdk_pixbuf_fill (sheet, 0x00000000); sheet2 = gdk_pixbuf_new_subpixbuf (sheet, 1, 1, w - 2, h - 2); gdk_pixbuf_fill (sheet2, 0xffffffff); g_object_unref (sheet2); tmp = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, w + 6, h + 6); gdk_pixbuf_fill (tmp, 0x00000000); gdk_pixbuf_composite (sheet, tmp, 6, 6, w, h, 6.0, 6.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255); gdk_pixbuf_composite (sheet, tmp, 3, 3, w, h, 3.0, 3.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255); gdk_pixbuf_composite (pixbuf, tmp, 0, 0, w, h, 0.0, 0.0, 1.0, 1.0, GDK_INTERP_NEAREST, 255); g_object_unref (sheet); return tmp; }
// Clear received picture & metadata void evt_clearPix() { gdk_pixbuf_fill (pixbuf_disp, 0); gtk_image_set_from_pixbuf(GTK_IMAGE(gui.image_rx), pixbuf_disp); gtk_label_set_markup (GTK_LABEL(gui.label_fskid), ""); gtk_label_set_markup (GTK_LABEL(gui.label_utc), ""); gtk_label_set_markup (GTK_LABEL(gui.label_lastmode), ""); }
/* 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; }
static GdkPixbuf * avatar_create_pixbuf (TwituxAvatar *avatar, gint size) { GdkPixbuf *tmp_pixbuf; GdkPixbuf *ret_pixbuf; GdkPixbufLoader *loader; GError *error = NULL; int orig_width; int orig_height; int scale_width; int scale_height; if (!avatar) { return NULL; } loader = gdk_pixbuf_loader_new (); if (!gdk_pixbuf_loader_write (loader, avatar->data, avatar->len, &error)) { g_warning ("Couldn't write avatar image: %p with " "length: %" G_GSIZE_FORMAT " to pixbuf loader: %s", avatar->data, avatar->len, error->message); g_error_free (error); return NULL; } gdk_pixbuf_loader_close (loader, NULL); tmp_pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); scale_width = orig_width = gdk_pixbuf_get_width (tmp_pixbuf); scale_height = orig_height = gdk_pixbuf_get_height (tmp_pixbuf); if (scale_height > scale_width) { scale_width = (gdouble) size * (gdouble) scale_width / (double) scale_height; scale_height = size; } else { scale_height = (gdouble) size * (gdouble) scale_height / (gdouble) scale_width; scale_width = size; } ret_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 32, 32); gdk_pixbuf_fill (ret_pixbuf, 0x00000000); gdk_pixbuf_scale (tmp_pixbuf, ret_pixbuf, (size - scale_width)/2, (size - scale_height)/2, scale_width, scale_height, (size - scale_width)/2, (size - scale_height)/2, (double)scale_width/(double)orig_width, (double)scale_height/(double)orig_height, GDK_INTERP_BILINEAR); if (avatar_pixbuf_is_opaque (ret_pixbuf)) { avatar_pixbuf_roundify (ret_pixbuf); } g_object_unref (loader); return ret_pixbuf; }
/*************************************************************************** ... ***************************************************************************/ void create_overlay_unit(struct canvas *pcanvas, struct unit_type *punittype) { int x1, x2, y1, y2; int width, height; struct sprite *sprite = get_unittype_sprite(tileset, punittype); sprite_get_bounding_box(sprite, &x1, &y1, &x2, &y2); if (pcanvas->type == CANVAS_PIXBUF) { width = gdk_pixbuf_get_width(pcanvas->v.pixbuf); height = gdk_pixbuf_get_height(pcanvas->v.pixbuf); gdk_pixbuf_fill(pcanvas->v.pixbuf, 0x00000000); } else { if (pcanvas->type == CANVAS_PIXCOMM) { gtk_pixcomm_clear(pcanvas->v.pixcomm); } /* Guess */ width = tileset_full_tile_width(tileset); height = tileset_full_tile_height(tileset); } /* Finally, put a picture of the unit in the tile */ canvas_put_sprite(pcanvas, 0, 0, sprite, (x2 + x1 - width) / 2, (y1 + y2 - height) / 2, tileset_full_tile_width(tileset) - (x2 + x1 - width) / 2, tileset_full_tile_height(tileset) - (y1 + y2 - height) / 2); }
static void draw_shadow (GdkPixmap *pixmap, int x, int y, int width, int height) { GdkPixbuf *shadow; int i, alpha = 0, max; shadow = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height); gdk_pixbuf_fill (shadow, 0x00000000); max = MAX (width / 2, height / 2); for (i = 1; i < max; i++) { _gdk_pixbuf_draw_rectangle (shadow, i, alpha); alpha += 12; alpha = MIN (alpha, 255); } gdk_pixbuf_render_to_drawable_alpha (shadow, pixmap, 0, 0, x, y, width, height, GDK_PIXBUF_ALPHA_FULL, 255, GDK_RGB_DITHER_MAX, 0, 0); g_object_unref (shadow); }
static GdkPixbuf * egg_status_icon_blank_icon (EggStatusIcon *status_icon) { if (status_icon->priv->blank_icon) { gint width, height; width = gdk_pixbuf_get_width (status_icon->priv->blank_icon); height = gdk_pixbuf_get_width (status_icon->priv->blank_icon); if (width == status_icon->priv->size && height == status_icon->priv->size) { return status_icon->priv->blank_icon; } else { g_object_unref (status_icon->priv->blank_icon); status_icon->priv->blank_icon = NULL; } } status_icon->priv->blank_icon = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, status_icon->priv->size, status_icon->priv->size); if (status_icon->priv->blank_icon) gdk_pixbuf_fill (status_icon->priv->blank_icon, 0); return status_icon->priv->blank_icon; }
static void set_cell_color (GtkCellLayout *cell_layout, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { gchar *text; GdkRGBA color; guint32 pixel = 0; GdkPixbuf *pixbuf; gtk_tree_model_get (tree_model, iter, COL_TEXT, &text, -1); if (!text) return; if (gdk_rgba_parse (&color, text)) pixel = ((gint)(color.red * 255)) << 24 | ((gint)(color.green * 255)) << 16 | ((gint)(color.blue * 255)) << 8 | ((gint)(color.alpha * 255)); g_free (text); pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 24, 24); gdk_pixbuf_fill (pixbuf, pixel); g_object_set (cell, "pixbuf", pixbuf, NULL); g_object_unref (pixbuf); }
AwnApplet* awn_applet_factory_initp(const gchar *name, const gchar* uid, gint panel_id) { AwnApplet *applet = AWN_APPLET(awn_applet_simple_new(name, uid, panel_id)); CpuMeter *cpumeter; g_object_set (applet, "display-name","Awn System Monitor", NULL); gint height = awn_applet_get_size(applet); gtk_widget_set_size_request(GTK_WIDGET(applet), height*1.25, -1); GdkPixbuf *icon; #if 0 icon = gtk_icon_theme_load_icon(gtk_icon_theme_get_default(), "gnome-main-menu", height - 2, 0, NULL); awn_applet_simple_set_temp_icon(AWN_APPLET_SIMPLE(applet), icon); #endif /*setting to a transparent pixbuf to begin with... awn-effects (I think) does not seem to deal well with having the icon set overly late*/ #if 1 icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, height, height); gdk_pixbuf_fill(icon, 0x00000000); awn_applet_simple_set_icon_pixbuf(AWN_APPLET_SIMPLE(applet), icon); #endif cpumeter = cpumeter_applet_new(applet); cpumeter->height = height; /*gtk_widget_show_all(GTK_WIDGET(applet));*/ return applet; }
/** * gwy_data_view_get_thumbnail: * @data_view: A #GwyDataView. * @size: Requested thumbnail size. * * Creates and returns a thumbnail of the data view. * * If the data is not square, it is centered onto the pixbuf, with transparent * borders. The returned pixbuf always has an alpha channel, even if it fits * exactly. * * Returns: The thumbnail as a newly created #GdkPixbuf, which should be freed * when no longer needed. **/ GdkPixbuf* gwy_data_view_get_thumbnail(GwyDataView *data_view, gint size) { GdkPixbuf *pixbuf; gint width, height, width_scaled, height_scaled; gdouble scale; g_return_val_if_fail(GWY_IS_DATA_VIEW(data_view), NULL); g_return_val_if_fail(data_view->pixbuf, NULL); g_return_val_if_fail(size > 0, NULL); pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, BITS_PER_SAMPLE, size, size); gwy_debug_objects_creation(G_OBJECT(pixbuf)); gdk_pixbuf_fill(pixbuf, 0x00000000); width = gdk_pixbuf_get_width(data_view->pixbuf); height = gdk_pixbuf_get_height(data_view->pixbuf); scale = MIN((gdouble)size/width, (gdouble)size/height); width_scaled = CLAMP((gint)(scale*width), 1, size); height_scaled = CLAMP((gint)(scale*height), 1, size); gdk_pixbuf_scale(data_view->pixbuf, pixbuf, (size - width_scaled)/2, (size - height_scaled)/2, width_scaled, height_scaled, (size - width_scaled)/2, (size - height_scaled)/2, scale, scale, GDK_INTERP_TILES); return pixbuf; }
Doppelganger* doppelganger_new (char *name) { Doppelganger *result = g_malloc (sizeof (Doppelganger)); GdkPixbuf *blank; int current_pointer; result->mpx = add_mpx_for_window (name); result->cursor = NULL; doppelganger_set_image (result, NULL); blank = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 1, 1); gdk_pixbuf_fill (blank, 0); /* transparent */ result->blank = gdk_cursor_new_from_pixbuf (gdk_display_get_default (), blank, 0, 0); gdk_pixbuf_unref (blank); show_cursor (result); return result; }
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 GtkWidget * make_colored_menu_item (char const *label, GOColor c) { GtkWidget *button; GdkPixbuf *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, COLOR_PREVIEW_WIDTH, COLOR_PREVIEW_HEIGHT); gdk_pixbuf_fill (pixbuf, c); if (label && 0 == strcmp (label, " ")) { /* color buttons are created with a label of " " */ button = gtk_menu_item_new (); gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_pixbuf (pixbuf)); } else { button = gtk_image_menu_item_new_with_label (label); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (button), gtk_image_new_from_pixbuf (pixbuf)); } g_object_unref (pixbuf); gtk_widget_show_all (button); g_object_set_data (G_OBJECT (button), "go_color", GINT_TO_POINTER (c)); /* Workaround for bug http://bugzilla.gnome.org/show_bug.cgi?id=585421 */ g_signal_connect (button, "toggle-size-request", G_CALLBACK (cb_menu_item_toggle_size_request), NULL); return button; }
/** * 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; }
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; }
static gboolean qr_avatar_render_hook(gpointer source, gpointer data) { AvatarRender *ar = (AvatarRender *)source; GtkWidget *image = NULL; gchar * text; QRcode *qrcode; unsigned char * qrdata; GdkPixbuf *pixbuf, *pixbuf_scaled; int i, j, k, rowstride, channels; guchar *pixel; debug_print("qr-avatar qr_avatar_render_hook() invoked\n"); if ((text = procmsg_msginfo_get_avatar(ar->full_msginfo, QR_AVATAR_QR_AVATAR)) != NULL) { if ((qrcode = QRcode_encodeString8bit(text, 0, QR_ECLEVEL_L)) == NULL) return FALSE; qrdata = qrcode->data; pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, qrcode->width, qrcode->width); pixel = gdk_pixbuf_get_pixels(pixbuf); rowstride = gdk_pixbuf_get_rowstride(pixbuf); channels = gdk_pixbuf_get_n_channels(pixbuf); gdk_pixbuf_fill(pixbuf, 0xffffffff); for (i = 0; i < qrcode->width; i++) for (j = 0; j < qrcode->width; j++) { for (k = 0; k < channels; k++) pixel[i * rowstride + j * channels + k] = !(*qrdata & 0x1) * 0xff; qrdata++; } /* claws-mail is limited to avatar with 48x48 pixels * TODO: skip scaling as soon as different sizes are supported */ pixbuf_scaled = gdk_pixbuf_scale_simple(pixbuf, QR_AVATAR_SIZE, QR_AVATAR_SIZE, GDK_INTERP_BILINEAR); QRcode_free(qrcode); g_object_unref(pixbuf); image = gtk_image_new_from_pixbuf(pixbuf_scaled); g_object_unref(pixbuf_scaled); if (ar->image != NULL) /* previous plugin set one */ gtk_widget_destroy(ar->image); ar->image = image; return TRUE; } return FALSE; /* keep rendering */ }
static GdkPixbuf * remove_shaped_area (GdkPixbuf *pixbuf, Window window) { Display *display; GdkPixbuf *retval; XRectangle *rectangles; gint rectangle_count, rectangle_order; gint i; retval = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf)); gdk_pixbuf_fill (retval, 0); display = gdk_x11_display_get_xdisplay (gdk_display_get_default ()); rectangles = XShapeGetRectangles (display, window, ShapeBounding, &rectangle_count, &rectangle_order); for (i = 0; i < rectangle_count; i++) { int y, x; for (y = rectangles[i].y; y < rectangles[i].y + rectangles[i].height; y++) { const guchar *src_pixels; guchar *dest_pixels; src_pixels = gdk_pixbuf_get_pixels (pixbuf) + y * gdk_pixbuf_get_rowstride (pixbuf) + rectangles[i].x * (gdk_pixbuf_get_has_alpha (pixbuf) ? 4 : 3); dest_pixels = gdk_pixbuf_get_pixels (retval) + y * gdk_pixbuf_get_rowstride (retval) + rectangles[i].x * 4; for (x = rectangles[i].x; x < rectangles[i].x + rectangles[i].width; x++) { *dest_pixels++ = *src_pixels ++; *dest_pixels++ = *src_pixels ++; *dest_pixels++ = *src_pixels ++; *dest_pixels++ = 255; if (gdk_pixbuf_get_has_alpha (pixbuf)) src_pixels++; } } } return retval; }
static void populate_flowbox (GtkWidget *button, GtkWidget *flowbox) { const gchar *location; GDir *dir; GError *error = NULL; const gchar *name; gchar *filename; GFile *file; GInputStream *stream; BackgroundData *bd; GdkPixbuf *pixbuf; GtkWidget *child; g_signal_handlers_disconnect_by_func (button, populate_flowbox, flowbox); pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 110, 70); gdk_pixbuf_fill (pixbuf, 0xffffffff); child = gtk_image_new_from_pixbuf (pixbuf); gtk_widget_show (child); gtk_flow_box_insert (GTK_FLOW_BOX (flowbox), child, -1); location = "/usr/share/backgrounds/gnome"; dir = g_dir_open (location, 0, &error); if (error) { g_warning ("%s", error->message); g_error_free (error); return; } while ((name = g_dir_read_name (dir)) != NULL) { filename = g_build_filename (location, name, NULL); file = g_file_new_for_path (filename); stream = G_INPUT_STREAM (g_file_read (file, NULL, &error)); if (error) { g_warning ("%s", error->message); g_clear_error (&error); g_free (filename); } else { bd = g_new (BackgroundData, 1); bd->flowbox = flowbox; bd->filename = filename; gdk_pixbuf_new_from_stream_at_scale_async (stream, 110, 110, TRUE, NULL, background_loaded_cb, bd); } g_object_unref (file); g_object_unref (stream); } g_dir_close (dir); }
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 GdkPixbuf * make_symbolic_pixbuf (char *file, int width, int height, GError **error) { GdkRGBA r = { 1,0,0,1}, g = {0,1,0,1}; GdkPixbuf *loaded; GdkPixbuf *pixbuf; int plane; gchar *file_data; gsize file_len; if (!g_file_get_contents (file, &file_data, &file_len, error)) return NULL; pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height); gdk_pixbuf_fill (pixbuf, 0); for (plane = 0; plane < 3; plane++) { /* Here we render the svg with all colors solid, this should * always make the alpha channel the same and it should match * the final alpha channel for all possible renderings. We * Just use it as-is for final alpha. * * For the 3 non-fg colors, we render once each with that * color as red, and every other color as green. The resulting * red will describe the amount of that color is in the * opaque part of the color. We store these as the rgb * channels, with the color of the fg being implicitly * the "rest", as all color fractions should add up to 1. */ loaded = load_symbolic_svg (file_data, file_len, width, height, &g, plane == 0 ? &r : &g, plane == 1 ? &r : &g, plane == 2 ? &r : &g, error); if (loaded == NULL) return NULL; if (plane == 0) extract_plane (loaded, pixbuf, 3, 3); extract_plane (loaded, pixbuf, 0, plane); g_object_unref (loaded); } g_free (file_data); return pixbuf; }
static void gwy_app_file_chooser_update_preview(GwyAppFileChooser *chooser) { GtkFileChooser *fchooser; GtkTreeModel *model; GdkPixbuf *pixbuf; GtkTreeIter iter; gchar *filename_sys; gwy_app_file_chooser_free_preview(chooser); model = gtk_icon_view_get_model(GTK_ICON_VIEW(chooser->preview)); gtk_list_store_clear(GTK_LIST_STORE(model)); fchooser = GTK_FILE_CHOOSER(chooser); filename_sys = gtk_file_chooser_get_preview_filename(fchooser); /* It should be UTF-8, but don't convert it just for gwy_debug() */ gwy_debug("%s", filename_sys); /* Make directories fail gracefully */ if (filename_sys && g_file_test(filename_sys, G_FILE_TEST_IS_DIR)) { g_free(filename_sys); filename_sys = NULL; } /* Never set the preview inactive. Gtk+ can do all kinds of silly things * if you do. */ if (!filename_sys) return; pixbuf = _gwy_app_recent_file_try_thumbnail(filename_sys); g_free(filename_sys); if (!pixbuf) { pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 1, 1); gdk_pixbuf_fill(pixbuf, 0x00000000); chooser->make_thumbnail = TRUE; } else chooser->make_thumbnail = FALSE; g_object_set(chooser->renderer_fileinfo, "ellipsize", PANGO_ELLIPSIZE_NONE, "wrap-width", TMS_NORMAL_THUMB_SIZE, NULL); gtk_list_store_insert_with_values(GTK_LIST_STORE(model), &iter, -1, COLUMN_PIXBUF, pixbuf, COLUMN_FILEINFO, _("…"), -1); g_object_unref(pixbuf); chooser->full_preview_id = g_timeout_add_full(G_PRIORITY_LOW, 250, gwy_app_file_chooser_do_full_preview, chooser, NULL); }
void picture_start(gint w, gint h, gboolean color) { GtkWidget *widget; picture_stop(); picture = g_new0(Picture, 1); picture->width = w; picture->height = h; picture->color = color; picture->x = 0; picture->y = 0; picture->rgb = 0; picture->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, w, h); picture->rowstride = gdk_pixbuf_get_rowstride(picture->pixbuf); gdk_pixbuf_fill(picture->pixbuf, 0xaaaaaaff); if (TRUE) { picture->window = create_picwindow(); picture->image = gtk_image_new_from_pixbuf(picture->pixbuf); widget = lookup_widget(picture->window, "pictureframe"); gtk_container_add(GTK_CONTAINER(widget), picture->image); gtk_widget_show_all(picture->window); g_signal_connect((gpointer) picture->window, "delete_event", G_CALLBACK(delete_callback), (gpointer) picture); widget = lookup_widget(picture->window, "picturesavebutton"); g_signal_connect((gpointer) widget, "clicked", G_CALLBACK(on_picturesavebutton_clicked), (gpointer) picture); widget = lookup_widget(picture->window, "pictureclosebutton"); g_signal_connect((gpointer) widget, "clicked", G_CALLBACK(on_pictureclosebutton_clicked), (gpointer) picture); } else { textview_insert_pixbuf("rxtext", picture->pixbuf); } picture->active = TRUE; }
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 draw (QCADDesignObject *obj, GdkDrawable *dst, GdkFunction rop, GdkRectangle *rcClip) { int Nix, Nix1 ; QCADClockingLayer *clocking_layer = QCAD_CLOCKING_LAYER (obj) ; QCADLayer *layer = QCAD_LAYER (obj) ; GdkGC *gc = NULL ; double potential ; GList *llItr = NULL ; double x, y; QCAD_DESIGN_OBJECT_CLASS (g_type_class_peek (g_type_parent (QCAD_TYPE_CLOCKING_LAYER)))->draw (obj, dst, rop, rcClip) ; gc = gdk_gc_new (dst) ; gdk_gc_set_foreground (gc, clr_idx_to_clr_struct (RED)) ; gdk_gc_set_background (gc, clr_idx_to_clr_struct (RED)) ; gdk_gc_set_clip_rectangle (gc, rcClip) ; if (NULL != layer->lstObjs && clocking_layer->bDrawPotential) { GdkPixbuf *pb = NULL ; pb = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, clocking_layer->tile_size, clocking_layer->tile_size) ; for (Nix = 0; Nix < Nx; Nix++) { x = xmin+dx*Nix; for (Nix1 = 0; Nix1 < Ny; Nix1++) { y = ymin+dy*Nix1; potential = get_potential (x, y, clocking_layer->z_to_draw, Nx, Ny, Nz, dx, dy, dz, xmin, ymin) ; /* if (fabs (potential) < clocking_layer->dExtremePotential / 100.0) { fprintf (stderr, "Potential too small - breaking out\n") ; // continue ; } */ gdk_pixbuf_fill (pb, ((potential > 0) ? 0xFF000000 : 0x0000FF00) | (((int)((fabs (potential) / clocking_layer->dExtremePotential) * 128.0)) & 0xFF)) ; // fprintf (stderr, "opacity = %lf/%lf * 255\n", potential, clocking_layer->dExtremePotential) ; gdk_draw_pixbuf (dst, gc, pb, 0, 0, Nix * clocking_layer->tile_size, Nix1 * clocking_layer->tile_size, clocking_layer->tile_size, clocking_layer->tile_size, GDK_RGB_DITHER_NONE, 0, 0) ; //gdk_draw_pixbuf (dst, gc, pb, 0, 0, Nix * clocking_layer->tile_size, Nix1 * clocking_layer->tile_size, clocking_layer->tile_size, clocking_layer->tile_size, GDK_RGB_DITHER_NONE, 0, 0) ; // gdk_draw_rectangle (dst, gc, TRUE, // Nix * clocking_layer->tile_size + (clocking_layer->tile_size >> 1) - 2, // Nix1 * clocking_layer->tile_size + (clocking_layer->tile_size >> 1) - 2, // 5, 5) ; } } g_object_unref (pb) ; } g_object_unref (gc) ; }
GdkPixbuf * create_empty_pixbuf(gint dest_width, gint dest_height) { GdkPixbuf *pix; if (dest_width < 1) dest_width = 1; if (dest_height < 1) dest_height = 1; pix = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, dest_width, dest_height); gdk_pixbuf_fill (pix, 0); return pix; }
/** * Update view buffer with new animation frame data. * * The functino does not update any display related variable (like offset or * viewport) since all animation frames have same dimensions and we want * animation to play with given zoom. * * It is called automatically from timeout installed by g_timeout_add() * * \todo track if somebody changed image by utilizing sequence number * * \param data pointer to ViewImageDisplay structure cast to gpointer * \return FALSE */ gboolean view_idv_update_frame(gpointer data) { FrameUpdate *update = (FrameUpdate*) data; ViewImageDisplay* idv_data = NULL; gint delay = -1; GdkPixbuf* image = NULL; if ( update->sequence != update->view->last_sequence ) { g_free( (gpointer)data ); return FALSE; } idv_data = view_idv_get_data_pointer(update->view); if ( NULL == idv_data ) { g_free( (gpointer)data ); return FALSE; } // composite image to the internal view buffer image = model_iml_get_image(update->view->model); if ( NULL == image ) { ERROR_LOG(); g_free( (gpointer)data ); return FALSE; } gdk_pixbuf_fill( idv_data->view_buffer, 0x000000ff); gdk_pixbuf_composite(image, idv_data->view_buffer, // destination position idv_data->viewport.x, idv_data->viewport.y, // destination dimension idv_data->viewport.width, idv_data->viewport.height, // offsets idv_data->viewport.x - idv_data->offset.x, idv_data->viewport.y - idv_data->offset.y, // zoom in both axes idv_data->zoom_factor, idv_data->zoom_factor, GDK_INTERP_BILINEAR, 255 ); // invalidate the image view region gdk_window_invalidate_rect(update->view->window, &(update->view->region), FALSE); // check and install new frame update timeout delay = model_iml_get_delay(update->view->model); if ( -1 != delay ) { g_timeout_add(delay, view_idv_update_frame, (gpointer)update); } else { g_free( (gpointer)data ); } return FALSE; }
gint render_camera(gpointer data) { GdkPixbuf *pixbuf = NULL; GdkPixbuf *blobbuf= NULL; GdkGC *gc = NULL; GtkWidget *drawing_area = GTK_WIDGET(data); uint16_t i; gc = GTK_WIDGET(drawing_area)->style->fg_gc[GTK_WIDGET_STATE(GTK_WIDGET(drawing_area))]; player_update(); if (g_blob_count > 0) { // Draw the blobs blobbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 1, 1); for (i=0; i< g_blob_count; ++i) { // shift the color by 8-bits to account for the alpha channel gdk_pixbuf_fill(blobbuf, g_blobs[i].color << 8); gdk_pixbuf_composite(blobbuf, g_pixbuf, g_blobs[i].left, g_blobs[i].top, abs(g_blobs[i].right - g_blobs[i].left), abs(g_blobs[i].top - g_blobs[i].bottom), 1, 1, 1, 1, GDK_INTERP_NEAREST, 128); } gdk_pixbuf_unref(blobbuf); } // scale everything at the end if ((g_width==g_window_width)&&(g_height==g_window_height)) { // we don't need to worry about scaling gdk_draw_pixbuf(GTK_WIDGET(drawing_area)->window, gc, g_pixbuf, 0, 0, 0, 0, g_width, g_height, GDK_RGB_DITHER_NONE, 0, 0); } else { pixbuf = gdk_pixbuf_scale_simple(g_pixbuf, g_window_width, g_window_height, GDK_INTERP_BILINEAR); gdk_draw_pixbuf(GTK_WIDGET(drawing_area)->window, gc, pixbuf, 0, 0, 0, 0, g_window_width, g_window_height, GDK_RGB_DITHER_NONE, 0, 0); gdk_pixbuf_unref(pixbuf); } return TRUE; }
static GdkPixbuf * renderer_create_empty_background( MMB_Screen *screen ) { GdkPixbuf *pb = gdk_pixbuf_new( GDK_COLORSPACE_RGB, TRUE, 8, screen->base.w, screen->base.h ); if ( pb == NULL ) { fprintf( stderr, "Failed to create background pixmap\n" ); exit( EXIT_FAILURE ); } // Make the wallpaper black. gdk_pixbuf_fill( pb, 0x000000FF ); return pb; }
Pixbuf::Pixbuf() { _width = 500; _height = 500; _ref = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, _width, _height); gdk_pixbuf_fill(_ref, 0xffffffff ); _scale = 1; n_channels = gdk_pixbuf_get_n_channels(_ref); rowstride = gdk_pixbuf_get_rowstride(_ref); pixels = gdk_pixbuf_get_pixels(_ref); };
static GdkPixbuf* gwy_app_recent_file_list_get_failed_pixbuf(void) { static GdkPixbuf *failed_pixbuf = NULL; if (!failed_pixbuf) { failed_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, THUMB_SIZE, THUMB_SIZE); gwy_debug_objects_creation(G_OBJECT(failed_pixbuf)); gdk_pixbuf_fill(failed_pixbuf, 0); } return failed_pixbuf; }