From: pete <psh...@gm...> - 2011-05-07 16:25:12
|
On 04/05/11 04:49, hermann wrote: > Am Dienstag, den 03.05.2011, 15:20 +0100 schrieb pete: >> i guess i wasn't very clear, sorry. let me put it another way: >> >> if we want to scale images that are loaded via the gtk icon cache >> can we use that same cache to store and then reference >> the modified images? (as we would need to) > > The stock_id is just a const gchar, not a PixBufer. We create the Pixbuf > by gtk_widget_render_icon () > http://developer.gnome.org/gtk/2.24/GtkWidget.html#gtk-widget-render-icon yeah, i didn't mean "encode" in the graphical sense. we would need to put the scaling parameters in the stock id to use as a new id. for example, if we specified a 50x500 target size for stock id "foo" and the source image did not match, we would then scale it, unref the initial image then create a new iconset with the scaled foo image and the stock id "foo-50x500". i think the gtk icon cache only supports fixed sizes (for icons) referenced by an enum so we can't use that directly. then any widget would reconstruct that id to lookup it's image via a wrapper to gtk_widget_render_icon when necessary. the wrapper function would detect a missing image and lookup and scale the base stock id image and insert it into the cache as above. > So yes, we could scale it in the same cache. > GxKnob.cpp line 366 > > static gboolean gx_knob_expose(GtkWidget *widget, GdkEventExpose *event) > { > g_assert(GX_IS_KNOB(widget)); > GdkRectangle image_rect, value_rect; > GdkPixbuf *pb = gtk_widget_render_icon(widget, get_stock_id(widget), > GtkIconSize(-1), NULL); > if (GDK_IS_PIXBUF (pb)) { > gint fcount; > gtk_widget_style_get (widget, "knob-framecount", > &fcount, NULL); > image_rect.width = gdk_pixbuf_get_width(pb); > image_rect.height = gdk_pixbuf_get_height(pb); > if (fcount>1) > image_rect.width = (image_rect.width / fcount); > if (fcount == 0) { // rc directs to assume square frames > fcount = (image_rect.width / image_rect.height); > image_rect.width = image_rect.height; > } > gdouble knobstate = _gx_regler_get_step_pos(GX_REGLER(widget), 1); > _gx_regler_get_positions(GX_REGLER(widget),&image_rect,&value_rect); > _gx_knob_expose(widget,&image_rect, knobstate, pb, fcount); > _gx_regler_display_value(GX_REGLER(widget),&value_rect); > g_object_unref(pb); > } > return FALSE; > } > > |