58
58
/* make sure no one is passing us garbage */
59
g_assert (width_r >= 0 && height_r >= 0);
59
g_return_val_if_fail (width_r >= 0 && height_r >= 0, NULL);
61
61
retval = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
140
140
gboolean highlight,
141
141
gboolean inverted_colors)
143
GtkStyle *style = gtk_widget_get_style (widget);
144
GtkStateType state = gtk_widget_get_state (widget);
146
gdk_cairo_set_source_color (cr, highlight ? &style->text[state] : &style->dark[state]);
143
GtkStyleContext *context = gtk_widget_get_style_context (widget);
144
GtkStateFlags state = gtk_widget_get_state_flags (widget);
145
GdkRGBA fg, bg, shade_bg;
146
GtkSymbolicColor *c1, *c2;
148
gtk_style_context_get_background_color (context, state, &bg);
149
gtk_style_context_get_color (context, state, &fg);
151
// FIXME: should we cache the shade_bg?
152
c1 = gtk_symbolic_color_new_literal (&bg);
153
c2 = gtk_symbolic_color_new_shade (c1, 0.7);
154
gtk_symbolic_color_resolve (c2, NULL, &shade_bg);
155
gtk_symbolic_color_unref (c1);
156
gtk_symbolic_color_unref (c2);
158
gdk_cairo_set_source_rgba (cr, highlight ? &fg : &shade_bg);
147
159
gdk_cairo_rectangle (cr, area);
158
170
area->height - (border->top + border->bottom));
161
gdk_cairo_set_source_color (cr, &style->mid[state]);
173
gdk_cairo_set_source_rgba (cr, &bg);
162
174
cairo_rectangle (cr,
164
176
area->y + area->height - (border->bottom - border->top),
180
192
cairo_surface_t *surface;
195
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
183
197
surface = cairo_image_surface_create (gdk_pixbuf_get_has_alpha (pixbuf) ?
184
198
CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24,
185
199
gdk_pixbuf_get_width (pixbuf),
196
210
ev_document_misc_pixbuf_from_surface (cairo_surface_t *surface)
199
cairo_surface_t *image;
203
cairo_format_t surface_format;
204
gint pixbuf_n_channels;
205
gint pixbuf_rowstride;
206
guchar *pixbuf_pixels;
209
width = cairo_image_surface_get_width (surface);
210
height = cairo_image_surface_get_height (surface);
212
surface_format = cairo_image_surface_get_format (surface);
213
has_alpha = (surface_format == CAIRO_FORMAT_ARGB32);
215
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
218
pixbuf_n_channels = gdk_pixbuf_get_n_channels (pixbuf);
219
pixbuf_rowstride = gdk_pixbuf_get_rowstride (pixbuf);
220
pixbuf_pixels = gdk_pixbuf_get_pixels (pixbuf);
222
image = cairo_image_surface_create_for_data (pixbuf_pixels,
226
cr = cairo_create (image);
227
cairo_set_source_surface (cr, surface, 0, 0);
230
cairo_mask_surface (cr, surface, 0, 0);
235
cairo_surface_destroy (image);
237
for (y = 0; y < height; y++) {
238
guchar *p = pixbuf_pixels + y * pixbuf_rowstride;
240
for (x = 0; x < width; x++) {
243
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
247
p[3] = (has_alpha) ? p[3] : 0xff;
253
p[3] = (has_alpha) ? tmp : 0xff;
255
p += pixbuf_n_channels;
212
g_return_val_if_fail (surface, NULL);
214
return gdk_pixbuf_get_from_surface (surface,
216
cairo_image_surface_get_width (surface),
217
cairo_image_surface_get_height (surface));
262
220
cairo_surface_t *